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 objPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objModels As SolidEdgePart.Models = Nothing
Dim objModel As SolidEdgePart.Model = Nothing
Dim i As Integer
Dim objConstructions As SolidEdgePart.Constructions = Nothing
Dim objBody As SolidEdgeGeometry.Body = Nothing
Dim objFaces As SolidEdgeGeometry.Faces = Nothing
Dim objFace() As SolidEdgeGeometry.Face = Nothing
ReDim objFace(1)
Dim SEInstallDir As DirectoryInfo
Dim objCopySurfaces As SolidEdgePart.CopySurfaces = Nothing
Dim objCopySurface As SolidEdgePart.CopySurface = Nothing
Try
objSEApplication = Marshal.GetActiveObject("SolidEdge.Application")
SEInstallDir = GetTrainingFolder()
objPartDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\anchor.par")
objModels = objPartDoc.Models
For i = 1 To objModels.Count
objModel = objModels.Item(i)
objBody = objModel.Body
objFaces = objBody.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryPlane)
objFace(0) = objFaces.Item(1)
objConstructions = objPartDoc.Constructions
objCopySurfaces = objConstructions.CopySurfaces
objCopySurface = objCopySurfaces.Add(1, objFace)
Next
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