Showing results for 
Search instead for 
Did you mean: 

Faster Way to find Face/Edge ?

Valued Contributor
Valued Contributor

Good evening.


Every time I want to stablish a relationship I need to search the Item() property of the Faces/Edges collections until I find the desired Face/Edge, index by index.


It's a slowly, tedious, time consumming process. Is there a better way of getting the desired Face/Edge? I know they have an ID property, but I can't see it through SE screen selecting the part.


It'd be very usefull I we could see the ID property somewhere so we could access it directly in code.


Does anybody know how to discover it?


Thankx !!!


Re: Faster Way to find Face/Edge ?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom



I assume that you are looking for an existing edge/face with some specific characteristics, which identify it. As you did not specify what you are looking for, I can only give some generic suggestions:

(1) If you are looking for a specific geometry type, you may already ask the Faces or Edges property of the body using any of the specific arguments, like igQueryPlane for planar faces only to limit the face collection to only the interesting geometry.

(2) You might also use the Parasolid ID, but this is not persistent and may change between sessions. (I do not recommend this)

(3) The ReferenceKey is a persistent property and can be used to identify easily the same toplogical entity between sessions. Just store the ReferenceKey of your entity and then later call the BindToObject() method on the document to get back your entity.

(4) You can also use the AttachedPropertyTables to identify your geometry in your parts and later get the geometry which has a specific attribute attached. The attributes can be attached through UI and are visible there. Through API, you will then query the objects which have a specific attribte attached. (see the AttachedPropertyTable object and its AttachedTo() method)


I have personally used methods (2) and (3) in the past, but haven't made any performance test on whether it is faster than iterating through the geometry. Especially, I have used method (3) to automatically create a complete assembly from an XML description file where all the associative relations were created by attributed geometry in the part components.

In my XML file I mainly had instructions to create a relation between the face with attribute "F1" from component C1 to the face "F2" in component C2.

Re: Faster Way to find Face/Edge ?

Valued Contributor
Valued Contributor

Hi, Martin!


I'm getting the faces/edges like this: objface4 = faces4.Item(5);


The problem is that whenever I need to find a face or edge, I have to start the application and check if the indexes I provided returned the desired faces. If it doesn't, I have to try another indexes and do all over again, index by index, until I find them.


The suggestions 3 and 4 seem to be the best approach. However, I'll have to spend some time learning these technics.


I think that if SE showed the ID property when we select them on UI, it would ease our lifes I lot.


Thanx for your reply !!!


Re: Faster Way to find Face/Edge ?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

For method (4), you will have to do the following:

1) Open your document, where you are searching your geometry.

2) Create a new property table (Tools > Properties > Tables command)

2.1) Create a new table and add a property. Name and default values are not important, but you should remember the names. In my example, I used "Martin" as table name and "MateFace" as integer property name and set its value to 0.

2.2) Close the dialog

3) Attach the created property to an edge/face (Tools > Properties > Attach command)

3.1) Select the table name, define a property value and select the geometry to which you want to attach the property value.

3.2) Close the dialog

Finally, run the following code to find the face with the given attribute.

' Highlight all topologies which have a specific property value attached
Dim objDoc As SolidEdgePart.PartDocument = objApp.ActiveDocument
Dim objResult As SolidEdgeFramework.SEGenericCollection = objDoc.QueryByProperty(PropertyTableConstants.seCustomPropertyQueryByNameAndValue, _
  "Martin", 1, "MateFace", SolidEdgePart.PropertyTypeConstants.sePropertyTypeInteger, 0)
Dim nObj As Integer = objResult.Count
For Each objTable As SolidEdgePart.AttachedPropertyTable In objResult
  Dim arrAttachments As Array = Array.CreateInstance(GetType(Object), 0)  ' Create an empty Object array
  Dim objHLSet As SolidEdgeFramework.HighlightSet = objDoc.HighlightSets.Add()
  For Each objObj In arrAttachments
  MsgBox("The found geometry is now highlighted. Hit OK to remove highlight.")


Re: Faster Way to find Face/Edge ?

Valued Contributor
Valued Contributor

Thanx Martin. You are great!


I'll implement it and give you a feedback!