Sketcher Offset

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Sketcher Offset

Post by onekk »

I have had same problem.

tested on

Code: Select all

OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.27861 (Git)
Build type: Release
Branch: (HEAD detached at 6de9b3d)
Hash: 6de9b3d26e3549d50b9708995bb22c71ae7994c1
Python 3.9.10, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: Italian/Italy (it_IT)
Installed mods: 
  * Curves 0.3.0
if you have a wire, you could try this:

Code: Select all

objc1 = wire.makeOffset2D(-3, 2)
  • first parameter is used to determine the offset in this case a negative 3.0mm
  • second parameters is used to determine transitions, using 2 you will have intersection
see maybe:
makes an offset shape (2d offsetting).
makeOffset2D(offset, [join = 0, fill = False, openResult = false, intersection =
false]) -> Shape
--
The function supports keyword
arguments. Input shape (self) can be edge, wire, face, or a compound of those.

* offset: distance to expand the shape by. Negative value will shrink the
shape.

* join: method of offsetting non-tangent joints. 0 = arcs, 1 = tangent, 2 =
intersection

* fill: if true, the output is a face filling the space covered by offset. If
false, the output is a wire.

* openResult: affects the way open wires are processed. If False, an open wire
is made. If True, a closed wire is made from a double-sided offset, with rounds
around open vertices.

* intersection: affects the way compounds are processed. If False, all children
are offset independently. If True, and children are edges/wires, the children
are offset in a collective manner. If compounding is nested, collectiveness
does not spread across compounds (only direct children of a compound are taken
collectively).

Returns: result of offsetting (wire or face or compound of those). Compounding
structure follows that of source shape.

This is the result with 2 (and 1) as join value:

stra_off.png
stra_off.png (5.05 KiB) Viewed 4832 times

This is the result for 0 or when you not specify a join value:

stra_off0.png
stra_off0.png (4.62 KiB) Viewed 4828 times
Hope it helps


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
paddle
Veteran
Posts: 1396
Joined: Mon Feb 03, 2020 4:47 pm

Re: Sketcher Offset

Post by paddle »

czinehuba wrote: Tue Mar 15, 2022 4:07 pm Yes. It might be a complicated. I just tough If it isn't that complicated and it's possible to do it. It is very useful. For creating enclosure where there's a need for lips or o rings and many more.

Basically just it's one dimension on length which will be constant between existing geometry. It could be implemented with construction lines, equal constraints and normal with in FreeCAD.
It appeared that you can't add all the lines for every offset edge or you get massive overconstraints. Then you have the tangent of the arcs which add constraints to consider. All in all it got very complex but I somehow managed to make something that work rather well. Only a few parallel overconstraints in some edges cases that I can't figure out how to catch.

phpBB [video]
shamanths13
Posts: 80
Joined: Mon Feb 21, 2022 3:02 pm

Re: Sketcher Offset

Post by shamanths13 »

paddle wrote: Thu Mar 17, 2022 5:08 pm ping
Awesome work dude! Get well soon!
I have a question: How does the offset tool interact with a sketch with 2 or more sectioned areas with a common edge? For example, like 2 squares touching each other with a common line, like an '8' on a 7 segment LCD display(hope I'm explaining this properly)?
Cheers!
User avatar
paddle
Veteran
Posts: 1396
Joined: Mon Feb 03, 2020 4:47 pm

Re: Sketcher Offset

Post by paddle »

That's an edge case that I haven't explored. I guess it will take one closed wire and one open wire.
User avatar
czinehuba
Posts: 159
Joined: Mon Oct 15, 2018 4:59 am
Location: UK
Contact:

Re: Sketcher Offset

Post by czinehuba »

paddle wrote: Thu Mar 17, 2022 5:08 pm
This is awesome. Looking forward to play with this. I think it will work 99% of the use cases for actual work.... :mrgreen: :mrgreen: :mrgreen:
matus
Posts: 1
Joined: Mon Jan 09, 2023 2:03 pm

Re: Sketcher Offset

Post by matus »

Hi there,

I just stumbled upon this piece of work. It looks promising, are there any plans to create PR to main branch?

Thank you for your work!
User avatar
NewJoker
Veteran
Posts: 3021
Joined: Sun Oct 11, 2020 7:49 pm

Re: Sketcher Offset

Post by NewJoker »

matus wrote: Mon Jan 09, 2023 2:15 pm I just stumbled upon this piece of work. It looks promising, are there any plans to create PR to main branch?
From what I know, the sketcher widget will have to be merged first and for that to happen, the main merger for this wb (Abdullah) has to review all the work by paddle which is now done in his own branch. Abdullah is often busy and hence the delays. But let's ask @paddle for an update.
User avatar
paddle
Veteran
Posts: 1396
Joined: Mon Feb 03, 2020 4:47 pm

Re: Sketcher Offset

Post by paddle »

NewJoker wrote: Mon Jan 09, 2023 3:34 pm
matus wrote: Mon Jan 09, 2023 2:15 pm I just stumbled upon this piece of work. It looks promising, are there any plans to create PR to main branch?
From what I know, the sketcher widget will have to be merged first and for that to happen, the main merger for this wb (Abdullah) has to review all the work by paddle which is now done in his own branch. Abdullah is often busy and hence the delays. But let's ask @paddle for an update.
This is correct. Offset requires tool settings which is still pending. So offset is down the waiting line.

It is out of my hands so I can't say when it will merge. Abdullah was about to start merging the first tool settings in June, but life happened and it got postponed. Don't hold you breath though. At the rate things merge I would be surprise if offset merges in 2023.
Hologram
Posts: 201
Joined: Thu Nov 03, 2022 3:05 pm

Re: Sketcher Offset

Post by Hologram »

paddle wrote: Tue Mar 15, 2022 2:26 pm
czinehuba wrote: Tue Mar 15, 2022 2:15 pm Really great work. If you could add offset constraint that would be even better. So we can keep it parametric and adjust the distance if we need to.
What you describe as offset constraint would mean to have a special kind of curve 'offsetcurves' that are dependant on their original geometries.
The pros :
- You can edit the offset length easily

The cons :
- You can't edit the offset curves easily.
- It's a extremely huge task as Abdullah explained in this thread : https://forum.freecadweb.org/viewtopic. ... 55#p578755

So for now we have this independant offset :)

Hmm
Another way would be to have a set of constraint created that are linked to a overall value (the offset length). But that feels quite difficult to make.
In Fusion 360, there is such an offset constraint. It is basically a master constraint, which I presume just recomputes the offset every time the source curve is modified. This would explain why it doesn't allow for offsetting offsets.
If you delete the offset constraint, you'll have a second series of curves that maintains most of the constraints, but drops the cobstraints that determine the overall length of the offet curves. A bit like the offset you've shown. This makes for a convenient workflow to quickly apply constraints for parallel curves.This is all really exiting stuff even compared to commercial offerings. I really hope it does get merged sooner, rather than later. Thanks for your work on this!
Hologram
Posts: 201
Joined: Thu Nov 03, 2022 3:05 pm

Re: Sketcher Offset

Post by Hologram »

@paddle Just checked the latest 0.21 build, do you have any timeline for the merger of the auto-constraint and mouse group dragging features? Was hoping these would already be in master :)
Post Reply