Where are QCAD scripts?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Where are QCAD scripts?
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
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?
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.
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.
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Where are QCAD scripts?
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!
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?
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"]);
};
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Where are QCAD scripts?
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.
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?
The tool "Flatten Drawing to 2D" removes Z coordinates for all entities in all blocks.
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Where are QCAD scripts?
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 434 times
-
- Screenshot from 2019-02-12 22-39-54.png (114.84 KiB) Viewed 7963 times
-
- Screenshot from 2019-02-12 22-44-22.png (93.78 KiB) Viewed 7963 times
- dfriasb
- Senior Member
- Posts: 119
- Joined: Thu Mar 10, 2016 1:08 pm
- Location: Calafell, Tarragona, Spain
Re: Where are QCAD scripts?
Meanwhile, can you send me flatten script so I can try to fix this by myself? Thanks again!!
David
David
Re: Where are QCAD scripts?
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);
};