mad
1
Hello
No matter how hard I look, I can't find any way to edit just the dimensions of a thread in solidworks
Scenario
Existing part with M10 thread
Objective
Change the M10 to M12 without giving the depth info or anything else so based just as if the user change in the solidworks dialog
I looked at HoleWizard but it's only to create the thread and not to edit it :/
mad
2
I found his
http://help.solidworks.com/2015/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IWizardHoleFeatureData2~ChangeStandard.html
But I don't see how to select my function beforehand :/
Hello
Do you want to edit on a 2D drawing, in 3D?
mad
4
In the part file directly ;)
mad
5
With the help of support, here's the code that works under VB.net
Dim File As String = "C:\Test.SLDPRT"
Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File)
swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)
Dim Part As PartDoc = swApp.ActiveDoc
Dim swModel As SldWorks.ModelDoc2 = swApp.ActiveDoc
Dim featMgr As FeatureManager = Part.FeatureManager
'
Dim swSelMgr As SldWorks.SelectionMgr = swModel.SelectionManager
swModel.Extension.SelectByID2("Threaded Hole", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Dim swFeat As SldWorks.Feature = swSelMgr.GetSelectedObject6(1, -1)
Dim instance As IWizardHoleFeatureData2
Dim Standard As Int32 = 8
Dim FastenerType As Int32 = 147
Dim SSize As String = "M30"
instance = swFeat.GetDefinition
instance. ChangeStandard(Standard, FastenerType, SSize)
swFeat.ModifyDefinition(instance, swModel, Nothing)
'
Part.ForceRebuild() 'Reconstruction
Dim fileerror, filewarning As Integer
Dim boolstatus As Boolean = swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning) 'Saving changes swApp.CloseDoc (File) 'Closing the room
mad
6
With the help of support, here's the code that works under VB.net
Dim File As String = "C:\Test.SLDPRT"Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File) swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)Dim Part As PartDoc = swApp.ActiveDocDim swModel As SldWorks.ModelDoc2 = swApp.ActiveDocDim featMgr As FeatureManager = Part.FeatureManager 'Dim swSelMgr As SldWorks.SelectionMgr = swModel.SelectionManager swModel.Extension.SelectByID2("Threaded Hole", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)Dim swFeat As SldWorks.Feature = swSelMgr.GetSelectedObject6(1, -1)Dim instance As IWizardHoleFeatureData2 Dim Standard As Int32 = 8Dim FastenerType As Int32 = 147 Dim SSize As String = "M30"instance = swFeat.GetDefinition instance. ChangeStandard(Standard, FastenerType, SSize) swFeat.ModifyDefinition(instance, swModel, Nothing) 'Part.ForceRebuild() 'Reconstruction Dim fileerror, filewarning As IntegerDim boolstatus As Boolean = swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning) 'Saving ChangeswApp.CloseDoc( File) 'Closing the room
pl
7
Would it be possible to put the VBA code of the full macro in a txt file as an attachment to a response? Because here, it's a bit illegible...