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 FilletWelds As SolidEdgePart.PartFilletWelds = Nothing
Dim FilletWeld As SolidEdgePart.PartFilletWeld = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim iNumBaseFaces As Integer
Dim iNumTargetFaces As Integer
Dim dBaseThickness As Double
Dim dTargetThickness As Double
Dim eSetbackType As SolidEdgePart.FilletWeldSetbackConstants
Dim objBaseFaces(0) As SolidEdgeGeometry.Face
Dim objTargetFaces(0) As SolidEdgeGeometry.Face
Dim objFaceArray(0) As SolidEdgeGeometry.Face
Dim objExtProt1 As SolidEdgePart.ExtrudedProtrusion = Nothing
Dim objExtProt2 As SolidEdgePart.ExtrudedProtrusion = Nothing
Dim objFaces As SolidEdgeGeometry.Faces = Nothing
Dim objFace As SolidEdgeGeometry.Face = Nothing
Dim objModel As SolidEdgePart.Model ' Object type will woork for both Flat model and Design model
Dim LabelWeldDC As SolidEdgePart.LabelWeldDataCollection
Dim LabelWeldObject As SolidEdgePart.LabelWeldData
Try
objFolder = GetTrainingFolder()
objFileInfo = New FileInfo(Path.Combine(objFolder.FullName, "Pin1.par"))
objApp = Marshal.GetActiveObject("SolidEdge.Application")
'objApp = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
objApp.Visible = True
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 Fillet weld collection
FilletWelds = objModel.PartFilletWelds
' Get Protrusion 1
objExtProt1 = objModel.ExtrudedProtrusions.Item(1)
' Get all base faces collection
objFaces = objExtProt1.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
' Collect INPUT Base faces
objBaseFaces(0) = objFaces.Item(1)
'Get protrusion 2
objExtProt2 = objModel.ExtrudedProtrusions.Item(2)
' Get all target faces collection
objFaces = objExtProt2.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
' Collect INPUT Target faces
objTargetFaces(0) = objFaces.Item(7)
'Apply face styles to selected faces for identification
objBaseFaces(0).Style = objPartDoc.FaceStyles("red")
objTargetFaces(0).Style = objPartDoc.FaceStyles("red")
' Initialize all inputs
iNumBaseFaces = 1
iNumTargetFaces = 1
eSetbackType = SolidEdgePart.FilletWeldSetbackConstants.seFilletWeldThickness
dBaseThickness = 0.00235
dTargetThickness = 0.0025
' Add a new Fillet weld
FilletWeld = FilletWelds.Add(iNumBaseFaces,
objTargetFaces,
iNumTargetFaces,
objBaseFaces,
LabelWeldObject,
eSetbackType,
dBaseThickness,
dTargetThickness)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
If Not objPartDoc Is Nothing Then
LabelWeldObject = Nothing
LabelWeldDC = Nothing
FilletWeld = Nothing
FilletWelds = Nothing
objPartDoc.Close()
objPartDoc = Nothing
End If
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