Reply

Collection of all faces of a part

Hello,

 

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.

3 REPLIES

Re: Collection of all faces of a part

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

 

https://docs.plm.automation.siemens.com/docs/se/108/api/SolidEdgeGeometry~Faces.html 

 

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

 

Regards,

Kaustubh

 

Re: Collection of all faces of a part

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)

~Tushar

www.SurfAndCode.in

 

 

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
        Try
            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()
                        Next
                        TextBox1.Text = TextBox1.Text & vbCrLf
                    Next
                End If
            Next


        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            If Not (objApp Is Nothing) Then
                Marshal.ReleaseComObject(objApp)
                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?