Selection From Polyline

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:

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
ExTrial.js (6.59 KB)

You have to include the script before using it:
include(“scripts/Pro/Draw/Polyline/PolylineFromSelection/PolylineFromSelection.js”);

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. :wink:

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

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” (QCAD: Introduction, Overviews, Howtos).

For future use: Where shall I find a documentation about such objects and functions?

Regards
Peter

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.