Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objSEApplication As SolidEdgeFramework.Application = Nothing
Dim objProfileSets As SolidEdgePart.ProfileSet = Nothing
Dim objDoc As SolidEdgePart.PartDocument = Nothing
Dim objFlatPatternModels As SolidEdgePart.FlatPatternModels = Nothing
Dim objFlatPatternModel As SolidEdgePart.FlatPatternModel = Nothing
Dim objFlatPattern As SolidEdgePart.FlatPattern = Nothing
Dim objModels As SolidEdgePart.Models = Nothing
Dim objModel As SolidEdgePart.Model = Nothing
Dim objBlankSurfaces As SolidEdgePart.BlankSurfaces = Nothing
Dim objBlankSurface As SolidEdgePart.BlankSurface = Nothing
Dim FacesToFlatten(0 To 5) As Object
Dim FacesToSet(0 To 5) As Object
Dim FacesFromFlat(0 To 5) As Object
Dim objBox As SolidEdgePart.BoxFeature = Nothing
Dim objBoxes As SolidEdgePart.BoxFeatures = Nothing
Dim objBaseModel As SolidEdgePart.Model = Nothing
Dim objMatTable As SolidEdgeFramework.MatTable = Nothing
Dim strLibrary As String = "Materials"
Dim strMaterial As String = "Copper"
Try
' Get a handle of Solid Edge...
objSEApplication = Marshal.GetActiveObject("SolidEdge.Application")
'Add part document
objDoc = objSEApplication.Documents.Add("SolidEdge.PartDocument")
' Get material table object handle
objMatTable = objSEApplication.GetMaterialTable()
' Set active document handle
objMatTable.SetActiveDocument(objDoc)
objMatTable.ApplyMaterialToDoc(objDoc, strMaterial, strLibrary)
'Change Modeling mode to Synchronous
objDoc.ModelingMode = SolidEdgePart.ModelingModeConstants.seModelingModeSynchronous
objModels = objDoc.Models
'Create a box
objBaseModel = objModels.AddBoxByCenter(0.0, 0.0, 0.0, 0.01, 0.01, 0.0, 0.01, objDoc.RefPlanes.Item(3), SolidEdgePart.FeaturePropertyConstants.igLeft, False, Nothing, 0)
objBlankSurfaces = objBaseModel.BlankSurfaces
objBoxes = objBaseModel.BoxFeatures()
objBox = objBaseModel.Features.Item(1)
' Define faces to flatten - from the box feature in this case
FacesToFlatten(0) = objBox.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryPlane).Item(1)
FacesToFlatten(1) = objBox.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryPlane).Item(2)
FacesToFlatten(2) = objBox.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryPlane).Item(3)
objBlankSurface = objBlankSurfaces.Add(nNumFaces:=3, _
FaceArray:=FacesToFlatten, _
DrawDirectionX:=0.0#, _
DrawDirectionY:=1.0#, _
DrawDirectionZ:=0.0#, _
HardeningCoefficient:=0.2, _
StrengthCoefficient:=550000000, _
AccuracyFactor:=3, _
RemoveLoops:=False)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class