Hello
As part of a macro I'm writing I want to trim a surface using another surface as a tool. I used the macro recording feature of SW and got this :
Sub main() Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc boolstatus = Part.Extension.SelectByID2("", "SURFACEBODY", -2.21255758435177E-02, 1.12119991063828E-02, -1.05938641196843E-02, True, 0, Nothing, 0) boolstatus = Part.FeatureManager.PreTrimSurface(False, False, False, False) boolstatus = Part.Extension.SelectByID2("", "SURFACEBODY", 2.1182587399835E-03, 2.64108065074833E-02, 3.92904249648041E-03, True, 0, Nothing, 0) Dim myFeature As Object Set myFeature = Part.FeatureManager.PostTrimSurface(True) End Sub
Simple enough, my problem is I can't use SelectByID2 because the coordinates to select my surfaces won't always be the same. So I tried SelectByRay to select the surfaces I want to trim, unfortunately it doesn't work and I can't find out why, there's no error message. My code looks like this :
Part.ClearSelection2 True boolstatus = Part.Extension.SelectByRay(0, 0, 0, -1, 0, 0, 0.001, swSelectType_e.swSelSURFACEBODIES, True, 0, 0) boolstatus = Part.FeatureManager.PreTrimSurface(False, False, False, False) boolstatus = Part.Extension.SelectByRay(0, 0.22, 0, -1, 0, 0, 1, swSelectType_e.swSelSURFACEBODIES, True, 0, 0) Set myFeature = Part.FeatureManager.PostTrimSurface(True)
Any help is appreciated!