Imports System.Runtime.InteropServices
Public Class TrimSurface
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objConstructionModel As SolidEdgePart.ConstructionModel
Dim objConstructionModel1 As SolidEdgePart.ConstructionModel
Dim objEdgArr(0 To 1) As Object
Dim objSurfaces(1) As Object
Dim objSurfaces1(1) As Object
Dim kptypeArr(0 To 2) As Object
Dim PositionArray(8) As Double
Dim pointtypeArr(0 To 2) As SolidEdgeConstants.PointTypeConstants
Dim pointonface(0 To 2) As Double
Dim trim As SolidEdgePart.TrimSurface
Dim odjBodies(0 To 1) As Object
Dim points(0 To 3) As Double
Dim dir(0 To 3) As Double
Dim objType As Type = Nothing
Try
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
If objApplication Is Nothing Then
' Get the type from the Solid Edge ProgID
objType = Type.GetTypeFromProgID("SolidEdge.Application")
' Start Solid Edge
objApplication = Activator.CreateInstance(objType)
' Make Solid Edge visible
objApplication.Visible = True
End If
' Get the active document.
objPartDoc = objApplication.ActiveDocument()
If Err().Number <> 0 Or objPartDoc Is Nothing Then
MsgBox("Could not open document ")
End If
'obtain the first model and get all its edges
objSurfaces(0) = objPartDoc.Constructions.ExtrudedSurfaces.Item(1).Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
objSurfaces1(0) = objPartDoc.Constructions.ExtrudedSurfaces.Item(2).Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
'objSurfaces(1) = objPartDoc.Constructions.ExtrudedSurfaces.Item(2).Faces(SolidEdge.Geometry.FeatureTopologyQueryTypeConstants.igQueryAll)
objConstructionModel = objPartDoc.Constructions.ExtrudedSurfaces(1).Parent
objConstructionModel1 = objPartDoc.Constructions.ExtrudedSurfaces(0).Parent
odjBodies(0) = objConstructionModel.Body
odjBodies(1) = objConstructionModel1.Body
points(0) = -0.03
points(1) = 0.06
points(2) = -0.03
dir(0) = 0
dir(1) = 0
dir(2) = 1
trim = objConstructionModel.TrimSurfaces.AddByPointOnFace(3, points, 3, dir, 1, objSurfaces, 1, objSurfaces1)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class