Change Attribute Value by known TAG name

Change Attribute Value by known TAG name

RockyBrown4134
Collaborator Collaborator
1,726 Views
3 Replies
Message 1 of 4

Change Attribute Value by known TAG name

RockyBrown4134
Collaborator
Collaborator

I need some help please with a small routine. 

I have a block that has attributes in it called Titleblock_2020. I have a LISP program that we use to insert the title block with default settings. There is one setting I need to have changed based on its Attribute Tag. Manually, its easy to do with ATTEDIT. Sometimes it gets changed, sometimes it doesn't. I wanted to automate it. I have tried several ways but I cant find the easiest way. I may be overlooking something, or I may be over thinking it as well. 

 

Block name: Titleblock_2020

Attribute Tag: ENG_GROUP

Variables:

TBNAME  =  Block Name

DIVNAME  = Company Division Name

 

I set the DIVNAMEariables in my code.

 

(setq TBNAME "Titleblock_2020")
(setq DIVNAME "GENERAL ENGINEERING")

 

Then I tried to edit the attribute.

(command "._attedit" "y" TBNAME "ENG_GROUP" DIVNAME)

 

This is where I get stuck. Any and all suggestions are welcome.

Thanks.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Accepted solutions (1)
1,727 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

Since AutoCAD 2012, you can use the  setpropertyvalue function which considers the tag of the attribute as a property of the block reference.

(setpropertyvalue blockEname "ENG_GROUP" "GENERAL ENGINEERING")

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4

RockyBrown4134
Collaborator
Collaborator

Thanks. I knew it had to be something simple. 

Ok. I added the code, however I get an error. Am I misunderstanding something? blockEname?? 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 4 of 4

RockyBrown4134
Collaborator
Collaborator

Never mind. Stupid me. I answered my own question. I forgot to set the entity name. 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes