Page 1 of 2

How to combine entities to a new outline? [SOLVED]

Posted: Thu Dec 19, 2019 2:37 pm
by plaatjesprater
Hello there,

I'm an experienced cad-user and I like Qcad, but here I'm a new user and I have difficulies in a recent design for a coaster. The design is made with a lot of ovals (see image). Now I want tot make it ready for a lasercutter. The lines you see now will be halfcut and there is an outline to be made for the overall form and two small inner lines too (for the 'eyes'). But how to make this outline/inline? In my old cad-program I could unite all the entities to a new path/spline/polyline-like object.For the inner open zone (eyes) I could have used a bucket tool to define such a ployline/spline. How can I perform such actions in Qcad?

Regards,

Kasper


systems Win 10, Qcad 3.23

Re: How to combine entities to a new outline?

Posted: Thu Dec 19, 2019 9:14 pm
by andrew
QCAD does not have tools for boolean operations on closed shapes nor a bucket fill type tool. Both are very complex operations when arcs, ellipses, splines are involved.

For an approximation of the union (outer most contour), you can use a simple script as follows:

1. Open the script shell (Misc > Development > Script Shell)
2. Select all ellipses
3. Paste the script below in to the command line of the script shell. Note that this is extremely crude code without any checks that might crash your QCAD. Be sure to save your work first. You also might want to do this with a copy of the ellipses as the ellipses will be converted into polylines in the process.

Code: Select all

RSettings.setValue("Explode/EllipseSegments", 1024);
doc=getDocument()
ids=doc.querySelectedEntities()
clipper=new RPolygonClipper()
for (i=0; i<ids.length; i++) {
    clipper.addSubjectPath(doc.queryEntity(ids[i]).getData().getVertices());
}
clipper.execute(RS.Union, RS.NonZero, RS.NonZero);
addPolyline(clipper.getSolutionPath(0), true)

Re: How to combine entities to a new outline?

