Page 1 of 1
Where are QCAD scripts?
Posted: Sat Dec 22, 2018 4:43 pm
by dfriasb
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
Re: Where are QCAD scripts?
Posted: Tue Dec 25, 2018 1:30 pm
by woddy
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.
Re: Where are QCAD scripts?
Posted: Fri Jan 25, 2019 4:58 pm
by dfriasb
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!
Re: Where are QCAD scripts?
Posted: Fri Jan 25, 2019 9:42 pm
by andrew
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"]);
};
Re: Where are QCAD scripts?
Posted: Tue Feb 12, 2019 9:21 pm
by dfriasb
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.
Re: Where are QCAD scripts?
Posted: Tue Feb 12, 2019 9:26 pm
by andrew
The tool "Flatten Drawing to 2D" removes Z coordinates for all entities in all blocks.
Re: Where are QCAD scripts?
Posted: Tue Feb 12, 2019 10:47 pm
by dfriasb
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.
Re: Where are QCAD scripts?
Posted: Wed Feb 13, 2019 9:56 am
by andrew
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.
Re: Where are QCAD scripts?
Posted: Wed Feb 13, 2019 11:01 am
by dfriasb
Meanwhile, can you send me flatten script so I can try to fix this by myself? Thanks again!!
David
Re: Where are QCAD scripts?
Posted: Thu Feb 14, 2019 3:41 pm
by andrew
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);
};