# Macro request

**URL:** <https://forum.cadmunity.com/t/macro-request/3241>\
**Category:** Macro Library\
**Created:** [September 14, 2024, 12:16pm UTC](https://forum.cadmunity.com/t/macro-request/3241 "2024-09-14T12:16:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BarryH](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@BarryH](https://forum.cadmunity.com/u/BarryH)\
**Post date:** [September 14, 2024, 12:16pm UTC](https://forum.cadmunity.com/t/macro-request/3241/1 "2024-09-14T12:16:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gupta9665](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/gupta9665/32/6304_2.png) [@gupta9665](https://forum.cadmunity.com/u/gupta9665)\
**Post date:** [September 14, 2024, 5:12pm UTC](https://forum.cadmunity.com/t/macro-request/3241/2 "2024-09-14T17:12:34Z")

</div>

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 Long
> 
> Sub 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  
> Next
> 
> Set swFeat = swModel.FeatureManager.InsertMoveFace(0, False, 0, 0.0005)
> 
> End If
> 
> swModel.ClearSelection2 True
> 
> End Sub

---

<div class="post-metadata">

**Author:** ![BarryH](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@BarryH](https://forum.cadmunity.com/u/BarryH)\
**Post date:** [September 15, 2024, 7:22am UTC](https://forum.cadmunity.com/t/macro-request/3241/3 "2024-09-15T07:22:06Z")

</div>

Thank you Deepak, that works perfectly.
