how to loading engineering Data source and selecting materials using scripting
How do I select materials that are not in my favourites?
I notice that even after putting materials in my favourite folder once I run a new instance of mechanical using Pymechanical it doesn't show up there.
I have found this code below from @Ayush Kumar
Unfortunately, when I try it, it just refreshes the material but does not add any new material
cmd = """
library1 = EngData.OpenLibrary(
Name="Composite Materials",
Source="Composite_Materials.xml")
system1 = GetSystem(Name="SYS")
engineeringData1 = system1.GetContainer(ComponentName="Engineering Data")
matl1 = engineeringData1.ImportMaterial(
Name="E-Glass",
Source="Composite_Materials.xml")
"""
ExtAPI.Application.ScriptByName('journaling').ExecuteCommand(cmd)
ExtAPI.DataModel.Project.Model.RefreshMaterials()
Comments
-
@Collins I tested today with 2024R1 and it seems work perfectly fine. Which version are you testing with?
1 -
Thank you
2024R1toocmd = """
library1 = EngData.OpenLibrary(
Name="Composite Materials",
Source="Composite_Materials.xml")
system1 = GetSystem(Name="SYS")
engineeringData1 = system1.GetContainer(ComponentName="Engineering Data")
matl1 = engineeringData1.ImportMaterial(
Name="E-Glass",
Source="Composite_Materials.xml")
"""ExtAPI.Application.ScriptByName('journaling').ExecuteCommand(cmd)
ExtAPI.DataModel.Project.Model.RefreshMaterials()I am running the code the way it is above no changes, Am I supposed to change the "SYS" in the
line : system1 = GetSystem(Name="SYS") to my system name?Or am I suppose to change anything in this code, I presume I want E-Glass as a way of testing if the code works but I don't get anything in my material list after running the code.
0 -
@Collins, this code gets executed on the WB level so, you need to check which system you making changes to. If you have multiple analysis systems on the WB project then you need to make sure you are using the correct name.
1 -
0
-
1