AnsweredAssumed Answered

script to sketch 3d points at intersection of 2 parts in assembly

Question asked by Yotam Amiram on Nov 9, 2016

Hi everyone, I have a specific requirement at work to find the XYZ coordinates of points where 2 certain parts intersect.

up until now, to do this, I would insert a 3D sketch in the main assembly and manually pick-point this location using points.

afterwards I copy this sketch to a new part and save as an IGES file, turn this file into a txt. file and copy those coordinates that represent the location of the points to excel and MATLAB.

This is very time consuming and i'm sure (hope) it is possible to write a macro for this. do you think it would be possible or by any chance is already available somewhere?


thanks in advance,





I used tools->sketch tools->intersection curve to record a macro and selected the two bodies that I need the intersection for. this works somewhat strange as the first time I use the macro that I recorded I get a 2d sketch on seemingly nowhere (picrture 1). after I exit this sketch and rerun the macro a second time I get exactly what I need. (picture 2).


this is the macro recorded:


Sub main()


Set swApp = Application.SldWorks


Set Part = swApp.ActiveDoc


boolstatus = Part.Extension.SelectByID2("ONE laser-2@Main_assy", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("ball-2@Main_assy", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0)




Part.ClearSelection2 True


End Sub


any thoughts as to what's causing this?


thanks all, Yotam.