Jump to content

Qtext & Zoom Extents Combined (AutoCad 2012)


Xiphos

Recommended Posts

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!

Link to comment
Share on other sites

(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 by SLW210
Added Code Tags!
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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!:thumbsup:

Edited by Xiphos
Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. 8)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...