PDA

View Full Version : AutoLISP Move only Z-Coord.?



420325
13th Nov 2007, 07:57 pm
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

lpseifert
13th Nov 2007, 08:10 pm
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

420325
13th Nov 2007, 08:19 pm
Thanks, Im new to the whole LISP process but it should help me get some work done faster.

420325
13th Nov 2007, 08:23 pm
Awsome, It is exactly what I was looking for

Thanks Again,

Patrick

BIGAL
14th Nov 2007, 02:54 am
you can do any of the 3 x y z

x rd (strcat rz ",0,0" )
y rd (strcat "0," rz ",0" )

Phiphi
18th Mar 2009, 09:17 am
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.

Lee Mac
18th Mar 2009, 02:41 pm
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))

Phiphi
20th Mar 2009, 06:44 am
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.

Lee Mac
20th Mar 2009, 11:22 am
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.

Phiphi
21st Mar 2009, 03:48 am
If there are some text: 3.45, 2.55 ...in drawing. We just select this number but not have to "Enter relative Z distance". Cheers.

Lee Mac
21st Mar 2009, 02:38 pm
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))

Phiphi
23rd Mar 2009, 01:09 pm
Lee, I get this:
Command: mvz
Select objects: 1 found
Select objects:
Select Text for Z Coord: ; error: bad argument type: numberp:

Lee Mac
23rd Mar 2009, 01:42 pm
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))

Phiphi
23rd Mar 2009, 11:27 pm
All right now. Thank a lot, Lee.

Lee Mac
23rd Mar 2009, 11:28 pm
No problem Phiphi, it was a stupid mistake on my part :oops:

Glad it works now :)

Lee