Allows access to library forming tool feature data.
'VBA
'This example demonstrates how to insert a design library forming tool into a sheet metal part and reposition and replace it with another forming tool.
'----------------------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\sheetmetal\formtools\cover.sldprt.
' 2. Ensure that the two specified formtoolpath locations exist.
' 3. Ensure that the Sheet Metal tab is visible on the CommandManager toolbar.
' 4. Run macro.
' 5. At the pause, inspect the FeatureManager design tree and the graphics area for the drafted rectangular emboss forming tool.
' Then select a flat face where to re-position (and replace) the forming tool.
' 6. Press F5 finish.
'
' Postconditions:
' 1. A dimple emboss replaces the drafted rectangular emboss.
' 2. Inspect the FeatureManager design tree, graphics area, and the Immediate window.
'
' NOTE: Do not save the part as it may be used elsewhere.
' ---------------------------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim featMgr As FeatureManager
Dim boolstatus As Boolean
Option Explicit
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Select a flat face where to insert an emboss forming tool
boolstatus = swModel.Extension.SelectByRay(5.53557395141979E-02, 3.03381093343091E-02, 2.66948404126879E-02, -0.707061513640545, -0.415946801562901, -0.57188484347632, 5.32844353755021E-04, 2, False, 0, 0)
Set featMgr = swModel.FeatureManager
Dim LibFormToolFeatureData As LibraryFormToolFeatureData
Set LibFormToolFeatureData = featMgr.CreateDefinition(swFmFormToolInstance)
LibFormToolFeatureData.LinkToFormTool = True
LibFormToolFeatureData.FormToolPath = "install_dir\data\Design Library\forming tools\embosses\drafted rectangular emboss.sldftp"
Call LibFormToolFeatureData.OverrideDocumentSettings(True, True, True, True)
LibFormToolFeatureData.RotationAngle = 0.5
Dim swFeat As Feature
Set swFeat = featMgr.CreateFeature(LibFormToolFeatureData)
Stop ' Inspect the graphics area and FeatureManager design tree; select a flat face where to re-position (and replace) the forming tool
Dim selMgr As SelectionMgr
Set selMgr = swModel.SelectionManager
Dim face2 As face2
Set face2 = selMgr.GetSelectedObject6(1, -1)
Dim pickPt As Variant
pickPt = selMgr.GetSelectionPoint2(1, -1)
Dim MU As MathUtility
Set MU = swApp.GetMathUtility()
Dim mathPt As MathPoint
Set mathPt = MU.CreatePoint(pickPt)
swModel.ClearSelection2 (True)
Dim swLibFormFeatData1 As LibraryFormToolFeatureData
Set swLibFormFeatData1 = swFeat.GetDefinition()
Debug.Print swLibFormFeatData1.GetPunchID()
Debug.Print swLibFormFeatData1.FormToolConfiguration
Debug.Print swLibFormFeatData1.FormToolPath
Debug.Print swLibFormFeatData1.LinkToFormTool
Debug.Print swLibFormFeatData1.RotationAngle
Debug.Print swLibFormFeatData1.AccessSelections(swModel, Nothing)
Dim face As face2
Set face = swLibFormFeatData1.PlacementFace
swLibFormFeatData1.RotationAngle = 0.7833
Call swLibFormFeatData1.OverrideDocumentSettings(True, True, True, True)
swLibFormFeatData1.FormToolConfiguration = "Default"
swLibFormFeatData1.FormToolPath = "install_dir\data\Design Library\forming tools\embosses\dimple.SLDFTP"
swLibFormFeatData1.LinkToFormTool = True
Dim ent As Entity
Set ent = face
Call ent.Select4(True, Nothing)
Call swLibFormFeatData1.SetPlacementFace(face2, mathPt)
Debug.Print swFeat.ModifyDefinition(swLibFormFeatData1, swModel, Nothing)
Dim face1 As face2
Set face1 = swLibFormFeatData1.PlacementFace
End Sub