Using ACT, how can I select a body named selection and apply a material assignment to this named selection ?
The following code can be used. Please note the body named selection and the material must already be defined previous to using this code.
ExtAPI.SelectionManager.ClearSelection() ns = ExtAPI.DataModel.GetObjectsByName("MyBodyNamedSelection") ma = ExtAPI.DataModel.Project.Model.Materials.AddMaterialAssignment() ma.Material = "MyMaterial" ma.Location = ns[0]
Hey @Pernelle Marone-Hitz
Please I have a question
This is a recording in Ansys Mechanical script for material assignment (similar to what you have)
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) selection.Ids = [4] material_assignment_37.Location = selection
with Transaction(True): material_assignment_37.Material = "732b2fff-a359-4770-aaa8-e6a1c0aadfa9"
My question are:
What is "732b2fff-a359-4770-aaa8-e6a1c0aadfa9". It seems like a material identifier, but it keeps changing each time I run a new instant of mechanical.
How do I find it in each new mechanical instance? (I understand this identifier appears in the ds.dat file but at the start of the project, the ds.dat file is unavailable so I can't get it.)
Thank you in advance
Hi @CollinsJnr , the number you are getting is some reference to the material internal ids. As you have experienced, it is not robust to use it. Just use the name of the material, it should work and be robust.