Import Rectangles from a cutlist

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Import Rectangles from a cutlist

Post by Kramerica » Tue Feb 16, 2021 4:11 am

I work for a cabinet shop, and I've manually been drawing approx 60 rectangles per kitchen. The sizes are generated from an Excel spreadsheet and are predefined based off the size of the cabinets.

I've seen (but don't yet understand) that you can import X,Y information into QCAD from a CSV. Does this relate to importing rectangles?

Example sizes:
8.25" x 22"
4.25" " 20"
3.55" x 20"
3.55" x 12.95"

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

Re: Import Rectangles from a cutlist

Post by CVH » Tue Feb 16, 2021 10:37 am

Hi,
With scripting almost anything is possible ... :wink:

In my case it would be easy because it is a snippet of code I already use.
There are two things missing in your definition.

The where and the angle.

That would look like:
  • "Rectangle", OffsetX, OffsetY, SizeX, SizeY, Angle (Closed polyline)
Others would look like:
  • "Line", StartX, StartY, EndX, EndY
    "Arc", Reversed/Not, CenterX, CenterY, Radius, StartAngle, EndAngle
    "Circle", CenterX, CenterY, Radius
    "Triangle", x1, y1, x2, y2, x3, y3 (Closed polyline)
    "Quad", x1, y1, x2, y2, x3, y3, x4, y4 (Closed polyline)
    "Polygon", <more than 4 reference points> (Closed polyline)
    "Polyline", Open/Closed, x1, y1, Bulge1, x2, y2, Bulge2, x3 ...
    "Fspline", Open/Closed, x1, y1, x2 ... (Fit points)
    "Text", ....
    ....
    ..
    8)
What about attributes (General Properties), active/cast Layer? e_geek
[Layer, Color, Lineweight, Linetype, (drawing order)]
What about custom properties? e_ugeek
Pairwise [key, value]
How about rounded rectangles or beveled rectangles?

Kind of macro's for QCAD ...
I dropped the project in favor for others ... :roll:
Not many people have the same needs. :wink:
On top, I alter the code on the fly to suit the requirements.


Regards,
CVH

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Re: Import Rectangles from a cutlist

Post by Kramerica » Wed Feb 17, 2021 3:11 am

So I'll be learning scripting in QCAD. Thank you for pointing me in the right direction.

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Re: Import Rectangles from a cutlist

Post by Kramerica » Thu Feb 18, 2021 2:11 pm

I'm getting somewhere, but keep getting parse errors when I hit enter.

From your text, what should the actual string look like?
"Rectangle", OffsetX, OffsetY, SizeX, SizeY, Angle (Closed polyline)

ecma> "Rectangle", Offset20, Offset20, Size15, Size19, Angle90 (Closed polyline)
SyntaxError: Parse error

ecma> "Rectangle", 20, 20, 15, 15, 90 (Closed polyline)
SyntaxError: Parse error

ecma> "Rectangle", 20, 20, 15, 15, 90
90
Nothing happened to the drawing, but no error.

ecma> "Rectangle", 20, 20, 15, 15, 90 (Closed polyline)
SyntaxError: Parse error

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

Re: Import Rectangles from a cutlist

Post by CVH » Thu Feb 18, 2021 2:32 pm

Don't worry,
I have my script almost ready and back in basic form.
Point, Line, Arc, Circle, Triangle, Quad, Square and Rectangle are included.

Give me a few hours to post it.
I'll keep you informed .... :wink:

Regards,
CVH

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

Re: Import Rectangles from a cutlist

Post by CVH » Thu Feb 18, 2021 3:47 pm

Hi Kramerica,
I posted the script in the QCAD Developers and Contributors Forum:
https://qcad.org/rsforum/viewtopic.php?t=8135

Kind regards,
CVH

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

Re: Import Rectangles from a cutlist

Post by Husky » Fri Feb 19, 2021 12:38 am

Kramerica wrote:
Tue Feb 16, 2021 4:11 am
I work for a cabinet shop, and I've manually been drawing approx 60 rectangles per kitchen. The sizes are generated from an Excel spreadsheet and are predefined based off the size of the cabinets.

I've seen (but don't yet understand) that you can import X,Y information into QCAD from a CSV. Does this relate to importing rectangles?

