Scripting Question?

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Scripting Question?

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

Re: Scripting Question?

Postby 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();
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

Re: Scripting Question?

Postby dodaykos » Wed Jul 03, 2013 3:39 pm

Aha! Much thanks, hungerburg! :D
dodaykos
Newbie Member
 
Posts: 4
Joined: Wed May 29, 2013 4:21 pm


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron