How can I use the "Clip to Rectangle" feature (https://qcad.org/doc/qcad/latest/refere ... le_en.html) in a script?
Alternatively, the dwg2maptiles cli tool would be very close to what I want to implement. Is the source code available somewhere?
Thanks,
Alex
EDIT: QCAD Pro 3.23.0.0 (3.23.0)
How can I use "Clip to Rectangle" in a script
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.
-
- Newbie Member
- Posts: 4
- Joined: Tue Oct 15, 2019 1:55 pm
Re: How can I use "Clip to Rectangle" in a script
To use the clip tool from script, you'd have to create the tool action, set the variables that are usually set interactively and then get the operation and run it. You can try all this in the QCAD script shell (Misc > Development > Script Shell). Make sure that there are entities in that area and that they are selected.
Code: Select all
// include tool:
include("scripts/Pro/Modify/ClipToRectangle/ClipToRectangle.js");
var di = getDocumentInterface();
// create and initialize tool:
var a = new ClipToRectangle();
a.setDocumentInterface(di);
a.corner1 = new RVector(10,10);
a.corner2 = new RVector(100,20);
a.mode = ClipToRectangle.Mode.Clip; // or Clear or Cut
// run operation on current document:
var op = a.getOperation(false);
di.applyOperation(op);
-
- Newbie Member
- Posts: 4
- Joined: Tue Oct 15, 2019 1:55 pm
Re: How can I use "Clip to Rectangle" in a script
Thanks. This works excellent.