Prompt to change the attribute of a block

Prompt to change the attribute of a block

Antonin_JubaultSRF25
Participant Participant
362 Views
3 Replies
Message 1 of 4

Prompt to change the attribute of a block

Antonin_JubaultSRF25
Participant
Participant

I have a TAG attribute in my block. I want to dynamically change it through a prompt. I don't want to see the EDIT attribute pop-up page. I'd like to select the block, edit attribute, precise attribute name and the new value. All within the prompt so I can call it through the Autocad Javascript api.

 

If you have it directly through a Javascript function and I do not see it, I would love to learn !

 

https://help.autodesk.com/view/OARX/2025/ENU/?guid=adsk_jsref_javascript_reference_guide

0 Likes
363 Views
3 Replies
Replies (3)
Message 2 of 4

Antonin_JubaultSRF25
Participant
Participant

Please find a CAD block as an example

0 Likes
Message 3 of 4

norman.yuan
Mentor
Mentor

I am not sure I understand what you want to do:

 

a. You want to set an attribute's value using code (be it JavaScript, or VBA, or LISP, or .NET API, it does not matter here), meaning your code find the target block reference and then the attribute of the block reference, based on its tag? In this case, the change is made by the code, not the attribute edit command (or user double-clicks the attribute to trigger the editing), thus, no attribute editing dialog box pops up.

 

2. When you say "...I'd like to select the block..", if that means the user selects the block reference->attribute to start editing, the editing dialog box may or may not pops up, depending on the system variable "ATTDIA" with value 0 - prompt at command line and 1 - show editing dialog box. The default value is 1. So, if you want to script the attribute editing, simply let your scripting code to set "ATTDIA" to 0.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 4

Antonin_JubaultSRF25
Participant
Participant

Hello Norman,

 

You are right, I am not really clear here.

 

I am using Javascript Autocad API to insert multiple instances of a same block on the Model.

My block has a "TAG" attribute which I want to increment at each inseration. Like the first one would be Attribute TAG = "TV-001" and the next one be "TV-002".

By default, the TAG attribute is empty in my block.

 

Right now, to insert blocks I am using Acad.Editor.executeCommand(-PROMPT COMMAND-) which simulates the prompt.

My guess is that I could do the same to edit the latest inserted block attribute value of "TAG".

 

But if you have any other idea using Javascript API directly, I would be very interested as well !

 

Thank you for the quick answer.

 

Regards,

 

AJ

0 Likes