Closed pmaroneh closed 1 year ago
workaround:
ids = System.Collections.Generic.List[System.Int32]()
[ids.Add(item) for item in input]
tempSel.Ids = ids
@pmaroneh This might actually already be fixed in the latest commit of pymechanical. Could you try a git pull?
I think I have the latest code (?): .
Your workaround also works fine, thanks.
matAssignment = Model.Materials.AddMaterialAssignment() tempSel = ExtAPI.SelectionManager.CreateSelectionInfo(Ansys.ACT.Interfaces.Common.SelectionTypeEnum.GeometryEntities) bodies = [body for body in ExtAPI.DataModel.Project.Model.Geometry.GetChildren(Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body,True)] geobodies = [body.GetGeoBody() for body in bodies] ids = System.Collections.Generic.List[System.Int32]() [ids.Add(item.Id) for item in geobodies] tempSel.Ids = ids matAssignment.Location = tempSel matAssignment.Material = "Structural Steel"
@pmaroneh are you sure that the version of pymechanical that is installed to your python environment is the latest one? It's not enough to simply pull the git repo to confirm it.
I was now able to get v0.7dev3 and it is indeed fixed there. Many thanks.
π Before submitting the issue
π Description of the bug
The code below works fine in the GUI:
# Assign material matAssignment = Model.Materials.AddMaterialAssignment() tempSel = ExtAPI.SelectionManager.CreateSelectionInfo(Ansys.ACT.Interfaces.Common.SelectionTypeEnum.GeometryEntities) bodies = [body for body in ExtAPI.DataModel.Project.Model.Geometry.GetChildren(Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body,True)] geobodies = [body.GetGeoBody() for body in bodies] tempSel.Ids = [geobody.Id for geobody in geobodies] matAssignment.Location = tempSel matAssignment.Material = "Structural Steel"
But in embedded mode,
tempSel.Ids = [geobody.Id for geobody in geobodies]
does not work and the following error is returned:The current workaround is to use
tempSel.Ids.Add(id)
π Steps to reproduce
See above.
π» Which operating system are you using?
Windows
π Which Python version are you using?
3.7
π¦ Installed packages