Selecting outer edge of face

Hi All,

so basically Im trying to create a macro that  changes the selection from the pre-selected (circular) face to its outer edge.

I kinda think it may be done with .getedges but i dont know how to implement it.

does anyone have an example of how this could be done?

thank you

Chris

SolidworksApi macros
Answers 3
AT
AT 2013-08-20 Best Answer

Hi Chris,

Here is the macro:

<p>Dim swApp As SldWorks.SldWorks</p><p>Dim swModel As SldWorks.ModelDoc2</p><p>Dim swSelMgr As SldWorks.SelectionMgr</p><p>Dim swFace As SldWorks.Face2</p><p></p><p>Sub main()</p><p>  </p><p>    Set swApp = Application.SldWorks</p><p></p><p>    Set swModel = swApp.ActiveDoc</p><p>    </p><p>    Set swSelMgr = swModel.SelectionManager</p><p>    </p><p>    Set swFace = swSelMgr.GetSelectedObject6(1, -1)</p><p>    </p><p>    If Not swFace Is Nothing Then</p><p>    </p><p>        Dim vLoops As Variant</p><p>        vLoops = swFace.GetLoops</p><p>        </p><p>        Dim i As Integer</p><p>        </p><p>        swModel.ClearSelection2 True</p><p>        </p><p>        For i = 0 To UBound(vLoops)</p><p>            Dim swLoop As SldWorks.Loop2</p><p>            Set swLoop = vLoops(i)</p><p>            If swLoop.IsOuter() Then</p><p>                Dim vEdges As Variant</p><p>                vEdges = swLoop.GetEdges</p><p>                Dim j As Integer</p><p>                For j = 0 To UBound(vEdges)</p><p>                    Dim swEdge As SldWorks.Entity</p><p>                    Set swEdge = vEdges(j)</p><p>                    swEdge.Select4 True, Nothing</p><p>                Next</p><p>            End If</p><p>        Next</p><p>        </p><p>    End If</p><p>    </p><p>End Sub</p>

____________________________________________________

Regards,

Artem Taturevych, Application Engineer at Intercad (Australia)

translationXpert – add-in to translate SolidWorks models

myIntercad – an integrated tool for SolidWorks Professionals

LinkedIn SolidWorks API Education Group

SF
SF 2013-08-21

Hi Artem!,

Thank you very much for helping me out..I spent at least 8 hours trying to figure out how to do this with no luck.

I cannot wait to get back in the office and dig into this code.

I was sooo close with my code but just wrong enough to not work.....

Do you have a particular SW API book that you reccomend? Im trying to learn as much as i can but I often hit the wall when looking for information specific  to SW API

thanks again!

Chris

AT
AT 2013-08-21

Hi Chris,

I would recommend the Keith's video courses at this web-site: cadsharp.com. You may also join the LinkedIn group for API Education as well as download and install myIntercad.myToolkit which contains a lot of API examples and macros. You may find the information in my signature.

____________________________________________________

Regards,

Artem Taturevych, Application Engineer at Intercad (Australia)

translationXpert – add-in to translate SolidWorks models

myIntercad – an integrated tool for SolidWorks Professionals

LinkedIn SolidWorks API Education Group