ktbjx Posted March 13, 2017 Share Posted March 13, 2017 (edited) is there a lisp routine to make it easier? because i am doing it by hand and its too time consuming.. is there a way to copy the elevation of the nearest polyline and make it the elevation of the other objects without its elevation or Z??? Drawing2.dwg Edited March 13, 2017 by ktbjx added DWG sample Quote Link to comment Share on other sites More sharing options...
ktbjx Posted March 13, 2017 Author Share Posted March 13, 2017 i made one! well atleast i can work faster... if someone can do it better, im really very OPEN to suggestion (vl-load-com) (defun c:qq (/ elevations sss) (if (ssget '((0 . "*POLYLINE"))) (progn (vlax-for x (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) (setq elevations (cons (vla-get-elevation x) elevations)) ) (prompt "\n2nd Selection") (setq sss (ssget "_:L")) (command"_.CHANGE" sss "" "_P" "_E" (rtos (last elevations)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 13, 2017 Share Posted March 13, 2017 (edited) Consider the following: (defun c:fixelevation ( / dis dst elv ent enx idx lst src tmp vts ) (if (and (setq src (LM:ssget "\nSelect polylines with elevation: " '(((0 . "LWPOLYLINE"))))) (setq dst (LM:ssget "\nSelect polylines to modify: " '("_:L" ((0 . "LWPOLYLINE"))))) ) (progn (repeat (setq idx (sslength src)) (setq ent (ssname src (setq idx (1- idx))) lst (cons (cons ent (assoc 38 (entget ent))) lst) ) ) (repeat (setq idx (sslength dst)) (setq enx (entget (ssname dst (setq idx (1- idx)))) vts (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx)) dis (getmindistance (caar lst) vts) elv (cdar lst) ) (foreach itm (cdr lst) (if (< (setq tmp (getmindistance (car itm) vts)) dis) (setq elv (cdr itm) dis tmp ) ) ) (entmod (subst elv (assoc 38 enx) enx)) ) ) ) (princ) ) (defun getmindistance ( ent lst / dis tmp ) (setq dis 1e308) (foreach vtx lst (if (< (setq tmp (distance vtx (vlax-curve-getclosestpointto ent vtx))) dis) (setq dis tmp) ) ) dis ) ;; ssget - Lee Mac ;; A wrapper for the ssget function to permit the use of a custom selection prompt ;; msg - [str] selection prompt ;; arg - [lst] list of ssget arguments (defun LM:ssget ( msg arg / sel ) (princ msg) (setvar 'nomutt 1) (setq sel (vl-catch-all-apply 'ssget arg)) (setvar 'nomutt 0) (if (not (vl-catch-all-error-p sel)) sel) ) (vl-load-com) (princ) Edited March 13, 2017 by Lee Mac Added (vl-load-com) Quote Link to comment Share on other sites More sharing options...
ktbjx Posted March 13, 2017 Author Share Posted March 13, 2017 Consider the following:(defun c:fixelevation ( / dis dst elv ent enx idx lst src tmp vts ) (if (and (setq src (LM:ssget "\nSelect polylines with elevation: " '(((0 . "LWPOLYLINE"))))) (setq dst (LM:ssget "\nSelect polylines to modify: " '("_:L" ((0 . "LWPOLYLINE"))))) ) (progn (repeat (setq idx (sslength src)) (setq ent (ssname src (setq idx (1- idx))) lst (cons (cons ent (assoc 38 (entget ent))) lst) ) ) (repeat (setq idx (sslength dst)) (setq enx (entget (ssname dst (setq idx (1- idx)))) vts (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx)) dis (getmindistance (caar lst) vts) elv (cdar lst) ) (foreach itm (cdr lst) (if (< (setq tmp (getmindistance (car itm) vts)) dis) (setq elv (cdr itm) dis tmp ) ) ) (entmod (subst elv (assoc 38 enx) enx)) ) ) ) (princ) ) (defun getmindistance ( ent lst / dis tmp ) (setq dis 1e308) (foreach vtx lst (if (< (setq tmp (distance vtx (vlax-curve-getclosestpointto ent vtx))) dis) (setq dis tmp) ) ) dis ) ;; ssget - Lee Mac ;; A wrapper for the ssget function to permit the use of a custom selection prompt ;; msg - [str] selection prompt ;; arg - [lst] list of ssget arguments (defun LM:ssget ( msg arg / sel ) (princ msg) (setvar 'nomutt 1) (setq sel (vl-catch-all-apply 'ssget arg)) (setvar 'nomutt 0) (if (not (vl-catch-all-error-p sel)) sel) ) (princ) Command: fixelevation Select polylines with elevation: Select polylines to modify: ; error: no function definition: VLAX-CURVE-GETCLOSESTPOINTTO there is an error sir, and also its not jut polyline i wanted to change but also text(Position Z), leader(Vertex Z), line (Star/End Z)... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 13, 2017 Share Posted March 13, 2017 Please try the updated code above. Quote Link to comment Share on other sites More sharing options...
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.