+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default insert an attribute block and rename the tags

    Registered forum members do not see this ad.

    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

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,350

    Default

    Are you sure you mean 'rename the tags'? Or do you mean populate the attribute values?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Quote Originally Posted by Lee Mac View Post
    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

    Yes. I need to change the Tag value, not the name of the tag

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    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.
    A man who never made mistakes never made anything

  5. #5
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    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.

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;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)
      )
    Attached Files

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    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.
    A man who never made mistakes never made anything

  7. #7
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    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

    Code:
    (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)
    
    )

  8. #8
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    Registered forum members do not see this ad.

    Grrr was I right about the matrix dcl ? I can not find it can you post a link.
    A man who never made mistakes never made anything

Similar Threads

  1. unhide/reveal block Attribute tags that has no text value?
    By tive29 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 8
    Last Post: 11th Jan 2017, 01:18 pm
  2. insert block and make the force autocad updating TAGS
    By rodrigo_sjc_sp in forum AutoLISP, Visual LISP & DCL
    Replies: 25
    Last Post: 24th Oct 2013, 12:49 pm
  3. insert block with tags (attributes)
    By rodrigo_sjc_sp in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 13th Aug 2013, 07:04 pm
  4. layout tab rename with block attribute value
    By super_troy in forum AutoLISP, Visual LISP & DCL
    Replies: 19
    Last Post: 4th Nov 2011, 08:05 pm
  5. Text Values from Attribute Tags from Exploded Block Inserts?.
    By muck in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 12th Oct 2007, 03:53 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts