Any Command Line Toos for shortening multiple lines at once?

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
Inglemation
Registered Member
Posts: 2
Joined: Fri Aug 12, 2022 3:33 am

Any Command Line Toos for shortening multiple lines at once?

Post by Inglemation » Fri Aug 12, 2022 3:54 am

Hello, all! Please forgive my ignorance, as I'm fairly new to QCAD. I'm running the latest version of QCAD (QCAD 3 I think) that I just downloaded last week, Windows 64-bit version.

I'm trying to help my friend who's getting some metal pieces cut so that he can bend the metal easily. The files he received have the cut lines along the outer perimeters as they should be, but the internal "bend lines" extend all the way to the outer perimeters, which would result in every section being cut into individual pieces on the cutting machine. So I'm going through and shortening the "bend lines" by 7mm along all the edges, so that there will be solid metal there in those 7mm gaps that can be easily bent. In the attached photo, I have already shorted the bend lines on the right side of the object, and the bend lines on the left side of the object are the unedited lines that I'm going through and shortening.

Does anybody know of a Command Line Tool where I can select all the lines on a given layer (the red or blue layers in the photo for instance) and shorten all of them at once from both ends of the line toward the center?

Other questions: Are there any reputable repositories where I might try and browse for such a Command Line Tool? Is there a similar tool that I might be able to easily adapt for these purposes?

Thank you very much, any help is greatly appreciated!
Image

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

Re: Any Command Line Toos for shortening multiple lines at once?

Post by CVH » Fri Aug 12, 2022 6:09 am

Hi,

I don't think that anything exist for this specific task.
You refer to the 'Command Line', do you mean running it from the OS command line?

QCAD comes with a very powerful Selection Filter.
See View menu .. Selection Filter.
If the filter widget isn't visible, you can also activate that by just typing the shortcut 'GF'.
You don't need to enter shortcuts in the QCAD GUI command line. :wink:

Selection on layer or on color is possible, one can add, subtract or intersect with an existing selection.
Without an example drawing we don't know how the segments are organized on layers ...
... It might do you no good as long as the outer perimeter also has red lines.

For a few entities (with the same length) I would shorten them by 3,5mm, reverse them and shorten again by 3,5mm.
Modify menu .. Reverse (RV) reverses all in selection.
Modify menu .. Lengthen / Shorten (LE) is not functional on a multi selection.

A custom script could be written to do this for you for any line segment in selection.
Especially interesting when you have tons of such drawings to adapt. 8)

Regards,
CVH
Last edited by CVH on Fri Aug 12, 2022 12:12 pm, edited 1 time in total.

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

Re: Any Command Line Toos for shortening multiple lines at once?

Post by Husky » Fri Aug 12, 2022 6:55 am

Hi,
without the dxf file I've a hard time to understand the structure of the drawing and how it needs to be manufactured.

This said - so far I see no need to shorten the blue or red bend lines!

This shape is most likely processed on a CNC cutter - it doesn't really matters what kind of cutter. That means somebody has to produce a g-code for the cnc cuts based on the outer lines. If you don't include in this process the inner red and blue lines then it will not be cut!!!
It could also be that the CNC is using the dxf layer attributes to create the cutting path automatically. In that case just make the inner blue and red lines invisible, lock them or if nothing else is working make a copy and delete them.

QCAD has currently no tool which shortens lines etc on both sides. The easiest way would be to use the "Lengthen/Shorten" tool on each line sides with a mouse click.

Questions:
What is the meaning of the the red lines? Just bending lines can't be.
The outer line is partly red - is there a white line underneath? Did you switch the red and blue layer invisible? Do you then have still the contour which needs to be cut?
What is the approx. overall dimension for what we see in the screenshot?
Is the CNC operating based on a G-Code? If yes who has to produces this code?
What machine is used for the bending process? I assume not a CNC forming machine ...
If possible please attache the drawing to your post or at least an example drawing which shows the same structure. Thanks.
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

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

Re: Any Command Line Toos for shortening multiple lines at once?

Post by CVH » Sat Aug 13, 2022 11:12 am

Inglemation,

When you sorted out how to select the line-segments in question ...
... Came up with a simple script ...

It is not conceived as an Addon tool, it has no settings that are handled in the GUI.

You need to adapt the value to grow (positive) / shrink (negative) textual in the script before you run it.
I also incorporated a ratio as that might have some use for me (>1%, not 100%).
These entries at line 4 or 5 are validated.
# EDIT # Oops, set the ratio to 'undefined' to use a fixed amount ... :roll:

The tool is limited to act on selected line-segments and cannot downsize to less than almost nothing (a point).

Scripts are textual, for more details see the script-file itself.

Store a copy of the *.js file wherever you want it locally.
Typically, you run it with a selection from the Misc menu .. Development .. Run Script (XC)

GrowShrink.js
Grow/shrink selected Line-segments
(2.74 KiB) Downloaded 223 times

Regards,
CVH

Inglemation
Registered Member
Posts: 2
Joined: Fri Aug 12, 2022 3:33 am

Re: Any Command Line Toos for shortening multiple lines at once?

Post by Inglemation » Sat Aug 13, 2022 8:22 pm

CVH wrote:
Sat Aug 13, 2022 11:12 am
Inglemation,

When you sorted out how to select the line-segments in question ...
... Came up with a simple script ...

It is not conceived as an Addon tool, it has no settings that are handled in the GUI.

You need to adapt the value to grow (positive) / shrink (negative) textual in the script before you run it.
I also incorporated a ratio as that might have some use for me (>1%, not 100%).
These entries at line 4 or 5 are validated.
# EDIT # Oops, set the ratio to 'undefined' to use a fixed amount ... :roll:

The tool is limited to act on selected line-segments and cannot downsize to less than almost nothing (a point).

Scripts are textual, for more details see the script-file itself.

Store a copy of the *.js file wherever you want it locally.
Typically, you run it with a selection from the Misc menu .. Development .. Run Script (XC)

GrowShrink.js

Regards,
CVH
CVH, I can't thank you enough for your help on this. I really, really appreciate you taking the time out of your day to help a perfect stranger. I'm humbled by your kindness. I don't know if there's some way to get in touch with you securely outside of this forum, but I would like to PayPal or Venmo or somehow send you a few bucks for your troubles, as this tool is probably going to help me tremendously. I can't wait to try it out! Thank you, thank you!!

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

Re: Any Command Line Toos for shortening multiple lines at once?

Post by CVH » Sat Aug 13, 2022 9:49 pm

Inglemation wrote:
Sat Aug 13, 2022 8:22 pm
I'm humbled by your kindness. I don't know if there's some way to get in touch with you securely outside of this forum,
Thanks for the kind words.
You can reach me by private message (PM) too.

The simple script is provided free to use and free of charge.
That is how things work in open source ...
Maybe you could donate a few bucks to the QCAD project ... Ask Andrew.

In time I might promote it to a QCAD Addon. :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”