leong1221 Posted November 9, 2017 Share Posted November 9, 2017 Hello, How do you insert an attribute block and rename the tags? Assuming there is only 1 attribute block and many of its copies with different tag value. It is easy to do it with keyboard and mouse but is it possible to do it in lisp? Thanks Leo Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 9, 2017 Share Posted November 9, 2017 Are you sure you mean 'rename the tags'? Or do you mean populate the attribute values? Quote Link to comment Share on other sites More sharing options...
leong1221 Posted November 10, 2017 Author Share Posted November 10, 2017 Are you sure you mean 'rename the tags'? Or do you mean populate the attribute values? Good morning Lee, You know what is the best thing in the morning? Is that when you go back to office, press the F5 and see LeeMac replys on your post:D Yes. I need to change the Tag value, not the name of the tag:ouch: Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 11, 2017 Share Posted November 11, 2017 There are so many examples available for changing block attributes. Do you want a custom routine like we have say for changing title block attributes ? Certainly Lee has some nice global routines. It would be best to post a dwg so we can see what it is your trying to do. Quote Link to comment Share on other sites More sharing options...
leong1221 Posted November 13, 2017 Author Share Posted November 13, 2017 Hi Bigal and all, Please find attached dwg for your information. The code below should be able to demonstrate my idea of command. Please make sure the BlockReference is set in Quickleader. ;;;;;;;;;;;;;;;;;;;;;;;;;SemiAutoLabeling;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun dtr ( deg ) (* pi (/ deg 180.0))) (defun rtd (a)(/ (* a 180.0) pi)) (setq dist 400) (setq Area BR) (setq yline 21900) (setq ylineDist 400) (defun c:QW () (setq cmde (getvar "cmdecho")) (setvar "cmdecho" 0) (setq osmode (getvar "osmode")) (setq oldlayer (getvar "CLAYER")) (setvar "osmode" 0) ;(initget "BL CP GL FA FB ML P PL SP ST TL WC WD ") ;(setq Mat1 (getkword "\n [bL/CP/GL/FA/FB/ML/P/PL/SP/ST/TL/WC/WD]<ML>: ")) ;(initget "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20") ;(setq Num1 (getkword "\n [01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20]: ")) (initget "ML WC WD ") (setq Mat1 (getkword "\n [ML/WC/WD]<ML>: ")) (initget "01 02 03") (setq Num1 (getkword "\n [01/02/03]: ")) (setq Mat1Num1 (strcat Mat1 Num1)) ;(initget "BL CP GL FA FB ML P PL SP ST TL WC WD ") ;(setq Mat2 (getkword "\n [bL/CP/GL/FA/FB/ML/P/PL/SP/ST/TL/WC/WD]<ML>: ")) ;(initget "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20") ;(setq Num2 (getkword "\n [01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20]: ")) ;(setq Mat2Num2 (strcat Mat2 Num2)) (initget "ML WC WD ") (setq Mat2 (getkword "\n [ML/WC/WD]<ML>: ")) (initget "01 02 03") (setq Num2 (getkword "\n [01/02/03]: ")) (setq Mat2Num2 (strcat Mat2 Num2)) (setq pt1 (getpoint "\nEnter first point:")) (setvar "osmode" osmode) (setq pt2 (getpoint "\nEnter sceond point:")) (setq pt1B (car pt1)) (setq pt1C (list pt1B yline)) (setq pt1D (list (+ (car pt1c) (* '2 dist)) yline)) (setq pt2B (car pt2)) (setq pt2C (list pt2B (+ yline ylineDist))) (setq pt2D (list (+ (car pt1c) (* '2 dist)) (+ yline ylineDist))) (setvar "osmode" 0) (Command "-layer" "make" "LEGEND" "c" 4 "" "") (command "Qleader" pt1 pt1c pt1d Mat1Num1 pt1d "" "" "") (command "Qleader" pt2 pt2c pt2d Mat2Num2 pt2d "" "" "") (setvar "cmdecho" cmde) (setvar "osmode" osmode) (setvar "CLAYER" oldlayer) (princ) ) SemiAutoLebeling.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 13, 2017 Share Posted November 13, 2017 2 suggestions osmode use oldsnap etc using a reserved word can cause problems. I am pretty sure Grr did a real nice matrix dcl that would work nicely with your long initget I think I downloaded it for future reference, I think its better way picking from dcl's rather than having to read command line. Quote Link to comment Share on other sites More sharing options...
leong1221 Posted November 13, 2017 Author Share Posted November 13, 2017 Actually Hanhphuc wrote something to help shorter the long initget in another post (see below), but I am still waiting for reply how to combine his to mine as I need the Input-Value of Mat1 and Num1 (see above lisp) to change the attribute block Tag1 & Tag2 value. I am reading Lee's functions about attribute but dont know which one to use (defun c:test (/ l i s mat1 Num1) (setq i 1 l '("BL" "CP" "GL" "FA" "FB" "ML" "P" "PL" "SP" "ST" "TL" "WC" "WD") ) (repeat (length l) (setq s (cons (strcat (itoa i) "_" (nth (1- i) l) " / ") s)) (setq i (1+ i)) ) (initget 7) (if (and (setq i (getint (strcat "\nIndex number [" (apply 'strcat (reverse s)) "]? : " ) ) ) (<= i (length l)) (setq mat1 (nth (1- i) l)) (progn (initget 7) (setq i (getint "Enter number 1~20 ? : ")) (setq Num1 (itoa i)) (<= i 20) ) ) (princ (strcat Mat1 (if (< i 10) (strcat "0" Num1) Num1 ) ) ) (princ "\nInvalid Input.. ") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 14, 2017 Share Posted November 14, 2017 Grrr was I right about the matrix dcl ? I can not find it can you post a link. 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.