Imports System.IO
Imports System.Runtime.InteropServices
Module Example
<STAThread()> _
Sub Main()
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim objSheetmetalDocument As SolidEdgePart.SheetMetalDocument = Nothing
Dim objModels As SolidEdgePart.Models = Nothing
Dim objModel As SolidEdgePart.Model = Nothing
Dim objFlanges As SolidEdgePart.Flanges = Nothing
Dim objFlange1 As SolidEdgePart.Flange = Nothing
Dim objFlange2 As SolidEdgePart.Flange = Nothing
Dim objFaces As SolidEdgeGeometry.Faces = Nothing
Dim objFace As SolidEdgeGeometry.Face = Nothing
Dim objEdges1 As SolidEdgeGeometry.Edges = Nothing
Dim objEdges2 As SolidEdgeGeometry.Edges = Nothing
Dim objEdge1 As SolidEdgeGeometry.Edge = Nothing
Dim objEdge2 As SolidEdgeGeometry.Edge = Nothing
Dim objCornerEdge As SolidEdgeGeometry.Edge = Nothing
Dim objCloseCorners As SolidEdgePart.CloseCorners = Nothing
Dim objCloseCorner As SolidEdgePart.CloseCorner = Nothing
Dim i As Long
Dim j As Long
Dim bFound As Boolean
Dim dOffsetValue As Double
Dim RefLayer As Long
Try
OleMessageFilter.Register()
' Start Solid Edge
objApplication = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
objApplication.Visible = True
objDocuments = objApplication.Documents
'Any sheet metal document contains more two flanges
objSheetmetalDocument = objDocuments.Open("anyfilename.psm")
objModels = objSheetmetalDocument.Models
objModel = objModels.Item(1)
objFlanges = objModel.Flanges
objFlange1 = objFlanges(1)
objFlange2 = objFlanges(2)
objEdges1 = objFlange1.Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
objEdges2 = objFlange2.Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
bFound = False
For i = 0 To objEdges1.Count
objEdge1 = objEdges1(i + 1)
For j = 0 To objEdges2.Count
objEdge2 = objEdges2(j + 1)
If (objEdge1 Is objEdge2) Then
bFound = True
objCornerEdge = objEdge1
Exit For
End If
Next j
If bFound Then
Exit For
End If
Next i
If bFound <> True Then
Throw New System.Exception("Could not find the appropriate close corner edge.")
End If
'Got it, go ahead to create close corner feature
objCloseCorners = objModel.CloseCorners
If objCloseCorners Is Nothing Then
Throw New System.Exception("Could not get the close corner collect.")
End If
' use the default value to create a simple corner
objCloseCorner = objCloseCorners.Add(objCornerEdge)
'objCloseCorner = objCloseCorners.Add(InputEdge:=objCornerEdge, _
' ClosureType:=SolidEdgePart.CloseCornerFeatureConstants.seCloseCornerCloseFaces, _
' TreatmentType:=SolidEdgePart.CloseCornerFeatureConstants.seCloseCornerTreatmentVCutout, _
' TreatmentDiameter:=0.003#, _
' CornerGap:=0.0#, _
' OverlapRatio:=0.0#, _
' CutAngle:=0.1#, _
' RectWidth:=0.0#, _
' Offset:=0.001#)
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
OleMessageFilter.Revoke()
End Try
End Sub
End Module