Jump to content

AutoLISP Move only Z-Coord.?


420325

Recommended Posts

I am trying to find or build a LISP that will move any object that is selected in the Z-Coord. I know many ways to change the elevation of an object I would just like to be able to run a command other than move @0,0,?

 

thanks

Link to comment
Share on other sites

Here's something to get you started:

(defun c:mvz ()
(setq ss1 (ssget)
        rz (rtos (getreal "Enter relative Z distance: "))
        rd (strcat "0,0," rz)
);setq
(command "move" ss1 "" "0,0,0" rd)
);defun

Link to comment
Share on other sites

  • 1 year later...
Here's something to get you started:

(defun c:mvz ()
(setq ss1 (ssget)
        rz (rtos (getreal "Enter relative Z distance: "))
        rd (strcat "0,0," rz)
);setq
(command "move" ss1 "" "0,0,0" rd)
);defun

Can you please add an option to pick the value of Z as well. Thank you.

Link to comment
Share on other sites

Perhaps :

 

(defun c:mvz  (/ ss1 rz rd)
 (setq    ss1 (ssget)
   rz  (rtos (getdist "Enter relative Z distance: "))
   rd  (strcat "0,0," rz))
 (command "move" ss1 "" "0,0,0" rd)
 (princ))

Link to comment
Share on other sites

Perhaps :

 

(defun c:mvz  (/ ss1 rz rd)
 (setq    ss1 (ssget)
   rz  (rtos (getdist "Enter relative Z distance: "))
   rd  (strcat "0,0," rz))
 (command "move" ss1 "" "0,0,0" rd)
 (princ))

Thanks Lee, but it does not work.

Lisp must request to pick a text of Z value first.

Link to comment
Share on other sites

This works in the same way as previously posted, except the user can click and specify a distance on screen. I'm not quite sure what you were expecting, but if you could clarify things it'd make it much easier.

Link to comment
Share on other sites

Maybe this:

 

(defun c:mvz  (/ ss1 rz rd)
 (if (and  (setq ss1 (ssget)
         txt (car (entsel "\nSelect Text for Z Coord: "))))
   (progn
   rd  (strcat "0,0," (rtos (cdr (assoc 1 (entget txt)))))
     (command "move" ss1 "" "0,0,0" rd))
   (princ "\n<!> Error in Selections <!>"))
 (princ))

Link to comment
Share on other sites

Haha... I'm a moron.... the text you are selecting is already a string and not a number... so I was trying to convert a string to a string... :P

 

(defun c:mvz  (/ ss1 rz rd)
 (if (and  (setq ss1 (ssget)
           txt (car (entsel "\nSelect Text for Z Coord: "))))
   (progn
   (setq rd (strcat "0,0," (cdr (assoc 1 (entget txt)))))
     (command "move" ss1 "" "0,0,0" rd))
   (princ "\n<!> Error in Selections <!>"))
 (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...