Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

update the 2nd titleblock with the data from the 1st..

Status
Not open for further replies.

R12NV

Civil/Environmental
Sep 4, 2002
54
Is it possiable to replace an attributed block with the same block, and get the attributed data to carry over to the new block.

Example:
I have a attributed title block, and a revised attributed title block both have the same attribute tags etc. but the second one has a few more that the first dosnt have.

So i want to update the 2nd titleblock with the data from the 1st.

is there a simple autocad comand???
 
Replies continue below

Recommended for you

This should do it...

;------------------------------------------------------------------------------
;MATCH_ATTS: From user selection, pick block with atts and all matching
; tags from target block will match its atts to the source
;Dependencies: ATT_READ
; ATT_UPD
;No error handling!
;------------------------------------------------------------------------------
(defun C:MATCH_ATTS (/ SRC_BLK TRGT_BLK)
(setq SRC_BLK (entsel "\nSelect Source Block."))
(princ "\n")
(setq TRGT_BLK (entsel "\nSelect Target Block."))
(setq ATT_LIST (ATT_READ (car SRC_BLK))
TRGT_ENT (car TRGT_BLK))
(setq SUCCESS (ATT_UPD TRGT_ENT ATT_LIST))
(princ)
)
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
; ATT_READ: given an eref to a block, return a dotted pair list of attr. tag
; names and attr. values.
;
; - syntax: (att_read <eref>) -> ((<att tag>.<att data>) (etc.)...)
;
; - no library dependencies
; - returns nil if an error condition is detected.
;------------------------------------------------------------------------------
(defun ATT_READ (EREF / ENT_DATA ATT_LIST)
(setq ENT_DATA (entget EREF)) ; passing a nil eref parameter will cause a crash
(cond
((/= &quot;INSERT&quot; (cdr (assoc 0 ENT_DATA))) NIL) ;not a block
((= NIL (entnext EREF)) NIL) ;no entities following
((/= 1 (cdr (assoc 66 ENT_DATA))) NIL) ;no attributes following
(t
(while ; step through all the attributes
(= &quot;ATTRIB&quot;
(cdr (assoc 0 (setq ENT_DATA (entget (entnext (cdr (assoc -1 ENT_DATA)))))))
)
(setq
ATT_LIST
(cons
(cons
(cdr (assoc 2 ENT_DATA)) ; att tag
(cdr (assoc 1 ENT_DATA)) ; att data
)
ATT_LIST
)
)
)
ATT_LIST ; return value
)
)
)
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
; ATT_UPD: Update the attributes of a block given by the eref according to the
; information in the <att_list>.
;
; - syntax: (att_upd <eref> <att_list>) -> T/nil
; - returns nil if an error is detected, T otherwise
; - <att_list> is a list with format: ( (<att tag>.<att data>) (etc.)...)
;
; Note: no error occurs if the block's attributes don't match those in the
; <att_list>. Data is transferred between all matching attribute
; tag names - if there's a mismatch the program doesn't mind at all,
; but no data transfer will occur for that particular item.
;
; - no library dependencies
;------------------------------------------------------------------------------
(defun ATT_UPD (BLOCK_REF ATT_LST / ENT_DATA)
; if the block_ref parameter is not an eref to a block insertion, the
; program will crash
(cond
((= NIL (entnext BLOCK_REF)) NIL) ;no entities following
((/= 1 (cdr (assoc 66 (setq ENT_DATA (entget BLOCK_REF))))) NIL) ; no attributes
(t
(while ; cycle through all attributes...
(= &quot;ATTRIB&quot;
(cdr (assoc 0 (setq ENT_DATA (entget (entnext (cdr (assoc -1 ENT_DATA)))))))
)
(setq ATT_TAG (cdr (assoc 2 ENT_DATA)))
(cond
((setq NEW_ATT (assoc ATT_TAG ATT_LST)) ;mismatch filtering...
(entmod
(subst
(cons 1 (cdr NEW_ATT))
(assoc 1 ENT_DATA)
ENT_DATA
)
)
)
)
)
(entupd BLOCK_REF) ; regen the block
t
)
)
)
;------------------------------------------------------------------------------
(princ)
(princ &quot;\nType Match_Atts to begin&quot;)

&quot;Whether you think that you can, or that you can't, you are usually right &quot;
.. Henry Ford
 
This is what I was looking for only I cant get the command to work.
This is what i get:

Command: MATCH_ATTS
Select Source Block.

Select Target Block.
no function definition: ATT_READ

Any suggestions as to what is wrong. Please help.
 
Make sure that the entire 3 functions (defuns) are included in the one lisp file.

BU

&quot;Whether you think that you can, or that you can't, you are usually right &quot;
.. Henry Ford
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor