Versión:
3.25.2.0 (3.25.2)
Internet:
QCAD.org
Fecha de producción:
Sep 4 2020
Repaso:
4a61501
Qt Versión:
5.13.2
Arquitectura:
x86_64
Compilador:
MSVC++ 14.0 (2015)
Windows 10 Pro
Hi,
I have a problem with my script. The script runs correctly at the first time, but the second time it is blocked and it doesn't run again.
This script does "cut and paste on other tab, and export to new file", I need to close the current tab, and repeat the same process with other pieces.
I have tried with "this.terminate" in different places but the result is incorrect every time. I have tried with reset too.
// CutPaste.js
// Include base class definition:
include("../MyScripts.js");
// Constructor calls base class constructor:
function CutPaste(guiAction) {
MyScripts.call(this, guiAction);
}
CutPaste.prototype = new MyScripts();
CutPaste.prototype.beginEvent = function() {
MyScripts.prototype.beginEvent.call(this);
var action = RGuiAction.getByScriptFile("scripts/Edit/Cut/Cut.js");
if (!isNull(action)) {
action.slotTrigger();
}
var action2 = RGuiAction.getByScriptFile("scripts/File/NewFile/NewFile.js");
if (!isNull(action2)) {
action2.slotTrigger();
}
var di = EAction.getDocumentInterface();
var document = di.getDocument();
var op = new RPasteOperation(RDocument.getClipboard());
op.setOffset(new RVector(0,0));
op.setRotation(0.0);
op.setScale(1.0);
op.setFlipHorizontal(false);
op.setFlipVertical(false);
op.setToCurrentLayer(true);
op.setOverwriteBlocks(true);
//op.setCopyEmptyBlocks(true);
di.applyOperation(op);
di.autoZoom();
// var data = readTextFile("/Planning/Oferta.txt");
var file = new QFile("C:/Planning/Oferta.txt");
var flags = new QIODevice.OpenMode(QIODevice.ReadOnly | QIODevice.Text);
if (!file.open(flags)) {
this.terminate();
return;
}
var ts = new QTextStream(file);
ts.setCodec("UTF-8");
var line;
//do {
line = ts.readLine(); //Sólo necesito la linea 1.
//} while (!ts.atEnd());
file.close();
//var d = new Date();
//var h = d.getHours();
//var m = d.getMinutes();
//var s = d.getSeconds();
di.exportFile("O:/" + line + "/Temp/" + line + ".dxf", "DXF 2000");
this.terminate();
//Here the problem.
var action3 = RGuiAction.getByScriptFile("scripts/File/CloseFile/CloseFile.js");
if (!isNull(action3)) {
action3.slotTrigger();
}
var action4 = RGuiAction.getByScriptFile("scripts/Reset/Reset.js");
if (!isNull(action4)) {
action4.slotTrigger();
}
};
CutPaste.init = function(basePath) {
var action = new RGuiAction(qsTr("CutPaste"), RMainWindowQt.getMainWindow());
action.setRequiresDocument(true);
action.setScriptFile(basePath + "/CutPaste.js");
action.setIcon(basePath + "/CutPaste.svg");
action.setStatusTip(qsTr("CutPaste"));
action.setDefaultShortcut(new QKeySequence("c,p"));
action.setDefaultCommands(["cutpaste"]);
action.setGroupSortOrder(73100);
action.setSortOrder(400);
action.setWidgetNames(["MyScriptsMenu"]);
};
Have you an idea to solve that?
Thanks!
[SOLVED] Close script to be called again
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
[SOLVED] Close script to be called again
Last edited by sinase on Thu Mar 18, 2021 6:21 pm, edited 1 time in total.
Re: Close script to be called again
Hi, solved using "-always-load-scripts" command.