Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
New Member
MontgomeryRoth
Posts: 2
Registered: ‎12-08-2011
Message 1 of 4 (474 Views)
Accepted Solution

Convert Attribute Tag Into Attribute Value

474 Views, 3 Replies
12-08-2011 01:38 PM

AutoLISP Experience: Minimal

 

Background: Someone exploded an attribute block and copied it hundreds of times throughout a project, each time changing the Attribute Tag to match the Value they expected to appear in their drawing.  The drawing must be xrefed, so the attribute definitions do not appear.

(There is only 1 attribute in the block.)

 

 

Proposed Solutions:

 

1:AutoLISP routine which copies Tag data from Attribute Definition into Value of Attribute Block:

Prompt-Select Attribute Definition

Copy Tag data

Prompt-Select Attribute Block

Paste data into Value

(Allow repeat to speed workflow)(*PREFERRED*)

 

2:AutoLISP routine which copies Tag data from Attribute Definition into Default Value and creates a new Block:

Prompt-Select Attribute Definition

Copy Tag data

Paste data into Default Value

Create New Block

(Select Multiple Objects)(Creates tons of new blocks which are messy)

 

This would help you with the first part of your request ...

 

(defun c:TesT (/ attributeDefinition attent ss i n e)
;; Tharwat 08. Dec. 2011 ;;
(if
(and (setq attributeDefinition
(car
(entsel "\n Select Attribute definition :"
)
)
)
(eq (cdr (assoc 0 (setq attent (entget attributeDefinition))))
"ATTDEF"
)
(progn (prompt "\n Select Attributed Blocks ")
(setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
)
)
(repeat (setq i (sslength ss))
(setq n (entnext (ssname ss (setq i (1- i)))))
(while
(not
(eq (cdr (assoc 0 (setq e (entget n))))
"SEQEND"
)
)
(entmod
(subst (cons 1 (cdr (assoc 2 attent))) (assoc 1 e) e)
)
(setq n (entnext n))
)
)
)
(princ)
)

 

Distinguished Mentor
_Tharwat
Posts: 643
Registered: ‎07-02-2010
Message 2 of 4 (472 Views)

Re: Convert Attribute Tag Into Attribute Value

12-08-2011 01:54 PM in reply to: MontgomeryRoth

This would help you with the first part of your request ...

 

(defun c:TesT (/ attributeDefinition attent ss i n e)
  ;; Tharwat 08. Dec. 2011 ;;
  (if
    (and (setq attributeDefinition
                (car
                  (entsel "\n Select Attribute definition :"
                  )
                )
         )
         (eq (cdr (assoc 0 (setq attent (entget attributeDefinition))))
             "ATTDEF"
         )
         (progn (prompt "\n Select Attributed Blocks ")
                (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
         )
    )
     (repeat (setq i (sslength ss))
       (setq n (entnext (ssname ss (setq i (1- i)))))
       (while
         (not
           (eq (cdr (assoc 0 (setq e (entget n))))
               "SEQEND"
           )
         )
          (entmod
            (subst (cons 1 (cdr (assoc 2 attent))) (assoc 1 e) e)
          )
          (setq n (entnext n))
       )
     )
  )
  (princ)
)

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
New Member
MontgomeryRoth
Posts: 2
Registered: ‎12-08-2011
Message 3 of 4 (458 Views)

Re: Convert Attribute Tag Into Attribute Value

12-08-2011 04:42 PM in reply to: _Tharwat

Thanks so much, this worked great!

You probably cut our repair time down to a quarter of what it would have been or better.

Exactly what we were looking for.

Distinguished Mentor
_Tharwat
Posts: 643
Registered: ‎07-02-2010
Message 4 of 4 (442 Views)

Re: Convert Attribute Tag Into Attribute Value

12-09-2011 01:22 AM in reply to: MontgomeryRoth

MontgomeryRoth wrote:

Thanks so much, this worked great!

You probably cut our repair time down to a quarter of what it would have been or better.

Exactly what we were looking for.


You're welcome . :smileyhappy:

 

I am glad to hear that .

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.