Civils_Ben Posted Thursday at 03:55 PM Share Posted Thursday at 03:55 PM Hi all, first time poster here. Been searching around for a while on various sites for a Lisp routine that I can select an attribute block then apply the value in the block to a polyline's elevation. I even tried Chat GPT but this appears to be too complex for it so i thought I would ask the experts. CAD test file attached for assistance. test.dwg Apologies if this is in the wrong thread. Cheers, Ben Quote Link to comment Share on other sites More sharing options...
SLW210 Posted Thursday at 05:45 PM Share Posted Thursday at 05:45 PM I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted Thursday at 09:51 PM Share Posted Thursday at 09:51 PM Welcome aboard, there are 2 ways to set the elevations. You can also use nentsel to pick the attribute value directly from the block. (defun c:selev ( / ent ent2) (setq ent (car (nentsel "\nPick the attribute text "))) (setq elev (atof (cdr (assoc 1 (entget ent))))) (setq ent2 (entget (car (entsel "\nPick pline ")))) (entmod (subst (cons 38 elev) (assoc 38 ent2) ent2)) (princ) ) ; VL (defun c:selev ( / obj elev obj2) (setq obj (vlax-ename->vla-object (car (nentsel "\pick the attribute ")))) (setq elev (atof (vlax-get obj 'textstring))) (setq obj2 (vlax-ename->vla-object (car (entsel "\nPick the pline ")))) (vlax-put obj2 'elevation elev) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tsuky Posted Thursday at 10:34 PM Share Posted Thursday at 10:34 PM With your dynamic bloc, try this... (defun c:att2elev ( / ss n ename dxf_ent dxf_10 ss_bl o l_att) (princ "\nSelect polyline") (setq ss (ssget (list (cons 0 "lWPOLYLINE") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) (cons 8 "T_E_Construction layer") (cons -4 "&") (cons 70 1) ) ) ) (cond (ss (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) dxf_ent (entget ename) dxf_10 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10))dxf_ent)) ss_bl (ssget "_WP" (mapcar '(lambda (x) (trans x 0 1)) dxf_10) '((0 . "INSERT") (2 . "`*U*") (8 . "T_E_FFL") (66 . 1))) ) (cond (ss_bl (if (= "T_E_FFL" (strcase (vla-get-effectivename (setq o (vlax-ename->vla-object (ssname ss_bl 0)))))) (progn (setq l_att (mapcar '(lambda (at) (list (Vla-get-tagstring at)(Vla-get-textstring at) at) ) (vlax-invoke o 'GetAttributes) ) ) (mapcar '(lambda (x) (if (eq (car x) "FFL") (entmod (subst (cons 38 (read (cadr x))) (assoc 38 dxf_ent) dxf_ent)) ) ) l_att ) ) ) ) ) ) ) ) (prin1) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted Friday at 02:36 PM Share Posted Friday at 02:36 PM Only one minor adjustment in @Tsuky code... This line : (setq ss_bl (ssget "_WP" (mapcar '(lambda (x) (trans x 0 1)) dxf_10) '((0 . "INSERT") (2 . "`*U*") (8 . "T_E_FFL") (66 . 1)))) Should be : (setq ss_bl (ssget "_WP" (mapcar '(lambda (x) (trans x ename 1)) dxf_10) '((0 . "INSERT") (2 . "`*U*") (8 . "T_E_FFL") (66 . 1)))) 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.