ecma script attribute.setInvisible() is not hidding the attribute

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
ssm2017
Newbie Member
Posts: 8
Joined: Sat Nov 25, 2023 8:26 pm

ecma script attribute.setInvisible() is not hidding the attribute

Post by ssm2017 » Sat Nov 25, 2023 8:44 pm

hello,
using :
Version:
3.28.2.0 (3.28.2)

using ecma script in the script shell.
i get a block attribute in a var called attribute.
i can use : attribute.getTag() or attribute.getPlainText() without issue.
i am not able to hide this attribute using : attribute.setInvisible(true)
the method attribute.isInvisible() is answering true or false but the attribute is not hidden on the drawing.

is it a bug or a wrong use ?

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: ecma script attribute.setInvisible() is not hidding the attribute

Post by CVH » Sat Nov 25, 2023 10:35 pm

You queried an entity from the document, regard it as a clone, and altered some properties.
The properties of the document entity are not affected.
You need to recast that entity back to the document.

Regards,
CVH

ssm2017
Newbie Member
Posts: 8
Joined: Sat Nov 25, 2023 8:26 pm

Re: ecma script attribute.setInvisible() is not hidding the attribute

Post by ssm2017 » Sat Nov 25, 2023 10:59 pm

do you have any example on how to do it please ?

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: ecma script attribute.setInvisible() is not hidding the attribute

Post by CVH » Sat Nov 25, 2023 11:12 pm

You might want to search the forums on the term "RModifyObjectsOperation" for code snippets.

I would step away from the Script Shell at some point and implement Addons.
All QCAD tools are implemented as Addons in ECMAScript, for open source see:
https://github.com/qcad/qcad/tree/master/scripts

Full class descriptions:
https://qcad.org/doc/qcad/3.0/developer/modules.html

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”