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 objDoc As SolidEdgePart.PartDocument = Nothing
Dim objModel As SolidEdgePart.Model = Nothing
Dim objBody As SolidEdgeGeometry.Body = Nothing
Dim objEdges(1) As Object
Dim objFaces As SolidEdgeGeometry.Faces = Nothing
Dim objFace As SolidEdgeGeometry.Face = Nothing
Dim SEInstallDir As DirectoryInfo
Try
objSEApplication = Marshal.GetActiveObject("SolidEdge.Application")
SEInstallDir = GetTrainingFolder()
' opening the part file
objDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\base.par")
objModel = objDoc.Models.Item(1)
objBody = objModel.Body
objFaces = objBody.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
objFace = objFaces.Item(6)
objDoc.TransformToSynchronousSheetmetal(objFace, 0, objEdges, SolidEdgeConstants.FeaturePropertyConstants.igNone, 0.001, 0.0, 0.001, 0.0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Function GetTrainingFolder() As DirectoryInfo
Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
Dim objInstallFolder As DirectoryInfo = Nothing
Dim objTrainingFolder As DirectoryInfo = Nothing
Try
objInstallData = New SEInstallDataLib.SEInstallData
objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
Catch
Finally
If Not (objInstallData Is Nothing) Then
Marshal.FinalReleaseComObject(objInstallData)
objInstallData = Nothing
End If
End Try
Return objTrainingFolder
End Function
End Class