


{"id":360031,"date":"2024-04-02T14:04:50","date_gmt":"2024-04-02T14:04:50","guid":{"rendered":"\/forum\/forums\/reply\/360031\/"},"modified":"2024-04-02T14:04:50","modified_gmt":"2024-04-02T14:04:50","slug":"360031","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/360031\/","title":{"rendered":"Reply To: Spaceclaim API &#8211; Select faces at given coordinates"},"content":{"rendered":"<p>&lt;p&gt;Thank you for your answer!&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;However, I am working on more complex structures than the one I described above. I managed to work on the normal vectors of each face, here I attach the code I developed (it may require adjustments, but for now it&#8217;s doing its job)&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;div&gt;&lt;div&gt;numFaces = len(GetRootPart().Bodies[0].Faces) # get number of total faces&lt;\/div&gt;&lt;div&gt;selectedFaces = [] # initialise vector to include required faces&lt;\/div&gt;&lt;br&gt;&lt;div&gt;for i in range(0, numFaces &#8211; 1): # select faces knowing their normal vector&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; if str((GetRootPart().Bodies[0].Faces[i].GetFaceNormal(0,0))) &nbsp;== &#8216;Direction: (0, 0, -1)&#8217;: # choose normal vector. Still don&#8217;t know how GetFaceNormal(0,0) is affecting the code&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedFaces.append(GetRootPart().Bodies[0].Faces[i]) # append face&lt;\/div&gt;&lt;br&gt;&lt;div&gt;print(selectedFaces)&lt;\/div&gt;&lt;br&gt;&lt;div&gt;# Define Named Selection&lt;\/div&gt;&lt;div&gt;primarySelection = FaceSelection.Create(selectedFaces)&lt;\/div&gt;&lt;div&gt;secondarySelection = Selection.Empty()&lt;\/div&gt;&lt;div&gt;result = NamedSelection.Create(primarySelection, secondarySelection)&lt;\/div&gt;&lt;div&gt;# Rename Named Selection&lt;\/div&gt;&lt;div&gt;result = NamedSelection.Rename(&#8220;Group1&#8221;, &#8220;myNamedSelection&#8221;)&lt;\/div&gt;&lt;\/div&gt;<\/p>\n","protected":false},"template":"","class_list":["post-360031","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/360031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/360031\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=360031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}