Scripting Question?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Scripting Question?
In my current script, I have managed to successfully insert line and text entities, but I need to be able to add rows of symbols that are located in my library. My question is: how would I go about inserting a .dxf file through code?
- hungerburg
- Premier Member
- Posts: 160
- Joined: Fri May 28, 2010 7:35 pm
Re: Scripting Question?
Below pseudo-code is taken from a utility function of mine.
Code: Select all
var DING = # A reference to the current drawing #
var bPath = "/absolute/path/to/block/drawing.dxf"
var bName = "Name of the Block";
var FAIL = function() { debugger; };
var x = y = 0; // Insert Position
var h = v = false; // Insert Mirror
var bDoc = new RDocument(new RMemoryStorage(), new RSpatialIndexNavel());
var bInt = new RDocumentInterface(bDoc);
if (bInt.importFile(bPath) != RDocumentInterface.IoErrorNoError) {
FAIL("Block missing: " + bPath);
bInt.destroy();
return;
}
var operationP = new RPasteOperation(bDoc);
operationP.setOffset(new RVector(x, y));
operationP.setBlockName(bName);
operationP.setScale(1.0);
operationP.setRotation(0.0);
operationP.setFlipHorizontal(h || false);
operationP.setFlipVertical(v || false);
operationP.setToCurrentLayer(true);
operationP.setOverwriteLayers(false);
operationP.setOverwriteBlocks(false);
DING.documentInterface.applyOperation(operationP);
bInt.destroy();
Re: Scripting Question?
Aha! Much thanks, hungerburg! ![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)