; CHELEV Command. ; ; Change UCS elevation of selected geometry (intended for 2D use only, ; but might also work on any geomtry at any orientation). ; ; Note: ; ; This AutoLISP command is NOT a replacement for the Release 10 CHANGE- ; Properties/Elevation command! ALL selected objects will be moved by ; varying displacements, in a direction parallel to either the Z axis of ; their ECS (if the object defines a coordinate system), or the Z axis of ; the WCS (if the object does not define a coordinate system). ; ; The distance that each object is moved will vary, depending on the Z ; component of its primary coordinate (group 10) in relation to the new ; specified elevation and the origin of the coordinate system which the ; object's primary coordinate is expressed in. ; ; CHELEV performs the equivalent of issuing an array of MOVE commands ; on each of the selected objects, applying different displacements to ; each one, to move them all to the same elevation (see below). ; ; When used on planar geometry parallel to the WCS XY plane, the command ; MAY behave similar to the AutoCAD CHANGE Properties Elevation command, ; but there are NO guarantees! ; ; Generally, 2D objects which define a PLANE should move in a direction ; parallel to their extrusion vector (the Z axis of their ECS). All 3D ; objects will move in a direction parallel to the WCS Z axis. ; ; With CHELEV, the elevation of an object is defined as the Z component ; of its primary coordinate (group 10), the Z components of all other ; coordinates of an object are displaced by the same distance the object's ; primary coordinate is displaced, in a rigid fashion. The displacement ; distance applied to each object, is the difference between the primary ; coordinate's Z component, and the new elevation. (defun setelev (ent / base zoff) (setq ent (entget ent) base (cadddr (assoc 10 ent)) zoff (- nl base)) (entmod (mapcar '(lambda (x) (cond ( (> 20 (car x) 9) (list (car x) (cadr x) (caddr x) (+ (cadddr x) zoff))) (t x))) ent))) (defun C:CHELEV ( / ss nl i ch_err) (setvar "cmdecho" 0) (command ".undo" "g") (setq ch_err *error* *error* '((s) (command ".undo" "e" "u") (setq *error* ch_err) (cond ( (member s '("console break" "Function cancelled"))) (t (princ (strcat "\nError: " s)))) (princ))) (cond ( (not (setq ss (ssget)))) (t (initget 1) (setq nl (getdist "\nNew elevation: ")) (setq i -1) (repeat (sslength ss) (setelev (ssname ss (setq i (1+ i))))))) (command ".undo" "e") (setq *error* ch_err) (princ) )