update the 2nd titleblock with the data from the 1st..
update the 2nd titleblock with the data from the 1st..
(OP)
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???
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???





RE: update the 2nd titleblock with the data from the 1st..
;------------------------------------------------------------------------------
;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
((/= "INSERT" (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
(= "ATTRIB"
(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...
(= "ATTRIB"
(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 "\nType Match_Atts to begin")
"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford
RE: update the 2nd titleblock with the data from the 1st..
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.
RE: update the 2nd titleblock with the data from the 1st..
BU
"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford