Text Fields unlinking from Dynamic Block when adding new attributes to the block

Text Fields unlinking from Dynamic Block when adding new attributes to the block

Anonymous
Not applicable
1,356 Views
12 Replies
Message 1 of 13

Text Fields unlinking from Dynamic Block when adding new attributes to the block

Anonymous
Not applicable

I created a block (picture attached) added attributes to it and then linked those attributes to a few text fields (picture attached). I needed to add a few new attributes to the block. So i opened the block and defined two new attributes. saved the block and then closed it. I clicked manage attributes and synced the new attributes I added and they updated and showed on the drawing (picture not attached, only able to attached three pictures). They I regened the drawing and all the text fields unlinked (picture attached).

Any idea why this happened and how to fix it? I'd hate to have to link every text field again. That is so time consuming.

0 Likes
1,357 Views
12 Replies
Replies (12)
Message 2 of 13

Libbya
Mentor
Mentor

A posted file is worth 1,000 posted images.  Post the file.  

0 Likes
Message 3 of 13

Anonymous
Not applicable

I attached a file of both, pre and post attribute update issue.

0 Likes
Message 4 of 13

Libbya
Mentor
Mentor

I don't see a way to update the block without losing all the existing fields.  In the 'unupdated' version, if you run ATTSYNC before any other changes, the links are all lost and ATTSYNC must be used to add attributes to the block.  

0 Likes
Message 5 of 13

Anonymous
Not applicable

Is it just me, or doesn't it seem ridiculous that if I add anything to my block it un-syncs all the text fields? I didn't change any of the previous attributes that were linked. 

0 Likes
Message 6 of 13

MMcCall402
Mentor
Mentor

All I can think of is to not run ATTSYNC after adding the new attribute, insert the block again based on the updated block definition and run a lisp to match the attribute values from the old inserted block to the new one.

 

Lisp below.

 

;; matchblocks.lsp
;;
;;
(princ "\nType MB to Run")
(defun C:MB (/)
(setq baselist (list))
(setq ename (car (entsel "\nSelect Base Block:")))
(while (= ename nil)
(princ "\nNothing Picked")
(setq ename (car (entsel "\nSelect Base Block:")))
);end while
(setq ename1 (car (entsel "\nSelect Block To Apply Changes:")))
(while (= ename1 nil)
(princ "\nNothing Picked")
(setq ename1 (car (entsel "\nSelect Block To Apply Changes:")))
);end while
(setq ename (entnext ename))
(setq elist (entget ename)) ;the entity list of the base border
(setq etype (cdr (assoc 0 elist))) ;should be attrib
(while (= etype "ATTRIB") ;puts all the attribute in a list
(setq tag (cdr (assoc 2 elist))) ;the attribute tag
(setq val (cdr (assoc 1 elist)));the attribute value
(setq baselist (append (list (list tag val)) baselist));put the attribute in list
(setq ename (entnext ename)) ;move onto the next attribute
(setq elist (entget ename))
(setq etype (cdr (assoc 0 elist)))
);end while
(setq ename1 (entnext ename1)) ;get the next entity, should be "ATTRIB"
(setq elist1 (entget ename1)) ;the entity list of the border
(setq etype1 (cdr (assoc 0 elist1))) ;should be attrib
(while (= etype1 "ATTRIB")
(setq attval nil)
(setq tag (cdr (assoc 2 elist1)));the attribute tag
(foreach item baselist
(if (= tag (nth 0 item))
(progn
(setq attval (nth 1 item))
);end then
(progn);else do nothing go to next in list till tag matches
);end if
);end foreach
(if (/= attval nil)
(progn (setq elist1 (subst (cons 1 attval) (assoc 1 elist1) elist1))
(entmod elist1));end then
(progn);end else
);end if
(setq ename1 (entnext ename1)) ;move onto the next attribute
(setq elist1 (entget ename1))
(setq etype1 (cdr (assoc 0 elist1)))
);end while
(command "REGEN")
);end defun
(princ)

Mark Mccall 
CAD Mangler


EESignature


VHB - Engineering, Inc.

Message 7 of 13

Libbya
Mentor
Mentor

@Anonymous wrote:

Is it just me, or doesn't it seem ridiculous that if I add anything to my block it un-syncs all the text fields? I didn't change any of the previous attributes that were linked. 



To be clear, editing a block and adding attributes does not unlink fields that are referencing attributes in that block.  You must have done something to edit the block definition even on the 'unupdated' version prior to saving it.  That version already has busted links, they just don't show up until you do an attsync and a regen.  

0 Likes
Message 8 of 13

Libbya
Mentor
Mentor

@MMcCall402 wrote:

All I can think of is to not run ATTSYNC after adding the new attribute, insert the block again based on the updated block definition and run a lisp to match the attribute values from the old inserted block to the new one.

 

 


I don't see how that would possibly work.  The file uses a bunch of object fields within mtext referencing attributes within the block.  If you replace the block, the links will definitely all be broken.  

0 Likes
Message 9 of 13

MMcCall402
Mentor
Mentor

I may have misread the situation. It appeared like the attribute field values were linked to the mtext after they were inserted into the drawing.  Running ATTSYNC would bring in the new attributes but at the cost of resetting all the attribute values back to their original values.  Inserting a new block would use the current block definition with the new attributes.  The lisp would transfer the edited attribute values from the old inserted block to the new one.

Mark Mccall 
CAD Mangler


EESignature


VHB - Engineering, Inc.

0 Likes
Message 10 of 13

Libbya
Mentor
Mentor

Yeah, the opposite is the case.  The mtext contains the fields referencing the attribute values, not the attribute values containing fields referencing mtext.  

 

FWIW, ATTSYNC does not reset existing attribute values back to their default.

 

I believe that the broken fields are a result of having multiple attributes with the same tag in the block.  When attsync is run in that situation, all links are broken.  All tags should be unique and it is no surprise that it causes issues.  See the following screencast.  In it you can clearly see that I link an mtext field to a block attribute.  I then edit the attribute and update the field - works fine.  I then run attsync -field still works fine.  I then add another attribute with a unique tag, run attsync - mtext field still works fine.  Edit linked attribute value - field still works.  Add a couple attributes that have the same tag - BROKEN LINK!  

 

It's just another of the many stories with the same moral - ALWAYS use unique tags for each attributes.  

 

 

0 Likes
Message 11 of 13

Anonymous
Not applicable
The tags with same names might be the issue. I'll test it out. This block
was created a while ago by another employee. I'm just trying to update the
file to new standards.

0 Likes
Message 12 of 13

Libbya
Mentor
Mentor

You should always use unique tags, but editing the attribute tags to all be unique at this point will not remedy the broken links.  I do not believe there is a remedy for the current file other than relinking each field.  I would make all tags unique first, though, so adding attributes in the future does not break all the links again.  

0 Likes
Message 13 of 13

Anonymous
Not applicable
Thanks for the info. The ones I personally created are all unique so I
should run into that issue. It looks like I just need to put my head down
and update all the fields. Fun time await!

0 Likes