mladenlju Posted August 19, 2022 Posted August 19, 2022 Hi, is there a lisp that I can use to change the elevation of an object based on the selection of another object? For example, object 1 has an elevation of 0, and object 2 has an elevation of 155, I want object 1 to change elevation based on the selection of object 2. Of course, the X and Y coordinates of object 1 must not change. Best regards, Mladen Lj. Change elevation of object based on another.dwg Quote
fuccaro Posted August 19, 2022 Posted August 19, 2022 (defun c:MoveZ( / ss target z i en el a10) (princ "Select objects to be moved...") (setq ss (ssget)) (setq target (entsel "select target ")) (setq z (last (assoc 10 (entget (car target))))) (repeat (setq i (sslength ss)) (setq en (ssname ss (setq i (1- i))) el (entget en) a10 (reverse(cons z (cdr(reverse(assoc 10 el))))) el (subst a10 (assoc 10 el) el)) (entmod el) ) (setq ss nil) (princ) ) Here a quick one - I have just minutes until I go home. Does it help? 1 Quote
mladenlju Posted August 19, 2022 Author Posted August 19, 2022 Thx for help. It's work. In the meantime i got this one (also work): (defun c:Zmatch ( / s d) (and (setq s (car (entsel "\nSource: "))) (setq s (last (assoc 10 (entget s)))) (setq d (car (entsel (strcat "\nObject to apply z=" (rtos s) " to: ")))) (setq d (entget d)) (entmod (subst (reverse (cons s (cdr (reverse (assoc 10 d))))) (assoc 10 d) d)) ) (princ) ) br Quote
Isaac26a Posted August 19, 2022 Posted August 19, 2022 Maybe this post can help you Quote you only need to select a point on the object. Quote
dan20047 Posted August 19, 2022 Posted August 19, 2022 I use the .xyz shortcuts (defun c:MX () (ssget ":LI") (SAA_CMDACTIVE nil) (command "MOVE" "P" "" pause ".yz" "non" "@") (princ)) (defun c:MY () (ssget ":LI") (SAA_CMDACTIVE nil) (command "MOVE" "P" "" pause ".xz" "non" "@") (princ)) (defun c:MZ () (ssget ":LI") (SAA_CMDACTIVE nil) (command "MOVE" "P" "" pause ".xy" "non" "@") (princ)) ;;;========================================================== ;;; Continue pausing until exited command mode ;;; nil = pause ;;; otherwise pass string to use ;;; credit unknown ;;; usage example: (command "line" (SAA_CMDACTIVE nil)) ;;;========================================================== (defun SAA_CMDACTIVE ( passcmd / ) (if (null passcmd) (setq passcmd pause)) (while (not (= 0 (getvar "cmdactive"))) (if (= 'LIST (type passcmd)) (foreach x passcmd (command x) ) ;_foreach (command passcmd) ) ;_if ) ;end while ) 1 Quote
BIGAL Posted August 23, 2022 Posted August 23, 2022 As your dealing with objects with possible Z values, the entmod would be more reliable method. Else check is object to move at z=0. 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.