Jump to content

zoom window


rookie37

Recommended Posts

I'm better at script than writing at lisp although I'm not good at that either.

 

I want to get away from that and start converting my script macros into lisp

 

How do I write a zoom window lisp?

 

Below is script. It explains what I'm tring to do but I want it in lisp.

 

 

^C^Cz;w;.end;/.end;/

 

Also

 

 

I have written a simple code to change the line thickness of an entity.

Again, it is in script and isn't very good. I'd like to pick a line or (if I miss) draw a fence and sellect a group. How do I write this in lisp?

 

^C^C_CHANGE;\\;P;t;

Link to comment
Share on other sites

Hi Rookie,

 

Would this suffice?

(defun c:zw ()
 (setvar "cmdecho" 0)
 (command "zoom"
 "w"
 pause
 pause
 ) ; end zoom
 (setvar "cmdecho" 1)
 (princ)
) ; end program

 

 

 

And for the width:

(defun c:polyw ()
   (if
       (setq obs (ssget))
           (progn
               (command "_.pedit"
                   "M"
                   obs ""
                   "w"
                   pause
                   ""
               )
           ) ; end progn
   (alert "\nPlease Select Objects!")
   ) ; end if
   (princ)
) ; end program 

Link to comment
Share on other sites

Thank you for your prompt reply!

 

 

(defun c:zw () (setvar "cmdecho" 0) (command "zoom" "w" pause pause ) ; end zoom (setvar "cmdecho" 1) (princ)) ; end program

 

How do I make zoom window snap to endpoint before each pause

 

 

 

And for the width:

 

Code:

(defun c:polyw () (if (setq obs (ssget)) (progn (command "_.pedit" "M" obs "" "w" pause "" ) ) ; end progn (alert "\nPlease Select Objects!") ) ; end if (princ)) ; end program

 

As it is, it would still be a huge timesaver. How do I modify it so that I can also select an individual line?

Link to comment
Share on other sites

For the zoom window to snap to endpoint, I suppose you could use this:

 

(defun c:zw ()
   (setq pt1 (getpoint "\nSelect First Window Point: "))
   (setq pt1 (osnap pt1 "_endp"))
   (setq pt2 (getpoint "\nSelect Second Window Point: "))
   (setq pt2 (osnap pt2 "_endp"))
     (command "zoom"
     "w"
   pt1
   pt2
     ) ; end zoom
    (princ)
) ; end program

 

Its not ideal though.

 

And for the Polyline width alteration, the LISP that I provided should enable you to select a single line, but if it is not what is desired then I am afraid that I do not have the knowledge to create such a LISP :(

Link to comment
Share on other sites

I like this better.

(defun c:zw (/ pt1 pt2)
(if
  (and
   (setq pt1 (getpoint "\nSelect First Window Point: "))
   (setq pt1 (osnap pt1 "_end"))
   (setq pt2 (getpoint "\nSelect Second Window Point: "))
   (setq pt2 (osnap pt2 "_end"))
  )
   (command "._zoom" "_w" "_non" pt1 "_non" pt2) ; end zoom
)
(princ)
) ; end program

Link to comment
Share on other sites

Maybe this for Thickness:

(defun c:changeThickness (/ ss tk)
(prompt "\nSelect objects to change thickness:")
(if
  (and
    (setq ss (ssget))
    (setq tk (getdist "\nEnter a new thickness:"))
  )
   (command "._change" ss "" "_P" "_T" tk "")
)
(princ)
)

 

Just some ideas to play with.:)

Link to comment
Share on other sites

Thanks for your input CAB, I couldnt work out how to put the 'end-point snap' before the pause and still get the program to work correctly, and so I resolved to put a point selection and use the points within the zoom command.

 

But as for the thickness, I used an 'ssget' syntax (as did you), but I am not sure if Rookie would like a selection similar to an 'entsel' selection pick-box...

Link to comment
Share on other sites

Entsel it is.:)

(defun c:changeThickness (/ ent obj tk)
 (setvar "ErrNo" 0) ; reset variable
 (if (setq tk (getdist "\nEnter a new thickness:"))
   (while
     (cond
       ((and (null(setq ent (car (entsel "\nSelect object to change thickness:"))))
              (= 52 (getvar "ErrNo"))) ; <Enter> was hit
        (prompt "\nUser Quit.") ; Bye bye
       )
       ((null ent)
        (princ "\nMissed, Try Again.")
       )
       ((null (vlax-property-available-p
                (setq obj (vlax-ename->vla-object ent))
                'Thickness t))
        (princ "\nNo Thickness or locked layer. Try Again.")
       )
       (t ; OK to update
        (vla-put-thickness obj tk)
        (princ "\nThickness updated.")
       )
     )
   )
 )
(princ)
)

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