How to select a face by the point location (x,y,z), and choose tne entities with the same location?
How to select a face by the point location (x,y,z),for example(0,1,0.1), and choose all tne entities with the same X location in Mechanical scripting? Just like the fig below:
Then set all the entities chosen to a name selection, just like the fig below:
The second question: how to choose a face by point location,and then choose the location X, create a name selection "X-sym",just like below:
Answers
-
Check out this post:
https://discuss.ansys.com/discussion/1857It will tell you how to get the faces in the model. Once you have them you can use the Face.Centroid property and see where the XYZ location of that centroid is. You can use any python filtering/tolerance scheme you want to then keep the faces with a centroid in the location bounds you desire.
Something like this:
selection_manager = ExtAPI.SelectionManager
SelInfo = selection_manager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
X_Bounds = [-0.01,0.01]
AllFaces = []
for Assembly in ExtAPI.DataModel.GeoData.Assemblies:
for Part in Assembly.AllParts:
for Body in Part.Bodies:
for Face in Body.Faces:
AllFaces.append(Face)
MyFaces = filter(lambda F: F.Centroid[0]>X_Bounds[0] and F.Centroid[0]<X_Bounds[1], AllFaces)
SelInfo.Entities=MyFaces
selection_manager.NewSelection(SelInfo)0