Xiphos Posted July 15, 2015 Share Posted July 15, 2015 Hello Everyone. The only experience I have with LISP routines is just loading them into cad. I have a specific request that I need help with. I am using Acad 2012. I need a Lisp Routine that: (Is also equipped with the vl-load-com portion as I do not have access to any Acad system files) 1) Turns Qtext ON, Regen, then zoom extents. 2) Pauses for a prompt to the user if they wish to continue Y or N 2a) If no, the program terminates. 2b) If Yes, turn Qext OFF, Regen, then zoom extents. To keep this short I will skip the explanation for why I need this. It will kill two birds with one stone. If there is anyone that is feeling kind enough to write me something that will work? Thank you very much in advance! Quote Link to comment Share on other sites More sharing options...
rlx Posted July 15, 2015 Share Posted July 15, 2015 (edited) (defun c:qtzoom ( / inp) (vl-load-com) (setvar "QTEXTMODE" 1) (command ".regen" ".zoom" "e") (initget "YES yes NO no") (setq inp (getkword "\nDo you wish to continue? Yes or No: ")) (if (eq inp "Yes") (progn (setvar "QTEXTMODE" 0)(command ".regen" ".zoom" "e"))) (princ) ) Edited July 16, 2015 by SLW210 Added Code Tags! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 15, 2015 Share Posted July 15, 2015 Please read the Code Posting Guidelines and use Code Tags for your Code. Quote Link to comment Share on other sites More sharing options...
rlx Posted July 15, 2015 Share Posted July 15, 2015 i use the wrap symbol but is just does not work rlx Quote Link to comment Share on other sites More sharing options...
Xiphos Posted July 15, 2015 Author Share Posted July 15, 2015 rlx, Thank you very much! The first part of the code works without a hitch, but the program ends if I hit yes to continue. Any thoughts? Quote Link to comment Share on other sites More sharing options...
tombu Posted July 15, 2015 Share Posted July 15, 2015 Try: (defun c:qtzoom ( / inp) (vl-load-com) (setvar "QTEXTMODE" 1) (command ".regen" ".zoom" "e") (initget "Yes No") (setq inp (getkword "\nDo you wish to continue? [Yes/No] ")) (if (eq inp "Yes") (progn (setvar "QTEXTMODE" 0)(command ".regen" ".zoom" "e"))) (princ) ) Quote Link to comment Share on other sites More sharing options...
Xiphos Posted July 15, 2015 Author Share Posted July 15, 2015 (edited) Ok! This works, but it seems as though it's not zooming to extents. And by that I mean it does zoom to the drawing, but it is ignoring the qtext for zooming. If I go through the command manually, not using the lisp, (Qtext, on) , (regen) , (Zoom extents) then it works. EDIT: I changed the code so it does not use (setvar) instead, I did this: (defun c:qtzoom ( / inp) (vl-load-com) (command ".qtext" "ON" ".regen" ".zoom" "e") (initget "Yes No") (setq inp (getkword "\nDo you wish to continue? [Yes/No] ")) (if (eq inp "Yes") (progn (command ".qtext" "OFF"".regen" ".zoom" "e"))) (princ) ) Now everything works like it should! Thanks guys! You have made my life so much easier! Edited July 15, 2015 by Xiphos Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 16, 2015 Share Posted July 16, 2015 You dont need the progn in this line (if (eq inp "Yes") (progn (command ".qtext" "OFF"".regen" ".zoom" "e"))) A IF is basicly true or false 1 line but if you need more than 1 line of code statements then you use a progn to say I have more than 1 line I want to execute. (if (= x 1) (this is true) (this is false) ) (if (= x 1) (progn (this is true) (need line 2) (needline 3) ) ; end progn (this is false) ) Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 16, 2015 Share Posted July 16, 2015 i use the wrap symbol but is just does not work rlx Not sure what you mean by wrap symbol, but... You just use the # or manually make the tags. [NOPARSE] Your Code Here [/NOPARSE]. Fixed your post for you this time. Quote Link to comment Share on other sites More sharing options...
rlx Posted July 17, 2015 Share Posted July 17, 2015 Not sure what you mean by wrap symbol, but... You just use the # or manually make the tags. [NOPARSE] Your Code Here [/NOPARSE]. Fixed your post for you this time. I used the '# symbol (after selecting my code) but just nothing happens. I'll use the manual option next time or use attachements instead , gr. rlx. Quote Link to comment Share on other sites More sharing options...
tombu Posted July 17, 2015 Share Posted July 17, 2015 I used the '# symbol (after selecting my code) but just nothing happens. I'll use the manual option next time or use attachements instead , gr. rlx. When you click the # it places the curser (blinking vertical line) between the code tags. Simply paste your code immediately after clicking # without moving the curser and it will display perfectly when posted! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 17, 2015 Share Posted July 17, 2015 When you click the # it places the curser (blinking vertical line) between the code tags. That shows that you are using Google Chrome but if you used FireFox , the cursor would be outside and at the end of the last char. Quote Link to comment Share on other sites More sharing options...
rlx Posted July 17, 2015 Share Posted July 17, 2015 ok , I'll give it a try (defun rdup ( i / o );remove duplicates (vl-remove-if '(lambda (x) (cond ((vl-position x o) t) ((setq o (cons x o)) nil))) i)) ..... nope (defun rdup ( i / o );remove duplicates (vl-remove-if '(lambda (x) (cond ((vl-position x o) t) ((setq o (cons x o)) nil))) i)) well selecting and clickin'g didn't do the job , but manually putting at beginning and the other one at the end did the job. I'm using company browser (micro sof) , with (company) defaults (Sabic , former GE) , so little I can do about it i'm afraid. But Thanx 4 all your advise guys , really appreciated. Gr. Rlx Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 17, 2015 Share Posted July 17, 2015 This [\code] must be [/code] Quote Link to comment Share on other sites More sharing options...
rlx Posted July 17, 2015 Share Posted July 17, 2015 This [\code] must be [/code] yip I saw it and fixed it but appently you saw it first:lol: Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 17, 2015 Share Posted July 17, 2015 yip I saw it and fixed it but appently you saw it first:lol: In some forums I prefer writing it than using the tag button specially when modifying a post. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.