Scripting Question?

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
dodaykos
Newbie Member
Posts: 4
Joined: Wed May 29, 2013 4:21 pm

Scripting Question?

Post by dodaykos » Mon Jul 01, 2013 8:00 pm

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?

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Re: Scripting Question?

Post by hungerburg » Tue Jul 02, 2013 12:02 pm

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();

dodaykos
Newbie Member
Posts: 4
Joined: Wed May 29, 2013 4:21 pm

Re: Scripting Question?

Post by dodaykos » Wed Jul 03, 2013 3:39 pm

Aha! Much thanks, hungerburg! :D

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”