Simple Script

Drop in here to discuss whatever you want.

Moderator: andrew

Post Reply
Premier Member
Posts: 1211
Joined: Wed Sep 27, 2017 4:17 pm

Simple Script

Post by CVH » Fri Jun 01, 2018 4:27 pm

Still strugling with simple change to ExDumpPolyline.js

I found the mirroring (arg(-v.y)) and the orientation change inappropriate, undocumented and misleading as an example.
All questions where finally cleared out by your reply on on May 17, 2018 11:47 am

Did found out that JavaScript isn't that hard to understand but that the syntax and the use of QCAD modules need carefull attention.

Next I find the command history an inappropriate place to dump the points data.
So I took a look at BlockListExport.js and the export to a CVS file is more appropriate.

Next I find the way java exports numbers unsatisfactory.
You proposed to use:
"%1".arg(numberToString(Math.PI, 12))

Math.PI is from java itself and is always present.
Math.PI returns a number and this checks out to be a number between 3.14159 and 3.14160 using comments to the command history.

numberToString is from the QCAD library.js lib.
Using this function ends the altered ExDumpPolyline.js script at this point.
So I presume library.js is not present, and even better, it is not to be found on my system.
I can't include it at the top of ExDumpPolyline.js script.
Reading the readme.txt in the C:\Program Files\QCAD\scripts one would think it is present as hardcoded.
I have not the intention to replace all hardcoded plugins with js files.

Because of the next two include branches I am troubled even further because scripts/Misc/Misc.js is also not found on my system but both scripts work.
ExMathSpiral.js : include("../MathExamples.js");
>> MathExamples.js : include("../Examples.js");
>> >> Examples.js : include("scripts/Misc/Misc.js");
ExDumpPolyline.js : include("../IOExamples.js");
>> IOExamples.js : include("../Examples.js");
>> >> Examples.js : include("scripts/Misc/Misc.js");

So I think I am missing a clue here.

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

Re: Simple Script

Post by CVH » Sat Jun 02, 2018 8:27 am

And further, it is in Misc.js that EAction.js is included (also not on my system)
but EAction.handleUserWarning("any text.") does work.

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

Re: Simple Script

Post by CVH » Sat Jun 02, 2018 12:09 pm

Found this: viewtopic.php?t=2675
Andrew wrote:
Some hints:
- look at the console output to check for error messages
- enable the script debugger (it will pop up as soon as a dependency is not met, a script cannot be found, etc): ./qcad -enable-script-debugger

What is an output console??


Found this in only 3 relevant hits on the forum:
viewtopic.php?f=107&t=3172&p=11407&hili ... put#p11407
qcad -rescan -enable-script-debugger

Did put both in the command line of QCAD but this will return an error in the command history.
Wait command line.... the OS command line....

Started qcad.exe with -rescan -enable-script-debugger
And yes its the QT debugger / console and so on.

Found that QCAD is now prone to crasch like mentioned in the above topics.
Even drawing a quick test polyline with a few segments let it fail.
I can seen the drawing plane shift a litle drawing the line and selecting it.
As it not fails every time I could test the ExDumpPolyline.js script.

Found out that library.js is loaded from :/scripts/Snap/SnapAuto/../../library.js (not on my system so hardcoded)
?--> library.js is not in the github qcad-master/scripts/Snap/SnapAuto/
?--> library.js is in the github qcad-master/scripts/

And that it produces and exception ReferenceError: Can't find variable: sprintf
Indeed sprintf.js is not loaded.

At the beginning of library.js is stated:
// don't include sprintf.js here to keep library footprint small:

So I placed a copy of github qcad-master/scripts/sprintf.js at C:\Program Files\QCAD\scripts.
And I included sprintf.js at the top of the ExDumpPolyline.js script.

And what do you think, yes, finally numberToString() is doing what it is suposed to do.

How could this be so difficult?

Post Reply

Return to “Chat”