Hello.
How can I get the self script path in my script? For example, if I want to move my result file in directory with script file.
And how can I get in script the path of qcad directory?
Moderator: andrew
alf2006x wrote:How can I get the self script path in my script? For example, if I want to move my result file in directory with script file.
function MyClass() {
...
}
MyClass.prototype = new MyBaseClass();
// store include base path for later use:
MyClass.includeBasePath = includeBasePath;
MyClass.prototype.beginEvent = function() {
this.loadSomeResource(MyClass.includeBasePath + "/MyResource.txt");
};
...
And how can I get in script the path of qcad directory?
QCoreApplication.applicationDirPath()alf2006x wrote:How can I insert my block from the file?
I have got the file with name "MyDraw.dxf". It has block with name "MyBlock1". I want my script to open that file, get that block and insert it in current drawing.
/** Einen Block einfügen, gegebenenfalls regional spezifisch.
* @param {Object} zeichnung die Zeichnung
* @param {String} pfad Name der Datei
* @param {Number} x X-Koordinate
* @param {Number} y Y-Koordinate
* @param {Boolean} h H-Spiegelung
* @param {Boolean} v V-Spiegelung
*/
MyScript.prototype.insert = function(zeichnung, pfad, x, y, h, v) {
var bPath = "My/" + pfad + ".dxf";
var bName = "My#" + pfad;
var bDoc = new RDocument(new RMemoryStorage(), new RSpatialIndexNavel());
var bInt = new RDocumentInterface(bDoc);
if (bInt.importFile(bPath) != RDocumentInterface.IoErrorNoError) {
this.log.w("Datei fehlt: " + bPath);
return;
}
var operation = new RPasteOperation(bDoc);
operation.setOffset(new RVector(x, y));
operation.setBlockName(bName);
operation.setScale(1.0);
operation.setRotation(0.0);
operation.setFlipHorizontal(h);
operation.setFlipVertical(v);
operation.setToCurrentLayer(true);
operation.setOverwriteLayers(false);
operation.setOverwriteBlocks(false);
zeichnung.documentInterface.applyOperation(operation);
zeichnung.documentInterface.repaintViews();
}alf2006x wrote:Can I use in my -no-gui QCAD script any commands without a prefix "R", like Circle3P?
I would study the source of Circle3P command. How it converts the data gathered from the mouse clicks into something
var p1 = new RVector(0, 0);
var p2 = new RVector(10, 0);
var p3 = new RVector(5, Math.sin(RMath.deg2rad(60))*10);
operation.addObject(new RCircleEntity(document, new RCircleData(Circle3P(p1, p2, p3)));include(QCoreApplication.applicationDirPath()+"/scripts/Modify/Round/Round.js");
var p1 = new RVector(0, 0);
var p2 = new RVector(10, 0);
var p3 = new RVector(5, Math.sin(RMath.deg2rad(60))*10);
var LineEntity1 = new RLineEntity(document, new RLineData(p1, p2));
var LineEntity2 = new RLineEntity(document, new RLineData(p2, p3));
operation.addObject(LineEntity1);
operation.addObject(LineEntity2);
var success = Round.round(operation,LineEntity1,p1,LineEntity2,p3,true,1.5,false);
Users browsing this forum: Google [Bot] and 1 guest