HI,
Would you please tell me how to get read/write a block attribute ?
Thank you
Michał
ECMAScript block attributes access
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Newbie Member
- Posts: 7
- Joined: Sun Nov 29, 2020 6:32 pm
- Location: Poland
-
- Premier Member
- Posts: 4879
- Joined: Wed Sep 27, 2017 4:17 pm
Re: ECMAScript block attributes access
Hi,
With an RDocument reference in doc, all entity ID's of the type EntityAttribute:
Or all entity ID's of the type EntityBlockRefAttr:
In some way you need to filter on the intended attribute with querying the attributes themselves by id.
The RAttributeEntity has several methods including reading/writing the tag content, the plain text and so on.
See reference
The parent Block Reference id can be retrieved by a method of the REntity class: attrib.getParentId()
See reference
Then:
On any change you have to cast the entity back to the document (With an RDocumentInterface reference in di):
If this doesn't answer your question then please provide some code where a known RAttributeEntity must be read or written.
Or a drawing with block attributes and what to select to alter.
Regards,
CVH
With an RDocument reference in doc, all entity ID's of the type EntityAttribute:
Code: Select all
var attribIds = doc.queryAllEntities(false, false, RS.EntityAttribute);
Code: Select all
var attribIds = doc.queryAllEntities(false, false, RS.EntityBlockRefAttr);
Code: Select all
var attrib = doc.queryEntity(id);
See reference
The parent Block Reference id can be retrieved by a method of the REntity class: attrib.getParentId()
See reference
Then:
On any change you have to cast the entity back to the document (With an RDocumentInterface reference in di):
Code: Select all
var op = new RAddObjectOperation(attrib);
di.applyOperation(op);
Or a drawing with block attributes and what to select to alter.
Regards,
CVH
-
- Newbie Member
- Posts: 7
- Joined: Sun Nov 29, 2020 6:32 pm
- Location: Poland
Re: ECMAScript block attributes access
Hi,
Thank you for your thorough answer. I'll try it out.
Michał
Thank you for your thorough answer. I'll try it out.
Michał