Jump to content
leong1221

insert an attribute block and rename the tags

Recommended Posts

leong1221

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

Share this post


Link to post
Share on other sites
Lee Mac

Are you sure you mean 'rename the tags'? Or do you mean populate the attribute values?

Share this post


Link to post
Share on other sites
leong1221
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:

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
leong1221

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.8)

 


;;;;;;;;;;;;;;;;;;;;;;;;;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

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites
leong1221

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)

)

Share this post


Link to post
Share on other sites
BIGAL

Grrr was I right about the matrix dcl ? I can not find it can you post a link.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×