Linux: Ubuntu 20.04 and Wayland
qcad-3.27.1-pro-linux-qt5.14-x86_64
Hello,
I want to change a rectangle build by 4 lines to a rectangle made by one polyline using a script. I use your script "ExThreePoints.js" to test functions for my script and copied it to my script ExTrial.js for modifications.
I found two entries in your forum for the solution:
https://qcad.org/rsforum/viewtopic.php?f=107&t=7210
https://qcad.org/rsforum/viewtopic.php?f=32&t=7057
But none of this will work. I put the code to my script and got in both case the error (running qcad in debug mode): "Uncaught exception at scripts/PPeters/ExTrial/ExTrial.js:111: ReferenceError: Can't find variable: PolylineFromSelection"
(attached screenshot)
How do I have to change my code that it works?
Regards
Peter
Selection From Polyline
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.
Selection From Polyline
- Attachments
-
- ExTrial.js
- (6.59 KiB) Downloaded 267 times
-
- error message
- qcad forum 01.png (123.71 KiB) Viewed 4353 times
Re: Selection From Polyline
You have to include the script before using it:
include("scripts/Pro/Draw/Polyline/PolylineFromSelection/PolylineFromSelection.js");
include("scripts/Pro/Draw/Polyline/PolylineFromSelection/PolylineFromSelection.js");
Re: Selection From Polyline
Remark that di.selectAll(); will select all selectable entities in a drawing.
Poly from selection would than merge everything that can be considered as a chain of segments.
And not only some rectangles build by 4 lines.
For that you need to evaluate all entities first on whether they make up a quadrilateral.
Deselecting those that don't or merely selecting those that will.
Without selecting all first in your script, it would run on those that are selected before you initiate it.
In the way you are scripting right now is nothing more than TA followed by OC.
Remark also that the QCAD shape tools create quadrilaterals as 4 lines or optionally as a polyline.
Maybe it is just a question of using the correct option on creation.
Regards,
CVH
Re: Selection From Polyline
Thank you for the fast and helpful answer. After I added the "include" it works in the intended way.
I suggested, that there is "include" missing, but I could not find it in the "Source Code" that I downloaded from your website(https://github.com/qcad/qcad/archive/v3.27.1.0.zip) or in the documentation of the "QCAD Application Framework" (https://www.ribbonsoft.com/doc/qcad/3.0 ... index.html).
For future use: Where shall I find a documentation about such objects and functions?
Regards
Peter
I suggested, that there is "include" missing, but I could not find it in the "Source Code" that I downloaded from your website(https://github.com/qcad/qcad/archive/v3.27.1.0.zip) or in the documentation of the "QCAD Application Framework" (https://www.ribbonsoft.com/doc/qcad/3.0 ... index.html).
For future use: Where shall I find a documentation about such objects and functions?
Regards
Peter
Re: Selection From Polyline
Please keep in mind that PolylineFromSelection is not part of the public API but part of the proprietary API of QCAD Professional. Feel free to call this from your script, but keep in mind that this API might change in a future version.