Imports System.Runtime.InteropServices
Public Class IntersectSurfaces
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 objEdges As SolidEdgeGeometry.Edges = Nothing
Dim objConstructionModel As SolidEdgePart.ConstructionModel = Nothing
Dim objConstructionModel1 As SolidEdgePart.ConstructionModel = Nothing
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 intersectfeat As SolidEdgePart.IntersectSurface = Nothing
Dim trim As SolidEdgePart.TrimSurface = Nothing
Dim odjBodies(0 To 1) As Object
'Dim objapplication As Object
Dim objObject As Object
Dim bHeal, bst As Boolean
Dim dtol As Double
Dim points(0 To 3) As Double
Dim dir(0 To 3) As Double
Dim objType As Type = Nothing
Dim strRetStatusMsg As String
strRetStatusMsg = ""
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 reference to active document
objPartDoc = objApplication.ActiveDocument()
If 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)
objSurfaces(1) = objPartDoc.Constructions.ExtrudedSurfaces.Item(2).Faces(SolidEdgeGeometry.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
intersectfeat = objConstructionModel.IntersectSurfaces.AddByPointOnFace(3, points, 3, dir, 2, objSurfaces, 0, objEdgArr, False, False, 0.0, SolidEdgePart.ExtendSurfaceExtentTypeConstants.igESLinearTangentContinuous)
objEdges = objSurfaces(1).Item(1).Edges
objEdgArr(0) = objEdges(0)
objEdgArr(1) = objEdges(1)
intersectfeat.PutEdgesToExtend(2, objEdgArr)
intersectfeat.PutStitchOption(True)
objapplication = intersectfeat.Application
If objapplication Is Nothing Then
MsgBox("Failed to get Application on ExtendSurface collection.")
End If
objObject = intersectfeat.AttributeSets
If objObject Is Nothing Then
MsgBox("Failed to get Application on ExtendSurface collection.")
End If
objObject = intersectfeat.Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
If objObject Is Nothing Then
MsgBox("Failed to get Application on ExtendSurface collection.")
End If
objObject = intersectfeat.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
If objObject Is Nothing Then
MsgBox("Failed to get Application on ExtendSurface collection.")
End If
objObject = intersectfeat.Parent
If objObject Is Nothing Then
MsgBox("Failed to get Application on ExtendSurface collection.")
End If
bHeal = intersectfeat.GetHealOption()
bst = intersectfeat.GetStitchOption()
dtol = intersectfeat.GetStitchTolerance()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class