Private Sub Form_Load()
Dim objApp As SolidEdgeFrameWork.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objProfile As SolidEdgePart.Profile
Dim objProfileset As SolidEdgePart.ProfileSet
Dim objEdges As Object
Dim objEdge As Object
Dim objGeom2d As Object
Dim objPrjGeom2d As Object
Dim objProfile1 As SolidEdgePart.Profile
Dim objFaces As Object
Dim objFace As Object
Dim objPrjSilGeom2d() As Object
Dim objSilGeom2d As Object
Dim objExtrudedProtrusion As SolidEdgePart.ExtrudedProtrusion
Dim objLine1 As SolidEdgeFrameworkSupport.Line2d
Dim objLine2 As SolidEdgeFrameworkSupport.Line2d
Dim objProfileset1 As SolidEdgePart.ProfileSet
' Local variables to be declared here
Const TESTFILE = "T:\vbtests\testcases\Cylinder.par"
Dim lngCount2d As Long
Dim ii As Integer
' Create/get the application with specific settings
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
On Error GoTo 0
'Close the existing Document
Call objDoc.Close(Savechanges:=False)
'Open the test case
Set objDoc = objApp.Documents.Open(Filename:=TESTFILE)
'Get the Edges collection of the ExtrudedProtrusion1
Set objEdges = objDoc.Models(1).ExtrudedProtrusions(1).Edges(igQueryAll)
'Get the circular edge
Set objEdge = objEdges(1)
'Get the ProfileSet
Set objProfileset = objDoc.ProfileSets.Add
'Add a Profile
Set objProfile = objProfileset.Profiles.Add(objDoc.RefPlanes(1))
'Project the Circular Edge onto the Profile to get the 2d Geometry object
Set objPrjGeom2d = objProfile.ProjectEdge(objEdge)
Call objProfile.IncludeEdge(objPrjGeom2d, objGeom2d)
Call objDoc.Models(1).ExtrudedProtrusions.AddFinite(objProfile, igLeft, igLeft, 0.025)
objProfile.Visible = False
'IncludeEdge also accepts SilhoutteEdges as shown below
'Get the Faces collection of the ExtrudedProtrusion2
Set objFaces = objDoc.Models(1).ExtrudedProtrusions(2).Faces(igQueryAll)
'Get the Cylindrical Face
Set objFace = objFaces(1)
'Get the ProfileSet
Set objProfileset1 = objDoc.ProfileSets.Add
' Add a new Profile
Set objProfile1 = objProfileset1.Profiles.Add(objDoc.RefPlanes(3))
'Project the Face to get silhoutte edges
Call objProfile1.ProjectSilhoutteEdges(objFace, lngCount2d, objPrjSilGeom2d)
Call objProfile1.IncludeEdge(objPrjSilGeom2d(1), objSilGeom2d)
Set objLine1 = objProfile1.Lines2d.AddBy2Points(0, -0.025, 0.05, 0.05)
Set objLine2 = objProfile1.Lines2d.AddBy2Points(0.05, 0.05, 0, 0.1)
Call objProfile1.Relations2d.AddKeypoint(objLine1, igLineEnd, objLine2, igLineStart)
Call objProfile1.Relations2d.AddKeypoint(objLine2, igLineEnd, objSilGeom2d, igLineStart)
Call objProfile1.Relations2d.AddKeypoint(objSilGeom2d, igLineEnd, objLine1, igLineStart)
ii = objProfile1.End(igProfileClosed)
Set objExtrudedProtrusion = objDoc.Models(1).ExtrudedProtrusions.AddFinite(objProfile1, igRight, igRight, 0.2)
objProfile1.Visible = False
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objProfileset = Nothing
Set objProfile = Nothing
Set objEdges = Nothing
Set objEdge = Nothing
Set objPrjGeom2d = Nothing
Set objGeom2d = Nothing
Set objProfile1 = Nothing
Set objSilGeom2d = Nothing
Dim i As Integer
For i = 0 To UBound(objPrjSilGeom2d)
Set objPrjSilGeom2d(i) = Nothing
Next
Set objExtrudedProtrusion = Nothing
End Sub