Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objConstructions As SolidEdgePart.Constructions = Nothing
Dim objBdrySurfaces As SolidEdgePart.SurfaceByBoundaries = Nothing
Dim objBdrySurface As SolidEdgePart.SurfaceByBoundary = Nothing
Dim objProfileSet As SolidEdgePart.ProfileSet = Nothing
Dim objProfile As SolidEdgePart.Profile = Nothing
Dim sketch As SolidEdgePart.Sketch = Nothing
Dim arrInEdges(4) As Object
Dim arrEdge(0) As Object
Dim objConsModel As SolidEdgePart.ConstructionModel = Nothing
Dim objTrimSurfaces As SolidEdgePart.TrimSurfaces = Nothing
Dim objTrimSurface As SolidEdgePart.TrimSurface = Nothing
Try
' Create/get the application with specific settings
objApp = Marshal.GetActiveObject("SolidEdge.Application")
If objApp Is Nothing Then
MessageBox.Show("Could not get application.")
End If
' Get the active document which contains 2 sketechs. One with rectangle and other with circle in the middle of rectangle
objPartDoc = objApp.ActiveDocument
If objPartDoc Is Nothing Then
MessageBox.Show("Could not open document ")
End If
' Get the constructions collection
objConstructions = objPartDoc.Constructions
objBdrySurfaces = objConstructions.SurfaceByBoundaries
If objBdrySurfaces Is Nothing Then
MessageBox.Show("Could not get SurfaceByBoundary collection.")
End If
' Input edges
sketch = objPartDoc.Sketches.Item(1)
objProfile = sketch.Profile
' Get input edges to create bounded surface
arrInEdges(0) = objProfile.CurveBody.Curves.Item(1)
arrInEdges(1) = objProfile.CurveBody.Curves.Item(2)
arrInEdges(2) = objProfile.CurveBody.Curves.Item(3)
arrInEdges(3) = objProfile.CurveBody.Curves.Item(4)
' Input edges
sketch = objPartDoc.Sketches.Item(2)
objProfile = sketch.Profile
arrEdge(0) = objProfile.CurveBody.Curves.Item(1)
objBdrySurface = objBdrySurfaces.Add(4, arrInEdges)
Dim objProjCurve As SolidEdgePart.ProjectCurve = Nothing
objConsModel = objConstructions.Item(1)
objTrimSurfaces = objConsModel.TrimSurfaces
objTrimSurface = objTrimSurfaces.Add(1, arrEdge, SolidEdgePart.TrimSurfaceAreaSideConstants.igTSLeft)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class