How I can get reference Id of surface of a particular body. Please kindly help me with this and don't use current selection.
I assume this is ANSYS Mechanical…
Ids = [F.Id for F in MyBody.Faces]
Thanks Mike, for your comment. I have name selection of bodies and want loop over those bodies for their ids.
Hi
The below example might be what is needed. It assumes one wants 3D solid bodies and then to get their Faces and Ids - if surface bodies are also of interest, then just add to the if: an or condition to get also surface bodies :
model = ExtAPI.DataModel.Project.Model analysis=model.Analyses[0] ns=model.NamedSelections.Children # named selections for n in ns: # loop through ns nId=n.Location.Ids # only bodies in ns so nId is body id also for body in nId: # loop through and find 3D body b=ExtAPI.DataModel.GeoData.GeoEntityById(body) if str(b.BodyType)=="GeoBodySolid": # if Solid Body (no face/sheets) # or str(b.BodyType)=="GeoBodySheet": # if Solid Body and Surface bodies are used faces = b.Faces for face in faces: fid=face.Id print(fid)
Thank you Erik
Thanks Erik
Hi Erik I am getting this error "iteration over non-sequence of type NamedSelection " because of below code I am not able to get the Id of particular nameselection containing bodies.Please Kindly help me with this.
model = ExtAPI.DataModel.Project.Model ns=model.NamedSelections.Children[3] # named selections face1ID = [] for n in ns: # loop through ns nId=n.Location.Ids # only bodies in ns so nId is body id also for body in nId: # loop through and find 3D body b=ExtAPI.DataModel.GeoData.GeoEntityById(body) if str(b.BodyType)=="GeoBodySolid": # if Solid Body (no face/sheets) # or str(b.BodyType)=="GeoBodySheet": # if Solid Body and Surface bodies are used faces = b.Faces for face in faces: fid=face.Id face1ID.append(fid)
print("nameslection ID",face1ID)