Macro for converting every line in a drawing into two lines

May 03, 2006 5 Replies

Hi all,



I am completely new to the whole Solidworks macro thing. I was wondering if something like the following could be done:


  1. Scan through the present drawing and for every line in the drawing:
  2. Create two copies of the line which are offset from the present line on both sides.

Basically, we have a drawing which cuts out fine on a machine which creates "thick cuts", however, when we want to cut out the same file on another machine which creates "thin cuts", some of the cuts are too thin. I thought that doing something like this would enable me to thicken the cuts on the second machine.



Thank you, Regards, Srinath



Yup, should be possible.

Iterate through drawing views to select all edges and then use ModelDoc2::SketchOffset2.

This isn't a SolidWorks answer, but I'd look into using Cutter Radius Compensation (CRC) on your CNC mill if available. With CRC, you'd program the mill to the actual part dimension, and then the CNC generates a cutter path offset from your entered part size value by whatever diameter you tell it your cutter is.

Ken

Hi Tin,

Thanks for the reply.

In my case, I am using a Laser Machine, not a mill. The machine we have doesn't have anything like CRC. It basically functions as a print driver so we need to create a solidworks file which it then cuts as seen.

Thanks, Srinath

Hi Mr. Who(?)

Thanks for the reply. Could you please elaborate on how one "iterates through drawing views"? The hint about ModelDoc2::SketchOffset2 is very helpful.

Thanks, Srinath

  1. Use DrawingDoc::GetFirstView (returns sheet)
  2. Then View::GetNextView to get each subsequent drawing view on that sheet

Not positive what you need here - sketch lines or edges. Big difference. For sketch lines:

  1. View::GetSketch to get sketch associated with a view
  2. Sketch::GetSketchSegments to get all sketch segments
  3. SketchSegment::Select4 to select the sketch segments
  4. ModelDoc2::SketchOffset2 to offset them

For drawing edges:

  1. View::GetVisibleEntities to get all visible edges, faces and vertices
  2. Entity::GetType to filter out edges
  3. Entity::Select4 to select edges
  4. ModelDoc2::SketchOffset2 to offset them

Good luck.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required