Closed ambehnam closed 1 year ago
I found the command for importing the material data from Example_06 which are:
MAT = ExtAPI.DataModel.Project.Model.Materials
MAT.Import(mat_Copper_file_path)
MAT.Import(mat_Steel_file_path)
However, when I run this example I get the following error (Ansys 2023R1):
_MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "'Materials' object has no attribute 'Import'"
debug_error_string = "UNKNOWN:Error received from peer {created_time:"2023-07-07T15:44:16.840381658+00:00", grpc_status:2, grpc_message:"\'Materials\' object has no attribute \'Import\'"}"
Materials.Import is only supported from Ansys 2023R2 onwards. Prior to that version, we have a workaround. See the file src/ansys/mechanical/core/embedding/shims.py for more information.
@koubaa Hi Mohamed. Thanks, I used the jscript as a workaround to import the material until the 23R2 is released. I have another issue that is mentioned in the original post for importing external data. I use the following script and I get an error:
Model.AddSteadyStateThermalAnalysis()
ST_STA = Model.Analyses[0]
imported_load_group_104 = ST_STA.AddImportedLoadExternalData()
external_data_files = Ansys.Mechanical.ExternalData.ExternalDataFileCollection()
external_data_files.SaveFilesWithProject = False
external_data_file_1 = Ansys.Mechanical.ExternalData.ExternalDataFile()
external_data_files.Add(external_data_file_1)
external_data_file_1.Identifier = "File1"
external_data_file_1.Description = ""
external_data_file_1.IsMainFile = True
external_data_file_1.FilePath = r"C:\\Ansys\\CCD_power_map.csv"
external_data_file_1.ImportSettings = Ansys.Mechanical.ExternalData.ImportSettingsFactory.GetSettingsForFormat(MechanicalEnums.ExternalData.ImportFormat.Delimited)
import_settings = external_data_file_1.ImportSettings
import_settings.SkipRows = 0
import_settings.SkipFooter = 0
import_settings.Delimiter = ","
import_settings.AverageCornerNodesToMidsideNodes = "True"
import_settings.UseColumn(1, MechanicalEnums.ExternalData.VariableType.XCoordinate, "mm", "X Coordinate@B")
import_settings.UseColumn(2, MechanicalEnums.ExternalData.VariableType.YCoordinate, "mm", "Y Coordinate@C")
import_settings.UseColumn(3, MechanicalEnums.ExternalData.VariableType.ZCoordinate, "mm", "Z Coordinate@D")
import_settings.UseColumn(4, MechanicalEnums.ExternalData.VariableType.HeatFlux, "W m^-2", "Heat Flux@E")
imported_load_group_104.ImportExternalDataFiles(external_data_files)
imported_heatflux_111 = imported_load_group_104.AddImportedHeatFlux()
imported_heatflux_111.Location = CCDs_NS
imported_heatflux_111.Import()
The error screenshot is attached. Do you know what might be wrong that causes this error? The error is for imported_load_group_104.ImportExternalDataFiles(external_data_files) which is AttributeError:'NoneType' object has no attribute 'ImportExternalDataFile'
Found the issue through Ansys Support. The problem was I was not using the Stand alone version of Mechanical using the following command: 'C:\Program Files\ANSYS Inc\v231\aisol\Bin\winx64\AnsysWBU.exe' -DSApplet -AppModeMech
Hi there,
I am trying to automate a series of steady state thermal simulations with a same geometry and different heat flux boundary conditions imported from a CSV file. I have created a PyMechanical script attached below. My problem is that I couldn't find out how to import the material .xml file and the heat flux data from CSV file. In workbench I was using the Engineering Data and External Data to import these data, but I don't know how to do it in PyAnsys. The CSV file includes the X,Y,Z coordinates and the heat flux value for each coordinate. Can you please help me add the necessary commands to import these data appropriately.
I have an open Service Request 11421277844 on Ansys Support, but I was directed to GitHub Issues for PyMechanical.
The script is attached below and as a txt file.
Thanks a lot, Amir
example_01_steady_state_thermal_solve.txt