Skip to main content
1-Visitor
December 17, 2010
Question

How do you work out how many segments are in a selected bezier curve and which one has been selected?

  • December 17, 2010
  • 1 reply
  • 2730 views

I'm doing a macro that gets the user to select a bezier, then changes the line thickness of part of that bezier.

To let me know which segments to change, I need to know two things:

  1. How many segments are in the bezier.Can this be done in a macro using a loop until there are no more segments reported?
  2. Which segment has been selected.

Are these things possible?

The reason for wanting this information is:

When we convert IGES drawings to 2d, it leaves thick lines where bolt heads rest against metal and we change them to thin. Annoyingly, there is always 1 bezier line that needs to be half thick and half thin. I can't predict how many segments these lines have (often 6) or which way round the line has generated, so I'm never sure which segments to change. If I know, for example that the user selected segment 2 of 6, I know to change line thicknesses of the first 3 segments.

    1 reply

    12-Amethyst
    December 17, 2010

    Here's the answer to #1. If you have problems with this, I did do it the long way (loop) first.

    Macro PartCount

    Define E1 as Element

    E1=ActiveDoc.FirstSelectedElement

    Message E1.SegmentCount

    End Macro

    TimSharp1-VisitorAuthor
    1-Visitor
    December 23, 2010

    Thanks Trevor. This helps a lot. I guess the only way to know which segment I have actually selected would be to check straight lines between end points of each segment and the one that comes closest to the picked point is it.