Layer Colours issue - looking for a workaround

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
Owen423
Newbie Member
Posts: 3
Joined: Thu Oct 10, 2019 7:54 am

Layer Colours issue - looking for a workaround

Post by Owen423 » Thu Oct 10, 2019 8:07 am

Hi All.

First question on this forum - we have recently bought QCAD pro to replace draftsight.

When we save a DWG from draftsight - the package that we use next in the BIM workflow correctly interprets all remaining lines on all layers as visible (ie. Black, on white, or vice-versa).
When we save a DWG from QCAD, the package that we use, correctly interprets all of the layer colours, and will not show the while lines, on a white background (they become visible when we select and area of the drawing in the package).

By experimentation, we know that the package will do this with all QCAD DWG drawing formats (its working as it should, but not how we need it to be)

So my how do I is quite simple - how do I change the line colour of all layers in (ideally) one command

so QCAD pro (current release), Windows 10 - package that is picking up the DWG files is EDSL TAS - we have confirmed its interpretation is correct with the thier support - which leaves us no option but to look for other ways to force this behaviour. My suspicion is that Draftsight isnt encoding the line colour in thier DWG format..

Save me from a headscratch.

Thanks


Owen

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

Re: Layer Colours issue - looking for a workaround

Post by andrew » Thu Oct 10, 2019 8:33 am

There's an example script for that at:
Misc > Layer > Make all White Layers Black

The script can also be easily adapted to change only particular layers to desired colors, etc.

The source of that script is:

Code: Select all

include("scripts/EAction.js");

/**
 * This action changes the color of all white layers to black and can be adapted to
 * change layer colors in other ways.
 */
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.getName()==="ref") {
//            layer.setColor(new RColor("blue"));
//            op.addObject(layer);
//        }
//        else if (layer.getName()==="cursor" || layer.getName()==="center") {
//            layer.setColor(new RColor("#ff0000"));
//            op.addObject(layer);
//        }
//        else if (layer.getName()==="limiting") {
//            layer.setColor(new RColor("#0000ff"));
//            op.addObject(layer);
//        }

        if (layer.getColor().name().toLowerCase()==="#ffffff") {
            layer.setColor(new RColor("#000000"));
            op.addObject(layer);
            EAction.handleUserMessage(
                qsTr("Changed color of layer \"%1\" from white to black.")
                    .arg(layer.getName())
            );
        }
    }

    di.applyOperation(op);

    this.terminate();
};

/**
 * Adds a menu for this action.
 */
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"]);
};

Owen423
Newbie Member
Posts: 3
Joined: Thu Oct 10, 2019 7:54 am

Re: Layer Colours issue - looking for a workaround

Post by Owen423 » Thu Oct 10, 2019 9:57 am

As we tend to remove all the unneccesary layers, this could well do the job for us, nicely!

Awesome!

O

Post Reply

Return to “QCAD 'How Do I' Questions”