Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objFolder As DirectoryInfo
Dim objFileInfo As FileInfo
Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim objModel as solidedgepart.Model = Nothing
Dim LabelWelds As SolidEdgePart.PartLabelWelds = Nothing
Dim LabelWeld As SolidEdgePart.PartLabelWeld = Nothing
Dim LabelWeldDC As SolidEdgePart.LabelWeldDataCollection
Dim LabelWeldObject As SolidEdgePart.LabelWeldData
Dim iNumEdges As Integer
Dim objEdgesArray(0) As SolidEdgeGeometry.Edge
Dim objExtProt1 As SolidEdgePart.ExtrudedProtrusion = Nothing
Dim ObjEdges As SolidEdgeGeometry.Edges = Nothing
Dim objFaces As SolidEdgeGeometry.Faces = Nothing
Dim objFace As SolidEdgeGeometry.Face = Nothing
Try
objFolder = GetTrainingFolder()
objFileInfo = New FileInfo(Path.Combine(objFolder.FullName, "Pin1.par"))
objApp = Marshal.GetActiveObject("SolidEdge.Application")
objDocuments = objApp.Documents
' First open the test case document from training folder
objPartDoc = objDocuments.Open(objFileInfo.FullName)
' Get model handle
objModel = objPartDoc.Models.Item(1)
'Get Label Weld Data object
LabelWeldDC = objPartDoc.LabelWeldDataCollection
LabelWeldObject = LabelWeldDC.Add(ZSymbol:=0, Tail:=0, DashLine:=0, WeldInField:=0, OffsetTopBottom:=0, WeldAllAround:=0, Symmetrical:=0, TopNote1:="Test1", TopNote2:="Test2", TopTreatmentType:=0, TopType:=0, TopNote3:="Test3", TopNoteZ:="", TailNote:="", BottomNote1:="", BottomNote2:="", BottomTreatmentType:=0, BottomType:=0, BottomNote3:="", BottomNoteZ:="", TopTypeCompound:=0, BottomTypeCompound:=0, CenterType:=0, CrossSectionArea:=0, TailNote2:="", TopNoteCSize:="", BottomNoteCSize:="", TopNoteAngle:="", BottomNoteAngle:="", TopNoteDepth:="", BottomNoteDepth:="", TopPosOffset:=0, BottomPosOffset:=0)
' Get model handle
objModel = objPartDoc.Models.Item(1)
'Get Label weld collection
LabelWelds = objModel.PartLabelWelds
' Get Protrusion 1
objExtProt1 = objModel.ExtrudedProtrusions.Item(1)
' Get all base faces collection
objFaces = objExtProt1.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
' Collect INPUT Base faces
objFace = objFaces.Item(1)
objFace.Style = objPartDoc.FaceStyles("Yellow")
' Base edges collection
ObjEdges = objFace.Edges()
' Collect INPUT Base faces
objEdgesArray(0) = ObjEdges.Item(3)
' Number od edges
iNumEdges = 1
' Add a new Label weld
LabelWeld = LabelWelds.Add(iNumEdges,
objEdgesArray,
LabelWeldObject)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
LabelWeldObject = Nothing
LabelWeldDC = Nothing
LabelWeld = Nothing
LabelWelds = Nothing
objPartDoc.Close()
objPartDoc = Nothing
objApp = Nothing
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