Posted: Sat Dec 21, 2019 2:09 pm
by plaatjesprater
This could have been a simple and elegant solution, but it didn't work because qcad crashed. I tought: let's do the boolean trick in Inkscape and work on in Qcad but that wasn't easy as well.
Exported the drawing to Inkscape as svg and made the outline (that was the easy part).
Imported the new made outline in qcad but it would not show. Strange because other shapes I made as svg had no problems. Then I exported from Inkscape as dxf12 with a better result. Transformed the splines and lines to a new polyline to find out there was a little vertical scale problem (see picture, the white outline doesn't really fit). It is still a funny drawing but not exactly following the plan I had.

Nobody is to blaim because of my strange workflow of exporting and importing but I don't exactly understand what goes wrong.

Is there a reason boolean actions are not supported in qcad, or is this the reason? Is there a change qcad will have them in the future or is this a irrelevant question?

Re: How to combine entities to a new outline?

Posted: Sat Dec 21, 2019 3:09 pm
by plaatjesprater
I tried another way of solving the issue. In the picture is seen that two circles with offset distance deliver a nice result. When I try this with 34 elipses it doesn't. My idea was to do it with the offset tool and then make an inner offset line as well. That one should then correspond with the orginal form of the 34 elipses. Next time I tried with 4 elipses it crashed.

Re: How to combine entities to a new outline?

Posted: Sat Dec 21, 2019 5:26 pm
by andrew
Can you attach an example that crashes? Does it really crash or just hang, i.e. the operation takes very long? Note that if QCAD is "not responding" that does not mean it crashed but simply that it's busy.

Re: How to combine entities to a new outline?

Posted: Sat Dec 21, 2019 6:16 pm
by plaatjesprater
OK finally I found a way to realize it. The critical mistake was that I accidentally scaled the group of entities in Inkscape. So I tried everything again and then it finally worked.

So in short description:
Export to Inkscape with advanced svg export
In Inkscape everything disapeared, set linewidth to 0,1 and the lines appear again
The import from Qcad is twice grouped: Object > ungroup > 2x
copy all lines to keep the originals (just to be sure)
select all lines: path > unite
The result is exported as dxf r14 lwpolyline selected
Imported in the qcad drawing
select the lines and convert to polyline by 'polyline from segments' (OG)
a little scaling was needed: modify > scale > by mouse (choose in dialog)

Result in the image
Afterwards the offset tool (offset with distance) worked fine

So for other users who want to perform tricks like this, this is a way to do a boolean operation nice and pretty easy if you follow these steps.

Re: How to combine entities to a new outline?

Posted: Sat Dec 21, 2019 7:56 pm
by CVH
plaatjesprater wrote:
Sat Dec 21, 2019 3:09 pm
Next time I tried with 4 elipses it crashed.
Hi,
I tried 4 ellipse and it works using polylines as intermediate.
4xEllipse + offset.png
4xEllipse + offset.png (18.67 KiB) Viewed 2349 times

Regards,
CVH

Re: How to combine entities to a new outline?

Posted: Sun Dec 22, 2019 9:54 am
by plaatjesprater
@CVH Did you change the elipses into polylines first? What function did you use for that? I still feel like a greenhorn in Qcad, but getting more used to it day by day. :oops:
I ordered the qcad-book on lulu, but it is little delayed by christmas madness.

@Andrew: The crash did happen, but I couldn't reproduce it. It might be something like I was impatiened and doing too much at the same time. Nonetheless here is the file that I finally made with Inkscape, perfect result in the end. I'm still curious how to do this within qcad because that is obviously my goal. The closed white contour is made in Inkscape, the second is an offset in Qcad.

Is it a good idea to make a proposal for a uniting boolean tool? This is by far the most used variation and maybe almost there by the offset tool. Or maybe is a handy workflow of the offset tool allready good enough?

Regards, Kasper

Re: How to combine entities to a new outline?

Posted: Sun Dec 22, 2019 11:19 am
by CVH
Hi,

Selection -> Modify / Explode
But in the end there is something limiting in offsetting a multi selection off polys. :oops:
Will file a bugreport.

It's a long way around. Left - Right - twice selecting where to offset.

It doesn't come out perfect also due to the limited approximation.
Used 64 segments to explode the ellipses.
Further, an offset of an ellipse is never an ellipse itself. :(
Offsettting non-ellipses back or one further and two back is never ellipsoid.
Flaws add up. :cry:

Regards,
CVH

Re: How to combine entities to a new outline?

Posted: Sun Dec 22, 2019 11:30 am
by CVH

Re: How to combine entities to a new outline? [SOLVED]

Posted: Sun Dec 22, 2019 6:08 pm
by plaatjesprater
Very convincing result CVH! Now i see how to do this easy within Qcad. I'm still curious wether it is a good idea to propose a new feature with one or a few boolean functions. On the other hand, this is the 'brainpower method' as Husky stated. Thanks for your help!

Re: How to combine entities to a new outline? [SOLVED]

Posted: Sun Dec 22, 2019 6:34 pm
by CVH

Very bad result too
:!:

Did not need 'Brainpower', Divide et impera.
plaatjesprater wrote:
Sun Dec 22, 2019 6:08 pm
'brainpower method' as Husky stated.
Where did he that :?:

Thanks all together,
CVH

Re: How to combine entities to a new outline? [SOLVED]

Posted: Sun Dec 22, 2019 8:05 pm
by plaatjesprater
The quote of Husky was made in a basic tutorial on youtube. It was a funny quote so I remenbered it.

Last question for the moment: you said the elips was divided in 64 points in a polyline. When I repeated your action, it made only 32. Do you know where this can be ajusted, or is it in the program preferences?

Re: How to combine entities to a new outline? [SOLVED]

Posted: Sun Dec 22, 2019 8:26 pm
by CVH
Edit / Application Preferences / Modify / Explode. 8)
Not happy with the segments thing =relative accuray.

Using offsets a lot.
Fighting errors a lot.
I come by there more than once a day.

Regards,
CVH

Re: How to combine entities to a new outline? [SOLVED]

Posted: Wed Dec 25, 2019 12:21 pm
by plaatjesprater
I still have issues combining polygons with offset. See these results in the images. Maybe I do something wrong but I can't find out what it could be. 3 polygons are selected but only 2 want to offset. Is there something to prevent this? In the case wilt elipses there were 4 of them perfectly combined?