AnsweredAssumed Answered

How to select the second (or third) body created by an Extruded-Cut via API?

Question asked by Mike Frink on Oct 17, 2016
Latest reply on Oct 18, 2016 by Amen Allah Jlili

I have created an API that takes a sketch and Extrude-Cuts another solid. Sometimes this cut creates multiple bodies (ie Cut-Extrude1[1],Cut-Extrude1[2], etc.). In the next part of the macro, I am looking to perform more actions on the main body (the largest body in the Extruded-Cut, but not necessarily the largest body in the model). How can I select the largest body out of the Extruded-Cut feature?


'Cut body with Extrude Cut

    Dim myFeature2 As Object

    boolstatus = Part.Extension.SelectByID2("Sketch2", "SKETCH", 0, 0, 0, False, 4, Nothing, 0)

    Part.SelectionManager.EnableContourSelection = True

    boolstatus = Part.Extension.SelectByID2("Sketch2", "SKETCHCONTOUR", 0, 0, 0, True, 4, Nothing, 0)

    boolstatus = Part.Extension.SelectByID2(myRefPlane.Name, "PLANE", 0, 0, 0, True, 1, Nothing, 0)

    boolstatus = Part.Extension.SelectByID2(SlicedBody, "SOLIDBODY", -4.61290402245709E-02, 1.06971445651851E-02, 7.00869373238149E-02, True, 8, Nothing, 0)

    Part.FeatureManager.FeatureCut3 True, False, True, 4, 0, 0.0254, 0.0254, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, False, True, False, False, 0, 0, False


    Part.SelectionManager.EnableContourSelection = False

    SlicedBody = Part.FeatureByPositionReverse(0).Name

    boolstatus = Part.Extension.SelectByID2(SlicedBody, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

    Set swSelMgr2 = Part.SelectionManager

    Set CutSurface = swSelMgr2.GetSelectedObject6(1, -1)


I've played around with .GetBodies2 and IExtrudeFeatureData2 but without any luck.