How to extract all node ids of a named selection via Mechanical scripting?
Rohith Patchigolla
Member, Moderator, Employee Posts: 218
✭✭✭✭
in Structures
How to extract all node ids of a named selection via scripting, irrespective of whether it has geometric entities (faces for example) or nodes?
Tagged:
0
Comments
-
Here is an example code which takes the name of the named selection (please make sure the name is unique and collects all the node ids into a list.
myNS = ExtAPI.DataModel.GetObjectsByName("test_ns")[0] allNodeIds = [] geomIds = myNS.Location.Ids Mesh = ExtAPI.DataModel.MeshDataByName("Global") if myNS.Location.SelectionType == SelectionTypeEnum.GeometryEntities: for geomId in geomIds: mR = Mesh.MeshRegionById(geomId) nodeIds = mR.NodeIds allNodeIds.extend(nodeIds) else: allNodeIds = myNS.Location.Ids allNodeIds = list(set(allNodeIds)) print(len(allNodeIds))
0