Copy blocks

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
RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Copy blocks

Post by RR88 » Sat Jun 02, 2018 5:09 pm

Hello.

I have a set of block reference entities and they all have the same referenced block id. How could I copy the block, so that every block reference holds a copy of the original block? I tried this:

Code: Select all

var a = doc.queryEntity(62);
var b = a.getReferencedBlockId();
var c = doc.queryBlock(b);
var d = c.clone();
d.setName('Test');

var op = new RAddObjectOperation(d, false);
di.applyOperation(op);
But the last part only changes the name of the block, because the implementation of clone calls the copy constructor of RBlock. The id is still the same and there is no method to change it.
Arch Linux, QCad 3.22.0 Prof.

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Copy blocks

Post by RR88 » Mon Jun 04, 2018 8:36 am

I have done it this way, but there are a lot of lines: https://github.com/zippy84/lc-qcad/blob ... s#L56-L139 :shock:
Arch Linux, QCad 3.22.0 Prof.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”