Convert spline to DWire (for offsetting)

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Convert spline to DWire (for offsetting)

Post by montagdude »

Here is my situation. I am working on designing a model plane with balsa/liteply construction. FreeCAD is handling the "hard" part of this -- 3D part creation -- just fine. Once I finish drawing the 3D parts, I need to have them laser cut. This means I need to convert to 2D, offset slightly to account for the width of the laser beam, and trim off some small sections of each part to keep them attached to the piece of wood once the cutting is done. I'm having issues with the offsetting part of this process. I'm finding that draft offset does not work for many of my parts. I believe this is because some of the edges are actually splines or derived from splines. It seems to work okay with DWires. So my question is, is it possible to convert a spline or other edge to a DWire automatically? Even better, if it can be done for a wire consisting of multiple edges, some of which may be splines. Alternatively, if there is another solution to my offsetting problem, that would be welcomed too. Otherwise, I may have to just bite the bullet and do these final steps in a different CAD tool better suited to 2D.

A sample file is attached, which contains a single wire that I am not able to offset. I am using the official FreeCAD 0.18 AppImage on Slackware. Thanks in advance for your help.
Attachments
test.FCStd
(3.66 KiB) Downloaded 44 times
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Convert spline to DWire (for offsetting)

Post by Chris_G »

The problem is not the BSplines.
The shape in the test file is a compound of individual edges, it is not a wire.
You need to Draft->Upgrade it to a wire.
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: Convert spline to DWire (for offsetting)

Post by montagdude »

Does the offset work for you after upgrading it? I still get this error:

Code: Select all

the offset tool is currently unable to offset a non-Draft object directly - Creating a copy
('[Draft.todo.commit] Unexpected error:', <class 'AttributeError'>, 'in ', ['Draft.offset(FreeCAD.ActiveDocument.Wire,FreeCAD.Vector(56.91583887605228,2.6645352591003757e-15,0.0),copy=False,occ=False)', 'FreeCAD.ActiveDocument.recompute()'])
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Convert spline to DWire (for offsetting)

Post by Chris_G »

Part->Offset2D works.
Draft->Offset doesn't.
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: Convert spline to DWire (for offsetting)

Post by montagdude »

Thanks! I hadn't noticed the Part -> Offset2D function. It almost does what I need. The only problem is that after offsetting, sharp corners are now rounded. I need them to remain sharp. I've tried the different Join Type options, but unfortunately Arc is the only one that results in a valid offset. Any ideas?
Attachments
offset.png
offset.png (38.18 KiB) Viewed 1639 times
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: Convert spline to DWire (for offsetting)

Post by montagdude »

Well, if there is no solution to the rounded corners issue, unfortunately it looks like I will probably switch to another CAD program for this operation. I do think my original idea of converting everything to DWires would work, because draft offset with DWires works fine and does not round corners. But for now, I think I will take the path of least resistance.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Convert spline to DWire (for offsetting)

Post by vocx »

montagdude wrote: Wed Sep 25, 2019 7:26 pm Well, if there is no solution to the rounded corners issue, ...
Did you try all the options of Draft Offset? This tool is a particular implementation of internal commands, like DraftGeomUtils.offsetWire().

But not all options are readily available for the graphical interface. In some cases you need to call the functions from the command line.

For example, Draft.offset() seems to call this function

Code: Select all

DraftGeomUtils.offsetWire(obj.Shape, delta, occ=True)
Maybe setting occ=False would work.

Internally, offsetWire() seems to call Part.Wire.makeOffset() in some cases, and DraftGeomUtils.offset() in others.

The geometry probably can be offset correctly, but the right options are hard to track.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Convert spline to DWire (for offsetting)

Post by TheMarkster »

montagdude wrote: Wed Sep 25, 2019 7:26 pm Well, if there is no solution to the rounded corners issue, unfortunately it looks like I will probably switch to another CAD program for this operation. I do think my original idea of converting everything to DWires would work, because draft offset with DWires works fine and does not round corners. But for now, I think I will take the path of least resistance.
Part 2d offset has an Intersection option (instead of Arc) that will give squared corners instead of rounded ones.
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: Convert spline to DWire (for offsetting)

Post by montagdude »

vocx wrote: Wed Sep 25, 2019 9:10 pm
montagdude wrote: Wed Sep 25, 2019 7:26 pm Well, if there is no solution to the rounded corners issue, ...
Did you try all the options of Draft Offset? This tool is a particular implementation of internal commands, like DraftGeomUtils.offsetWire().

But not all options are readily available for the graphical interface. In some cases you need to call the functions from the command line.

For example, Draft.offset() seems to call this function

Code: Select all

DraftGeomUtils.offsetWire(obj.Shape, delta, occ=True)
Maybe setting occ=False would work.

Internally, offsetWire() seems to call Part.Wire.makeOffset() in some cases, and DraftGeomUtils.offset() in others.

The geometry probably can be offset correctly, but the right options are hard to track.
I did try all the GUI options, but I haven't tried messing with the python commands. Thanks for the tip. I'll try and report back if I can get it to work.
montagdude
Posts: 54
Joined: Tue Jan 08, 2019 9:04 pm

Re: Convert spline to DWire (for offsetting)

Post by montagdude »

TheMarkster wrote: Thu Sep 26, 2019 12:19 am
montagdude wrote: Wed Sep 25, 2019 7:26 pm Well, if there is no solution to the rounded corners issue, unfortunately it looks like I will probably switch to another CAD program for this operation. I do think my original idea of converting everything to DWires would work, because draft offset with DWires works fine and does not round corners. But for now, I think I will take the path of least resistance.
Part 2d offset has an Intersection option (instead of Arc) that will give squared corners instead of rounded ones.
Yes, as I mentioned, only Arc gives me a valid offset. All the other options and combination of options result in either nothing or only a small segment.
Post Reply