Where are QCAD scripts?

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
Post one question per topic.
Post Reply
User avatar
dfriasb
Full Member
Posts: 90
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Where are QCAD scripts?

Post by dfriasb » Sat Dec 22, 2018 4:43 pm

Dear all,

I'm looking for js scripts regarding to QCAD commands, like "line", "arc", etc... I older versions they were inside /opt/qcad-3.21.3-pro-linux-x86_64/scripts but not now. I read readme.txt but I can't find them on the web neither.

Thank you for your help. Best regards,

David
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Re: Where are QCAD scripts?

Post by woddy » Tue Dec 25, 2018 1:30 pm

Hey,

You can reach them from github https://github.com/qcad/qcad/tree/master/scripts. On the newer versions of Qcad they are compiled as plugin for faster load and less disk space as far as i know.

User avatar
dfriasb
Full Member
Posts: 90
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Where are QCAD scripts?

Post by dfriasb » Fri Jan 25, 2019 4:58 pm

Hello,

I cannot find "Make all White Layers Black" script. I think it should be inside https://github.com/qcad/qcad/tree/master/scripts/Misc but it's not.
Can I find this script elsewhere? I would like to use it to create a new one to convert ALL layers into black.

Thank you!
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

User avatar
andrew
Site Admin
Posts: 6158
Joined: Fri Mar 30, 2007 6:07 am

Re: Where are QCAD scripts?

Post by andrew » Fri Jan 25, 2019 9:42 pm

It's part of the Pro add-on. Here's the (simplified) source of that script:

Code: Select all

include("scripts/EAction.js");

function LayerWhiteToBlack(guiAction) {
    EAction.call(this, guiAction);
}

LayerWhiteToBlack.prototype = new EAction();

LayerWhiteToBlack.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);

    var di = this.getDocumentInterface();
    var document = this.getDocument();

    var op = new RModifyObjectsOperation();

    var layerIds = document.queryAllLayers();
    for (var i=0; i<layerIds.length; i++) {
        var layerId = layerIds[i];
        var layer = document.queryLayer(layerId);

        if (layer.getColor().name().toLowerCase()==="#ffffff") {
            layer.setColor(new RColor("#000000"));
            op.addObject(layer);
        }
    }

    di.applyOperation(op);

    this.terminate();
};

LayerWhiteToBlack.init = function(basePath) {
    var action = new RGuiAction(qsTr("Make all White Layers Black"), RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setScriptFile(basePath + "/LayerWhiteToBlack.js");
    action.setGroupSortOrder(78100);
    action.setSortOrder(200);
    action.setWidgetNames(["MiscLayerMenu", "MiscLayerToolBar", "MiscLayerToolsPanel"]);
};

User avatar
dfriasb
Full Member
Posts: 90
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Where are QCAD scripts?

Post by dfriasb » Tue Feb 12, 2019 9:21 pm

Hi again,

I can't find "Flatten Drawing to 2D" script neither. I'ld like to make a script to flat all entities inside blocks.
As I tested now this script is not working inside blocks.

Thanks! Best regards, David.
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

User avatar
andrew
Site Admin
Posts: 6158
Joined: Fri Mar 30, 2007 6:07 am

Re: Where are QCAD scripts?

Post by andrew » Tue Feb 12, 2019 9:26 pm

The tool "Flatten Drawing to 2D" removes Z coordinates for all entities in all blocks.

User avatar
dfriasb
Full Member
Posts: 90
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Where are QCAD scripts?

Post by dfriasb » Tue Feb 12, 2019 10:47 pm

It's not working with viewports, at least with tem inside layout blocks. Here I attach screenshots and drawing file. I'm running Linux Ubuntu, 18.04 QCAD Pro.
Attachments
Cos23EstrPart1v2.dwg
(858.9 KiB) Downloaded 34 times
Screenshot from 2019-02-12 22-39-54.png
Screenshot from 2019-02-12 22-39-54.png (114.84 KiB) Viewed 923 times
Screenshot from 2019-02-12 22-44-22.png
Screenshot from 2019-02-12 22-44-22.png (93.78 KiB) Viewed 923 times
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

User avatar
andrew
Site Admin
Posts: 6158
Joined: Fri Mar 30, 2007 6:07 am

Re: Where are QCAD scripts?

Post by andrew » Wed Feb 13, 2019 9:56 am

dfriasb wrote:
Tue Feb 12, 2019 10:47 pm
It's not working with viewports
I can confirm that the viewport view target property is currently not affected by this operation. This will be implemented in a future version.

User avatar
dfriasb
Full Member
Posts: 90
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Where are QCAD scripts?

Post by dfriasb » Wed Feb 13, 2019 11:01 am

Meanwhile, can you send me flatten script so I can try to fix this by myself? Thanks again!!

David
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

User avatar
andrew
Site Admin
Posts: 6158
Joined: Fri Mar 30, 2007 6:07 am

Re: Where are QCAD scripts?

Post by andrew » Thu Feb 14, 2019 3:41 pm

Sure.. it will likely not help you a lot though, since to2D currently does nothing for RViewportEntity objects. You'd have to do additional checks and set additional properties for viewport entities.

Code: Select all

function Flatten(guiAction) {
    EAction.call(this, guiAction);
}

Flatten.prototype = new EAction();

Flatten.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);
    Flatten.flatten(this.getDocumentInterface(), this.getToolTitle());
    this.terminate();
}

Flatten.flatten = function(documentInterface, title) {
    var doc = documentInterface.getDocument();

    var op = new RAddObjectsOperation();
    op.setText(title);
    op.setAllowAll(true);
    op.setAllowInvisible(true);

    var ids = doc.queryAllEntities(false, true);
    for (var i=0; i<ids.length; i++) {
        var id = ids[i];

        var e = doc.queryEntity(id);
        e.to2D();

        op.addObject(e, false);
    }
    documentInterface.applyOperation(op);
};

Post Reply

Return to “QCAD 'How Do I' Questions”