Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCad 2016 - Retaining the Value in a lisp

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
309 Views, 3 Replies

AutoCad 2016 - Retaining the Value in a lisp

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

 

 

3 REPLIES 3
Message 2 of 4
leothebuilder
in reply to: Anonymous

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

 

 

Message 3 of 4
Kent1Cooper
in reply to: Anonymous

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
Message 4 of 4
Anonymous
in reply to: leothebuilder

Thank you for the heads up! I will be sure to post it in the correct place.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report