Hello,
I am attempting to use a macro to control the hole wizard feature properties. I am able to control the sketches related to the hole wizard, but I am needing to update the hole call-out. In example, if I want to change an ANSI INCH 3/4-16 thread to an ANSI METRIC M16x1.5. How can I use the API to connect to the feature and update the properties.
I am trying to use the ChangeStandard method with SldWorks.WizardHoleFeatureData2. I am using template drawings, and I need to update the existing feature to avoid breaking references on the drawings, so creating a new feature is not really on the table.
I get a "True" for the update, but it is not actually changing the feature data.
Here is my current code:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swComponent As SldWorks.Component2
Dim longstatus As Long
Dim longwarnings As Long
Dim boolstatus As Boolean
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeatMgr As SldWorks.FeatureManager
Dim swFeat As SldWorks.Feature
Dim swWizHole As SldWorks.WizardHoleFeatureData2
Dim iCurrentType As Integer
Dim HoleType As Long
Dim StandardIndex As Long
Dim FastenerTypeIndex As Long
Dim SSize As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Set swFeatMgr = swModel.FeatureManager
Set swSelMgr = swModel.SelectionManager
boolstatus = swModelDocExt.SelectByID2("XA6", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
Set swWizHole = swFeat.GetDefinition
iCurrentType = swWizHole.Type
Debug.Print iCurrentType
boolstatus = swWizHole.ChangeStandard(0, 26, "1/2-20")
Debug.Print boolstatus
swModel.ForceRebuild3 False
swModel.ClearSelection2 True
End Sub
SolidworksApi/macros