Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objBProfile As SolidEdgePart.Profile
Dim objBPArray(1 To 2) As SolidEdgePart.Profile
Dim objModel As SolidEdgePart.Model
Dim objECProfile As SolidEdgePart.Profile
Dim objExtCutout As SolidEdgePart.ExtrudedCutout
Dim objRP As SolidEdgePart.RefPlane
Dim objEPProfile As SolidEdgePart.Profile
Dim objExtProt As SolidEdgePart.ExtrudedProtrusion
Dim objThinWall As SolidEdgePart.Thinwall
Dim lngStatus As Long
' Report errors
Const PI = 3.14159265358979
' 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
' *** Create an extruded protrusion as the base feature
' Create the profile for the base feature & validate it
Set objBProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(2))
Call objBProfile.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.05)
lngStatus = objBProfile.End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox "Profile for the base feature is not closed"
End If
' Create the extruded protrusion feature and validate it
Set objBPArray(1) = objBProfile
Set objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, ProfileArray:=objBPArray, _
ProfilePlaneSide:=igSymmetric, ExtrusionDistance:=0.1)
If (objModel.ExtrudedProtrusions(1).Status <> igFeatureOK) Then
MsgBox "AddFiniteExtrudedProtrusions method of the Models object fails"
End If
objBProfile.Visible = False
' *** Create an extruded cutout feature on the base feature
' Create the profile for the extruded cutout feature and validate it
Set objECProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(2))
Call objECProfile.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.025)
lngStatus = objECProfile.End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox "Profile for the extruded cutout feature is not closed"
End If
' Create the extruded protrusion feature and validate it
Set objExtCutout = objModel.ExtrudedCutouts.AddFinite(Profile:=objECProfile, ProfileSide:=igLeft, _
ProfilePlaneSide:=igRight, Depth:=0.5)
If (objExtCutout.Status <> igFeatureOK) Then
MsgBox "AddFinite method of the ExtrudedCutouts object fails"
End If
objECProfile.Visible = False
' *** Create an extruded protrusion feature on the base feature
' Create the profile for the extruded protrusion feature and validate it
Set objRP = objDoc.RefPlanes.AddParallelByDistance(ParentPlane:=objDoc.RefPlanes(2), Distance:=0.05, NormalSide:=igLeft)
Set objEPProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objRP)
Call objEPProfile.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.035)
lngStatus = objEPProfile.End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox "Profile for the extruded protrusion feature is not closed"
End If
' Create the extruded protrusion feature and validate it
Set objExtProt = objModel.ExtrudedProtrusions.AddFinite(Profile:=objEPProfile, ProfileSide:=igLeft, _
ProfilePlaneSide:=igLeft, Depth:=0.05)
If (objExtProt.Status <> igFeatureOK) Then
MsgBox "AddFinite method of the ExtrudedProtrusions object fails"
End If
objEPProfile.Visible = False
' *** Create a thin wall feature on the model
Set objThinWall = objModel.Thinwalls.Add(ThicknessSide:=igInside, CommonThickness:=0.005)
If (objThinWall.Status <> igFeatureOK) Then
MsgBox "Add method of thinwall object fails"
End If
' *** Reorder the thin wall feature to place it above the extruded protrusion feature
Call objThinWall.Reorder(TargetFeature:=objExtCutout, InsertBefore:=False)
' USER DISPLAY
If Not (objDoc.Models(1).Features.Item(3) Is objThinWall) Then
MsgBox "Reorder method of the ThinWall object fails"
End If
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objBProfile = Nothing
Set objBPArray(1) = Nothing
Set objModel = Nothing
Set objECProfile = Nothing
Set objExtCutout = Nothing
Set objRP = Nothing
Set objEPProfile = Nothing
Set objExtProt = Nothing
Set objThinWall = Nothing
End Sub