simple_modify.js ---- Pastes the given document

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
Ricardo2022
Registered Member
Posts: 2
Joined: Sat Dec 03, 2022 12:30 pm

simple_modify.js ---- Pastes the given document

Post by Ricardo2022 » Mon Dec 26, 2022 11:12 pm

Hi .
My operating system is Windows 10 Enterprise
My Qcad version is 3.27.8.0 (3.27.8)

I´m trying to use the simple_modify.js script included at scripts/ with my own :

include("C:/Users/xxx/scripts/simple_modify.js");
var docSource = "C:/xxx/bb.dxf";
var diDestination = "C:/xxx/cc.dxf";
var offset = [0,0]
var scale = 1;
var rotation = 0;
var flipHorizontal = false;
var flipVertical = false;
var toCurrentLayer = true;
var overwriteLayers = false;
var overwriteBlocks = false;

paste(docSource, diDestination, offset, scale, rotation, flipHorizontal, flipVertical, toCurrentLayer, overwriteLayers, overwriteBlocks);

The error shown is :

Script exception in script 'C:/Users/xxx/QCAD/scripts/MyScripts/paste_file.js': Error: :-1:-1: RPasteOperation(): no matching constructor found. <native>('C:/Users/xxx/bb.dxf') at -1 paste(docSource = 'C:/Users/xxx/bb.dxf', diDestination = 'C:/Users/xxx/cc.dxf', offset = "RVector(0.000000, 0.000000, 0.000000, 1)", scale = 1, rotation = 0, flipHorizontal = false, flipVertical = false, toCurrentLayer = true, overwriteLayers = false, overwriteBlocks = false) at :/scripts/simple_modify.js:27 paste(docSource = 'C:/Users/xxx/bb.dxf', diDestination = 'C:/Users/xxx/cc.dxf', offset = 0,0, scale = 1, rotationS = 0, flipHorizontal = false, flipVertical = false, toCurrentLayer = true, overwriteLayers = false, overwriteBlocks = false) at :/scripts/simple_modify.js:24 anonymous() at 26 <anonymous>() at :scripts/Misc/MiscDevelopment/RunScript/RunScript.js:120 <eval>() at 1 <native>() at -1 main() at :scripts\autostart.js:846 <global>() at :scripts\autostart.js:859

Could you tell me where is the mistake?
Thanks in advance.
Attachments
paste_file.js
(555 Bytes) Downloaded 209 times

CVH
Premier Member
Posts: 3471
Joined: Wed Sep 27, 2017 4:17 pm

Re: simple_modify.js ---- Pastes the given document

Post by CVH » Tue Dec 27, 2022 9:20 am

Ricardo2022 wrote:
Mon Dec 26, 2022 11:12 pm
Could you tell me where is the mistake?
Yes, but there is more to it ...

We usually include simple.js to start with (simple_modify.js Line 38 getDocumentInterface() is declared there)

diDestination is a correct naming but the explanation on line 10 is wrong. :shock:
https://github.com/qcad/qcad/blob/maste ... _modify.js
The parameter docDestination is not used.
Filed a BugReport at: https://qcad.org/bugtracker/index.php?d ... sk_id=2438

di usually stands for document interface.
The function doesn't paste a drawing docSource in another drawing on your drive called docDestination.
It paste an already open document into another open document.
That can be the current active drawing in QCAD with diDestination = undefined or a given one defined by its document interface.

In short: It isn't functional with filenames.
You need to supply an existing RDocumentInterface of an open drawing as target and the existing RDocument of an open drawing as source.
https://qcad.org/doc/qcad/3.0/developer ... ument.html
https://qcad.org/doc/qcad/3.0/developer ... rface.html


More in the nature of what you want to accomplish:
To merge drawing files (off-screen) there is also a command line tool called merge.
See: https://www.ribbonsoft.com/en/products/ ... ols/#merge

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”