Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

AutoCad 2016 - Retaining the Value in a lisp

Anonymous

AutoCad 2016 - Retaining the Value in a lisp

Anonymous
Not applicable

All,

I have a problem getting it to retain the value that is entered for distance "dist" in the line code.  Can anyone shine a light on how I could achive saving the distance similar to the fillet or offset command?  Please see the lisp that I have attached below so you can see how the command runs.

Thanks,

Alex

 

 

0 Likes
Reply
386 Views
3 Replies
Replies (3)

leothebuilder
Advisor
Advisor

You will probably get a better response posting this in the lisp forum:

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

 

0 Likes

Kent1Cooper
Consultant
Consultant

Yes, over at the Customization Forum would be better [not a version-specific issue], but....

 

Take 'dist' out of the localized variables list at the top so it will be remembered after the routine is run.  Personally, I would give it a variable name more specific to this routine, so that in case you run various routines that might leave variable settings, no other one that happens to use a 'dist' variable will overwrite the value.  So if we call it something like BRKOUTDIST, replace this line:

 

(setq dist (getreal "\nEnter distance from intersection to breakout. "))

 

with something like this [untested]:

 

(initget (if BRKOUTDIST 0 1)); no Enter allowed on first use [variable doesn't yet exist]

(setq BRKOUTDIST

  (cond

    ( (getdist ; returns nil on Enter, only when allowed above by existence of variable

        (strcat

          "\nDistance from intersection to breakout"

          (if BRKOUTDIST (strcat " <" (rtos BRKOUTDIST) ">") ""); offer default prior value if it exists

          ": "

        ); strcat

      ); getdist

    ); User-input condition

    (BRKOUTDIST); prior value on Enter [when allowed]

  ); cond

); setq

 

Using (getdist) instead of (getreal) allows the User to type a value, including one with feet and/or fractions if you use those, or pick two points on-screen.

Kent Cooper, AIA
0 Likes

Anonymous
Not applicable
Thank you for the heads up! I will be sure to post it in the correct place.
0 Likes