Can anybody help with a small macro? I am currently working on a project which involves laser cut plates with holes in, some are hole wizard holes such as dowel holes and threaded holes, others are cut extrudes. We laser cut these holes smaller then drill them out to full size manually. I use the move face command to temporarily make the holes smaller by 0.5mm. ( I do this so that I can get the dxf file for cutting, then I delete or supress it). It would be great If I had a macro which did the following- I pre select the features from the feature tree and hit the macro button, which moves the faces of all the holes by 0.5mm, then closes the move face command.
I have tried recording a macro but cannot get it to work properly.
Thanks
Select the desired features, and run the following codes. Please try on sample files first. Also not much error handling is added.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim selCount As Long
Dim i As LongSub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelectionManager = swModel.SelectionManager
selCount = swSelectionManager.GetSelectedObjectCount2(-1)If Not selCount = 0 Then
For i = 1 To selCount
swModel.SelectionManager.SetSelectedObjectMark i, 1, 0
NextSet swFeat = swModel.FeatureManager.InsertMoveFace(0, False, 0, 0.0005)
End If
swModel.ClearSelection2 True
End Sub
Thank you Deepak, that works perfectly.