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
Create block in existing layer
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Re: Create block in existing layer
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:
QCAD will still use the current block and attributes in this case since they have not been set explicitly.
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);