Example sizes:
8.25" x 22"
4.25" " 20"
3.55" x 20"
3.55" x 12.95"
Just for fun - I blame the pandemic for that!
Thinking about how that could be solved for someone with zero scripting skills like me. What we have is the size list and ... Excel. Good! I know one or two things about Excel ... e_surprised
Ok, I prepared an Excel spreadsheet, copy/paste the size list (random numbers) into the spreadsheet, searched/replaced in Excel to get rid of the useless unit etc. symbols - and my Excel function went to work immediately to created a Command Line list for QCAD with those information. This list copied - insert into QCAD Command Line - success.

QCAD Excel to cabinets.gif
QCAD Excel to cabinets.gif (1.09 MiB) Viewed 8563 times

I'm sure coder will call that "Primitive". However - it works. :lol: :lol: :lol:
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..."

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Import Rectangles from a cutlist

Post by ryancousins » Fri Feb 19, 2021 1:32 am

Husky,

I thought I'd try copying some of your spreadsheet cells to follow along with what you were showing Kramerica. I typed the values in excel real quick then copied and pasted them into the CL. But I must be doing something wrong! I'm seeing a "command" for all of the lines in the CL rather than "coordinate". Not sure what I did wrong.
command.png
command.png (160.48 KiB) Viewed 8560 times

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

Re: Import Rectangles from a cutlist

Post by Husky » Fri Feb 19, 2021 2:03 am

ryancousins

What is your "Cartesian coordinate separator? In this example it has to be a ;
Change the ; to the separator used by your QCAD or change it below: Application Preferences "Coordinate Format"
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..."

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Import Rectangles from a cutlist

Post by ryancousins » Fri Feb 19, 2021 2:24 am

Gottcha, thank you.

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Re: Import Rectangles from a cutlist

Post by Kramerica » Fri Feb 19, 2021 11:51 pm

This is a great forum! Discovering multiple ways to skin the cat. I'll be busy for the next week with another priority, but I'll dabble with these directions when I get a chance.

I will keep the forum posted with my progress - or lack there of. lol

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Re: Import Rectangles from a cutlist

Post by Kramerica » Sat Feb 20, 2021 12:11 am

Husky wrote:
Fri Feb 19, 2021 12:38 am
Kramerica wrote:
Tue Feb 16, 2021 4:11 am
I work for a cabinet shop, and I've manually been drawing approx 60 rectangles per kitchen. The sizes are generated from an Excel spreadsheet and are predefined based off the size of the cabinets.

I've seen (but don't yet understand) that you can import X,Y information into QCAD from a CSV. Does this relate to importing rectangles?

Example sizes:
8.25" x 22"
4.25" " 20"
3.55" x 20"
3.55" x 12.95"
Just for fun - I blame the pandemic for that!
Thinking about how that could be solved for someone with zero scripting skills like me. What we have is the size list and ... Excel. Good! I know one or two things about Excel ... e_surprised
Ok, I prepared an Excel spreadsheet, copy/paste the size list (random numbers) into the spreadsheet, searched/replaced in Excel to get rid of the useless unit etc. symbols - and my Excel function went to work immediately to created a Command Line list for QCAD with those information. This list copied - insert into QCAD Command Line - success.


QCAD Excel to cabinets.gif


I'm sure coder will call that "Primitive". However - it works. :lol: :lol: :lol:
The Gif is great, but flipping a bit too quick for me to see the dimensions in excel relative to how they are drawn in QCAD.
I had some success by writing:

re
0,59
28,89
84,65
22,43
qq

But it only drew two rectangles, and I'm not sure what the lines are relative to. Am I understanding it correctly?
re = rectangle
X,Y position 1 (first corner of first rectangle)
X,Y position 2 (second corner of first rectangle)
X,Y position 3 (first corner of second rectangle)
X,Y position 4 (second corner of second rectangle)
qq = Quit Command (or something like that)

Also, if these need to be polylines for CAM purposes - do I need to go the script route?

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

Re: Import Rectangles from a cutlist

Post by Husky » Sat Feb 20, 2021 1:25 am

Kramerica wrote:
Sat Feb 20, 2021 12:11 am
The Gif is great, but flipping a bit too quick for me to see the dimensions in excel relative to how they are drawn in QCAD.
I had some success by writing:

