Update Draw Polyline to match line command

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
riverbuoy
Senior Member
Posts: 103
Joined: Thu Oct 03, 2013 5:37 pm

Update Draw Polyline to match line command

Post by riverbuoy » Sat Nov 01, 2014 5:52 pm

Hi

I have updated 'draw polyline' to have the same functionality as the 'line' command. So I have added a 'redo' button to the options toolbar, and also a 'restrict to angle and/or distance' button.
I have also added shortcuts to the buttons - ',C' ',U' ',R' for close, undo and redo. Also ',A' to toggle the arc segment box. (Remember you can change the comma to another character in 'Edit->Application Preferences->Widgets->Toolbars'.).
You can also now use the commands 'c', 'u', 'r' and 'a' in the command line. (You can also type 'c', 'cl', 'clo', 'clos' and 'close'. They will all invoke the 'close' command, but you only have to type as many characters as required to distinguish between commands. Similarly for the 'undo', 'redo' and 'arc' commands.).
Also if you press 'enter' or 'return' at the 'First vertex' prompt, it will choose the last position as the first vertex.
Use of the 'restrict' button is the same as in the line command.
The standard command enables the 'close' and 'undo' buttons when it is waiting for a first vertex. I have changed this so they are now disabled, so they behave as they do in the line command.
Finally when defining an arc segment, relative zero is set to the point you pick. If this point is not at the end of the arc segment, then relative zero will be in the wrong position. I changed this so relative zero is positioned at the end of the arc segment.

There are four files to implement the change, which I have attached. These should be copied to the 'scripts/Draw/Polyline/DrawPolyline' directory. The two files 'DrawPolyline.js' and 'DrawPolyline.ui' already exist in this directory, so if you wish to keep them, rename them first.

riverbuoy
Attachments
RedoPath-inverse.svg
(9.34 KiB) Downloaded 199 times
RedoPath.svg
(9.06 KiB) Downloaded 221 times
DrawPolyline.ui
(4.44 KiB) Downloaded 224 times
DrawPolyline.js
(14.02 KiB) Downloaded 220 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 1992
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Update Draw Polyline to match line command

Post by Husky » Sat Nov 01, 2014 7:30 pm

riverbuoy wrote:Hi

I have updated 'draw polyline' to have the same functionality as the 'line' command.
Nice - thanks again for taking care of tools like this one! :D


Question to the new functionality:

If I restrict the angle (i.e. 45°) for an arc - I'm still able to pick any finishing point outside this given angle? Why is that so?
And what is the Mouspointer Info telling me?
Husky-2014.11.01-01.png
Husky-2014.11.01-01.png (14.82 KiB) Viewed 7681 times
Work smart, not hard: QCad Pro

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 1992
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Update Draw Polyline to match line command

Post by Husky » Sun Nov 02, 2014 9:20 am

Husky wrote:Question to the new functionality:

If I restrict the angle (i.e. 45°) for an arc - I'm still able to pick any finishing point outside this given angle? Why is that so?
And what is the Mouspointer Info telling me?
Understood! I can now answer my question by myself:
The given angle belongs not to the arc - it will restrict the Mousepointer position to relative zero. And the Compass orientation is always the same - regardless where I start my arc.

What means: I can't create a Polyline with arcs (180°) like this one, right?
Husky-2014.11.02-01.png
Husky-2014.11.02-01.png (2.54 KiB) Viewed 7665 times
:(
Work smart, not hard: QCad Pro

riverbuoy
Senior Member
Posts: 103
Joined: Thu Oct 03, 2013 5:37 pm

Re: Update Draw Polyline to match line command

Post by riverbuoy » Mon Nov 03, 2014 8:52 pm

Hi Husky
Husky wrote:What means: I can't create a Polyline with arcs (180°) like this one, right?
Actually you can, BUT, trying to get an arc to be exactly 180° when the preceeding line segment is not horizontal or vertical, is extremely difficult (not quite impossible, it would require some manual calculations).
However, this gave me an idea. I have added a sweep entry box to the options toolbar. This allows you to enter the sweep value you require. So, in your example, you would enter a value of 180.0 in this box.
The value in the box must be greater than or equal to 0.0, and less than or equal to 360.0. If it is outside these values then it will have no effect. Also if the value equals 0.0, it has no effect.
This change affects two files - 'DrawPolyline.js' and 'DrawPolyline.ui', which I have attached. As before copy them to the 'scripts/Draw/Polyline/DrawPolyline' directory.
Perhaps you could try this out and let me know what you think?

riverbuoy
Attachments
DrawPolyline.js
(15.39 KiB) Downloaded 208 times
DrawPolyline.ui
(5.72 KiB) Downloaded 225 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 1992
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Update Draw Polyline to match line command

Post by Husky » Mon Nov 03, 2014 10:13 pm

riverbuoy wrote: Actually you can, BUT, trying to get an arc to be exactly 180° when the preceeding line segment is not horizontal or vertical, is extremely difficult (not quite impossible, it would require some manual calculations).
Yes I know - but by now you know me .................. I'm a lazy boy. :roll:
riverbuoy wrote:However, this gave me an idea. I have added a sweep entry box to the options toolbar. This allows you to enter the sweep value you require. So, in your example, you would enter a value of 180.0 in this box.
YES - that was exactly what I was looking for! :D

Till now my work-flow for a little bit more complicated Polyline was to create the shape with standard tools like lines, Arcs etc etc. and then I converted this with the Tool "Create from Segments" to a Polyline.

Now with your additional options for the "Draw Polyline" tool I'm able to improve my Work-flow. Nice! Thank you!

I will test it a little further but it looks already pretty good! 8)

Question:
riverbuoy wrote:The value in the box must be greater than or equal to 0.0, and less than or equal to 360.0. If it is outside these values then it will have no effect. Also if the value equals 0.0, it has no effect.
Would it be possible to mark values outside the working range in red? Like -45 or 375 etc.? As a hint for the User that he is doing something wrong ...
Work smart, not hard: QCad Pro

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”