Showing results for 
Search instead for 
Did you mean: 

Collection of all faces of a part




I want to get the collection of all the faces a part with a Visual Basic code but I don't know how I can find it?

Thank you for advance to help me.


Re: Collection of all faces of a part

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Sample code to demonstrate the usage of "Faces" collection is available at below location. 


To access the main page of ST8 programming help click here.





Re: Collection of all faces of a part

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Good example.

It shows accessing faces for  a feature.

To access all faces of a part, the change would be:


oApp = Marshal.GetActiveObject("SolidEdge.Application")
oDoc = oApp.ActiveDocument
oModel = oDoc.Models.Item(1)
oBody = oModel.Body
Dim oFaces As SolidEdgeGeometry.Faces = oBody.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)




Re: Collection of all faces of a part


Thank you very for your reply but I have found myself a solution to find the faces with the code below :

Imports System.Runtime.InteropServices
Imports System.Math

Public Class Form1

    Dim objType As Type
    Dim objApp As SolidEdgeFramework.Application = Nothing
    Dim objDocuments As SolidEdgeFramework.Documents = Nothing
    Dim objPart As SolidEdgePart.PartDocument = Nothing

    Dim objModels As SolidEdgePart.Models = Nothing

    Dim objModel As SolidEdgePart.Model = Nothing

    Dim objFaces As SolidEdgeGeometry.Faces = Nothing
    Dim objFace As SolidEdgeGeometry.Face = Nothing

    Dim objBody As SolidEdgeGeometry.Body

    Dim objShells As SolidEdgeGeometry.Shells
    Dim objShell As SolidEdgeGeometry.Shell

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            objType = Type.GetTypeFromProgID("SolidEdge.Application")
            objApp = Activator.CreateInstance(objType)
            objApp.Visible = True

            objDocuments = objApp.Documents

            objPart = objDocuments.Open("C:/Test/Cube.par")
            objModels = objPart.Models

            For Each Me.objModel In objModels
                If objModel.Name = "Design Model" Then
                    objBody = objModel.Body
                    objShells = objBody.Shells

                    For Each Me.objShell In objShells
                        objFaces = objShell.Faces
                        For Each Me.objFace In objFaces
                            TextBox1.Text = TextBox1.Text & vbCrLf & objFace.ID.ToString()
                        TextBox1.Text = TextBox1.Text & vbCrLf
                End If

        Catch ex As Exception
            If Not (objApp Is Nothing) Then
                objApp = Nothing
            End If
        End Try
    End Sub

End Class

Now I have the faces, I need to copy them in a new part file but I have not found a copy function to do that. Do you have an idea to do this?