RAddObjectsOperation

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

Moderator: andrew

Post Reply
pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

RAddObjectsOperation

Post by pmbrull » Fri Sep 28, 2018 11:12 am

Hello and thank you for your time,

When using RAddObjectOperation, is it possible to also change the REntity properties?

What I am trying to achieve is:

Code: Select all

var hatch = new RHatchEntity(document, hatchData);
hatch.setColor(new RColor(0, 0, 255, 1));
hatch.setLayerId(MyLayerId);

var op = new RAddObjectOperation(hatch, true, true);
di.applyOperation(op);
However, the object that gets added still keeps the default properties of belonging to layer 0 and being colored by layer.

Thank you,
Pere

User avatar
andrew
Site Admin
Posts: 5604
Joined: Fri Mar 30, 2007 6:07 am

Re: RAddObjectsOperation

Post by andrew » Fri Sep 28, 2018 11:22 am

pmbrull wrote:
Fri Sep 28, 2018 11:12 am

Code: Select all

var op = new RAddObjectOperation(hatch, true, true);
The second argument of the constructor means "useCurrentAttributes", i.e. ignore the attributes assigned to the entity and use the current attributes. This is also the default, so you need to change this to false to keep the attributes assigned to your entity:

Code: Select all

var op = new RAddObjectOperation(hatch, false);

pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Re: RAddObjectsOperation

Post by pmbrull » Fri Sep 28, 2018 11:38 am

Works like a charm,
Thanks :)

Post Reply

Return to “QCAD Developers and Contributors”