edit entities in the block table

edit entities in the block table

Anonymous
Not applicable
1,582 Views
5 Replies
Message 1 of 6

edit entities in the block table

Anonymous
Not applicable

Hello

 

Ihave this little routine

 

The changes for the layer work fine, but the changes for the values of the ATTDEF not.

 

The values will not updated on the screen (when I close and open the drawing it is not updated too). When I explode the block, the attribs have the new value!

 

How can I update the block on the screen.

 

(defun c:edit-block-entities ()

  	(setq lst (list))
  	(setq ent (car (entsel)))
  	(setq entList (entget ent))
  	(setq BlockName (cdr (assoc 2 entList)))
  	
	(if (setq ent (tblobjname "block" BlockName)); get the BLOCK entity

		(while (setq ent (entnext ent)); Step through the entities in the block definition
			(setq entList (entget ent))
                  	(prompt (strcat "\nEntity: " (cdr (assoc 0 entList))))
                  	(if (= (cdr (assoc 0 entList)) "ATTDEF") (progn ;funktioniert nicht mit Attribs
				(prompt (strcat "\nATTDEF: " (cdr (assoc 2 entList)) "-" (cdr (assoc 3 entList)) "---" (cdr (assoc 1 entList))))
                          	(setq entList (subst (cons 1 "aaa") (assoc 1 entList) entList))
                          	(entmod entlist)
                        ))

		  	(if (= (cdr (assoc 0 entList)) "LINE") (progn
				(prompt (strcat "\nLINE: " "---" (cdr (assoc 8 entList))))
                          	(setq entList (subst (cons 8 "6-2") (assoc 8 entList) entList))
                          	(entmod entlist)
                        ))

			(setq lst (cons ent lst)); Construct a list of the block components
		)
	)
  	(command "_attsync" "n" BlockName)
  	(entupd (tblobjname "block" BlockName))
  	(command "_regen")
    	(reverse lst) ;; Return the list
)
0 Likes
Accepted solutions (1)
1,583 Views
5 Replies
Replies (5)
Message 2 of 6

Shneuph
Collaborator
Collaborator
Accepted solution

I think this is standards behavior.  If you have an attribute Block in a drawing each BlockRef object has it's own attribute value (all may be the default value).  Then if you edit the Block definition so that the attribute has a different default value the attribute of each BlockRef retains whatever value it was already set to.

 

You'll have to cycle through each BlockRef to change the individual attribute values.  Updating the default attribute in the block definition does nothing for the BlockRefs already inserted in the drawing.

 

This is how it works with the attribute settings I typically use.  Perhaps if their values are "locked", or if some other attribute property is changed, they may behave differently.

 

Hope this helps.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 6

Anonymous
Not applicable

OK, I see

 

Thank you.

 

 

But why the color of the lines will be changed in the BlockRef when I change the color in the block definition?

0 Likes
Message 4 of 6

Shneuph
Collaborator
Collaborator

Just about everything in a block ref will change if you change the definition, which is the point of a block really.  If you want blockrefs that are going to ALWAYS have the same text in them no matter what you can just put a mtext in the block definition.  Attributes are special though, they have a default value but you are able to change them on each BlockRef.  This is used for detail callouts, keynote tags etc. etc etc.  (see screencast)

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 5 of 6

dbroad
Mentor
Mentor

To add to what @Shneuph said, attribute data is part of the extended block reference package that includes the block, attribute entities for each attribute definition, and a seqend item.  There is also another special structure for dynamic block references when the attribute is in a locked position.  If you want to change the attribute values of block references to default values, the most convenient method I have found is to use the properties palette.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 6

JustoAg
Contributor
Contributor

Hi,

See this as a starting point.

 

Justo Aguiar

0 Likes