Jump to content

lisp routine to modify X, Y and Z axis


dnovember99

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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[<" i ">]: ")))
		 ((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)

Link to comment
Share on other sites

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[<" i ">]: ")))
		 ((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

Link to comment
Share on other sites

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)
 [b](or (setq i (getenv "ScaleIt")) (setq i "48."))[/b]
 (if (and (not (initget 2))
   (setq i (cond ((getreal (strcat "\nEnter block scale[<" i ">]: ")))
		 ((read i))
	   )
   )
   (setq s (ssget ":L" '((0 . "insert"))))
   [b](setenv "ScaleIt" (vl-princ-to-string i))[/b]
     )
   (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)

Edited by ronjonp
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...