×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Relative coordinates in a macro

Relative coordinates in a macro

Relative coordinates in a macro

(OP)
I'm tinkering with a macro definition for an AutoCAD button that will create a leader line to be used for a welding symbol.  The macro needs to create a leader in MS with the tail being exactly 1" in PS.  The sticking point is my logic wants to use a relative coordinate definition that is based upon the DIMSCALE.  I have been unable to figure out how to use relative coordinates in a macro without actually prompting for user input.

The only thing that works half-way is this:

^C^C(SETQ LX (GETVAR "DIMSCALE")LY '0);_LEADER;\\;;N;UCS;O;@;LINE;@;(LIST LX LY);;UCS;P;

The problem is, the specification "@" for last point picked (also LASTPOINT value) works correctly when starting in WCS, but if starting in anything other than WCS, the @ point is off in the stratosphere.

I want to believe that if I can use relative coordinates for the last point without stopping the leader command and going to draw a line based on a new UCS that it would work better.

Thoughts?

Thanks in advance!

Bill
Racer24ksi

RE: Relative coordinates in a macro

In lisp, I use (polar point1 distance angle) to gt to the next point.

RE: Relative coordinates in a macro

(OP)
Thanks for the tip - that worked out perfect on the first attempt:

^C^C_LEADER;\\(polar (getvar "lastpoint") 0 (getvar "dimscale"));;;N;

Note:  Because the tail of the leader is supposed to be 1", the DIMSCALE value is equal to 1" in PS.

Bill
Racer24ksi

RE: Relative coordinates in a macro

Whaw. You made the tip into something real cute. To include those two getvars is ingenious. I would have to go more roundabout to get there. You produced the most compact code I have seen since a long time.

Take care.

www.homescript.com

RE: Relative coordinates in a macro

(OP)
Well, even a blind squirrel finds a nut now and then!

BTW - Playing with it a little further, the syntax is actually (polar point1 angle distance) where angle is in radians.  To make the leader tail 1" in the opposite direction, replace 0 with pi:

^C^C_LEADER;\\(polar (getvar "lastpoint") pi (getvar "dimscale"));;;N;

For angles other than 0 and 180, math functions worked well too:

^C^C_LEADER;\\(polar (getvar "lastpoint") (/ pi 2) (getvar "dimscale"));;;N;

would produce a tail oriented 90 degrees vertical.

Thanks again for your help.

Bill
Racer24ksi

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources