rookie37 Posted October 16, 2008 Posted October 16, 2008 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; Quote
Lee Mac Posted October 16, 2008 Posted October 16, 2008 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 Quote
rookie37 Posted October 17, 2008 Author Posted October 17, 2008 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? Quote
Lee Mac Posted October 17, 2008 Posted October 17, 2008 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 Quote
CAB Posted October 17, 2008 Posted October 17, 2008 Here is one option. (defun c:zw () (setvar "cmdecho" 0) (command "zoom" "w" "_end" pause "_end" pause ) Quote
CAB Posted October 17, 2008 Posted October 17, 2008 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 Quote
CAB Posted October 17, 2008 Posted October 17, 2008 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. Quote
Lee Mac Posted October 18, 2008 Posted October 18, 2008 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... Quote
CAB Posted October 18, 2008 Posted October 18, 2008 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) ) Quote
rookie37 Posted October 19, 2008 Author Posted October 19, 2008 Thank you! It will be a great help Quote
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.