Create block in existing layer

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
User avatar
dfriasb
Senior Member
Posts: 119
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Create block in existing layer

Post by dfriasb » Tue Aug 08, 2017 4:32 pm

I'm trying to modify the Block command so that blocks will be created always in some specific layer.

I didn't see the way to do it using existing commands, so I was tracing 2 different script strategies:

OPTION 1:
1.1.- Create Block
1.2.- Set Selection to Layer "0b"

or ...

OPTION 2:
2.1.- Get Current Layer ID
2.2.- Set Current Layer to "0b"
2.3.- Create Block
2.4.- Set Current Layer to previous

I don't know how to script moving selection to an existing layer (step 1.2). Any help?

Thank you. Best regards,

David
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

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

Re: Create block in existing layer

Post by andrew » Tue Aug 08, 2017 8:18 pm

When creating a block reference, presumably, you add it to an RAddObjectsOperation. By default, QCAD adds the entity to the current layer and current block with the current attributes (color, line weight, line type).

However, you can also tell QCAD explicitly not to use the current layer by passing false as the second argument in addObject:

Code: Select all

entity = new RBlockReferenceEntity(...);
entity.setLayerId(...);
operation.addObject(entity, false);
QCAD will still use the current block and attributes in this case since they have not been set explicitly.

Post Reply

Return to “QCAD 'How Do I' Questions”