lisp routine to modify X, Y an
hey all,i am trying to figure out a way to be able to take a block and change the x y and z axis from one value to another. for example something i currently have would be a tag that has a value of 48.000 for all three axis. i want to take that and change it to a different value of lets say 96.000.
does anyone know of a lisp that would be out there that would be able to do this rather than selecting what you want to change going to properties and changing each axis one at a time. i just find that this is a little slow and would like to find another way to do it.any and all help is appreciated.
thank you If you set your block definitions to 'scale uniformly' then you'd only need to fill in the X value. i hear what you are saying, sadly the company that i work for has blocked us from changing that. or in other words i can change it today but that is something that they change back at the end of the day. so that is another reason that i want to come up with something to bypass that so i dont have to set that each day that i go into a drawing.
thank you for the information Here's a quick one:
(defun c:foo (/ i s) (if (and (not (initget 2)) (setq i (getreal "\nEnter block scale: ")) (setq s (ssget ":L" '((0 . "insert")))) ) (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (entmod (mapcar '(lambda (x) (if (member (car x) '(41 42 43)) (cons (car x) i) x ) ) (entget b) ) ) ) ) (princ))
This might be a better if your blocks have attributes:
(defun c:foo (/ i s) (if (and (not (initget 2)) (setq i (getreal "\nEnter block scale: ")) (setq s (ssget ":L" '((0 . "insert")))) ) (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i)) ) ) ) (princ))(vl-load-com) ronjonp***
this works awsome. being that i really only use two scales (48.000 and 96.000) would it be possible to have this set to select the object and type in the command and have it auto set to either one of those numbers. so for example being that the command name "foo"
if it was "foo48" to scale any selected objects to 48.000 and "foo96"to scale to 96.000. just a thought.
but thank you very much for helping with this either way this is going to help me for sure. thank you again Try this .. will remember last scale used.
(defun c:foo (/ i s) (or (setq i (getenv "ScaleIt")) (setq i "48.")) (if (and (not (initget 2)) (setq i (cond ((getreal (strcat "\nEnter block scale[]: "))) ((read i)) ) ) (setq s (ssget ":L" '((0 . "insert")))) (setenv "ScaleIt" (vl-princ-to-string i)) ) (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i)) ) ) ) (princ))(vl-load-com)
this is awsome! now i am trying to run thru what you wrote to understand it a little more so i can learn how to write this stuff slowly. where would it be at when you say that it will remember last?
thanks
The GETENV and SETENV portions get and set (in the registry) the number used.
(defun c:foo (/ i s) (or (setq i (getenv "ScaleIt")) (setq i "48.")) (if (and (not (initget 2)) (setq i (cond ((getreal (strcat "\nEnter block scale[]: "))) ((read i)) ) ) (setq s (ssget ":L" '((0 . "insert")))) (setenv "ScaleIt" (vl-princ-to-string i)) ) (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i)) ) ) ) (princ))(vl-load-com)
页:
[1]