re
0,59
28,89
84,65
22,43
qq
Ha ha, you are not the first one who is struggling with that. :lol: To relax my PM box here are the numbers calculated by Excel:

re
0;58
28;89.5
28;69.5
58;89.5
58;58
86;89.5
86;64.5
114;89.5
114;58
129;89.5
0;0
28;36
28;0
58;36
58;0
86;36
86;0
114;36
114;0
129;36
qq

Kramerica wrote:
Sat Feb 20, 2021 12:11 am
But it only drew two rectangles, and I'm not sure what the lines are relative to. Am I understanding it correctly?
re = rectangle
X,Y position 1 (first corner of first rectangle)
X,Y position 2 (second corner of first rectangle)
X,Y position 3 (first corner of second rectangle)
X,Y position 4 (second corner of second rectangle)
qq = Quit Command (or something like that)
The lines are relative to Absolute 0;0. The cabinet calculation starts from the left to the right. Your understanding is correct - Re is the QCAD shortcut to draw a rectangle. qq = QCAD command "Reset/Idle". The RE command is asking for the first X/Y point and then asking for the second X/Y point of the rectangles. Position/calculation is based on Absolute 0 and the last rectangle to the left. For the overhead cabinets (I don't know the correct term for them :oops: ) the overall hight (89.5) is also considered in the calculation. There are many variants how you can set up the Excel Spreadsheet - depends on your relevant manufacturing workflow. Ones it is set for your requirements you have just to copy/paste the size list into that spreadsheet and the command list will be created immediately by Excel ...

Same Spreadsheet:
Husky-2021.02.19-03.png
Husky-2021.02.19-03.png (2.57 KiB) Viewed 8501 times
Kramerica wrote:
Sat Feb 20, 2021 12:11 am
Also, if these need to be polylines for CAM purposes - do I need to go the script route?
No. QCAD will use the last RE settings in the option bar. Make sure "Create Polylines" is ticked before you run the command list and you will get your polylines. But if you have forgotten you can do it later too (OG or OC).
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: 3476
Joined: Wed Sep 27, 2017 4:17 pm

Re: Import Rectangles from a cutlist

Post by CVH » Sat Feb 20, 2021 7:36 am

@Kramerica,

What Husky exploit is the multi-line paste for a tool.
https://qcad.org/rsforum/viewtopic.php? ... 924#p26925

Here 'RE' or a Rectangle from 2 points.
Followed by 2 references each rectangle.
References of opposite corners in your native format.
  • Without influence on the persistent tools settings.
    For tools without a dialog popping up.
    ...
    ..
    .
That goes well for one single method.
But may fail at some point when mixing tools.
https://qcad.org/rsforum/viewtopic.php?t=7017
https://qcad.org/rsforum/viewtopic.php?t=7454
In Andrews words:
andrew wrote:
Mon Mar 02, 2020 11:30 am
Your mileage may indeed vary when trying to launch / terminate multiple tools using this method (surprised you got that far e_surprised)
For some reason QCAD will double your last entry:
viewtopic.php?t=6989
That is why Husky terminates the list with 'QQ' = Reset/Idle
Notice in the GIF that 'QQ' is doubled up what doesn't harm anything.

For some reasons it may only work on the second trial ...
See mixed outcomes in mentioned topics.

We exhausted this method for multiple tools.
That is where the script comes in.
Now John Hyslop and everyone else can draw panels with cut-outs.
Table tops too. Whatever you desire.
There is no limit to what the script can cast from CSV, only but your spreadsheet abilities.

And now I rest my case.
'Just for fun' ... I think not.
If Husky really wants that, I will withdraw the free and functional script:
https://qcad.org/rsforum/viewtopic.php?t=8135

CVH
Last edited by CVH on Mon Feb 22, 2021 5:21 am, edited 2 times in total.

Kramerica
Newbie Member
Posts: 8
Joined: Tue Feb 16, 2021 4:04 am

Re: Import Rectangles from a cutlist

Post by Kramerica » Sat Feb 20, 2021 4:27 pm

I will be installing the script. Thank you for uploading.

Post Reply

Return to “QCAD 'How Do I' Questions”