Create point on the selected sketch point in the Drawing View

Hi SW Community, ​, ​, ​

Im currently creating a macro to create a point on the selected sketch point of the model in a drawing view.

But it seems that there are lots of transform to do.

Does anyone who can help me with this?

Thank you in advance.

Regards,

DiAnne

SolidworksApi macros
Answers 6
PB
PB 2017-06-06 Best Answer

I guess you recorded a macro and there are hundreds of lines with transforms? That's just you zooming in and out. You can remove most of that and still have a functioning macro.

I guess you need to do something like this:

  1. Create a SelectionManager​
  2. Use GetSelectedObject6 (1, -1) to get the first selected item and put that into an object
  3. Check the type of the object to see if you can put it into a sketchPoint​. I don't know if you can check the object type, otherwise create a Try Catch block that catches all errors (On Error GoTo labelName) and just try to put the object into a SketchPoint object.
  4. If that went well, get the position of the point. Make sure you know if the coordinates are local for that view or global for that sheet.
  5. Get the right drawing view
  6. Activate the drawing view for sketching
  7. Add a new point to the drawing view using CreatePoint​
ST
ST 2017-06-06

I wrote this macro a long time ago. It can almost certainly be simplified, but it will do the job.

DA
DA 2017-06-07

Hi Peter,

I can select the point already, and I didnt recorded a macro.

My problem is that, the selected point is a point in a sketch within the model.

and i want to create a point from the selected point.

DA
DA 2017-06-07

Hi Simon,

Id tried it, but doesnt work.

PB
PB 2017-06-07

In that case you could start by recording a macro Clean it up a little, add some things, post it here and tell us where you get stuck.

ST
ST 2017-06-07

In what way does it not work?

Did you step through the macro to see which line isn't working?