Draft 2d offset

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
VVM
Posts: 10
Joined: Sun Oct 17, 2021 7:21 am

Draft 2d offset

Post by VVM »

OS: Debian GNU/Linux 11 (bullseye) (LXDE/LXDE)
Word size of FreeCAD: 64-bit
Version: 0.20.26720 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 7bca26e)
Hash: 7bca26e7c14d4d43374ff7e0c8582735b249cbfd
Python version: 3.9.9
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: Russian/Russia (ru_RU)

Sorry, im not speak english.
2d_offset_1.png
2d_offset_1.png (15.51 KiB) Viewed 2070 times
2d_offset_2.png
2d_offset_2.png (13.81 KiB) Viewed 2070 times
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft 2d offset

Post by Roy_043 »

File?

Both solutions seem valid to me, although I know that other CAD programs (DwgCAD) will do this differently.
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Draft 2d offset

Post by chrisb »

A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
paullee
Veteran
Posts: 5119
Joined: Wed May 04, 2016 3:58 pm

Re: Draft 2d offset

Post by paullee »

Wondering if the wire is not really closed, so it offset like the way it shows?

Need the model file for avoidance of doubt :)
VVM
Posts: 10
Joined: Sun Oct 17, 2021 7:21 am

Re: Draft 2d offset

Post by VVM »

File:
Draft_2D_offset.FCStd
(8.24 KiB) Downloaded 63 times
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft 2d offset

Post by Roy_043 »

There is a bug in the isReallyClosed() code used by the Draft_Offset command. It only checks if the first vertex of the first edge and the last vertex of the last edge coincide. But since the direction of the edges can vary, there are in fact 4 possibilities.

https://github.com/FreeCAD/FreeCAD/blob ... #L272-L276
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft 2d offset

Post by Roy_043 »

https://github.com/FreeCAD/FreeCAD/pull/5496

Edit:
Oops, it's not that simple. Will have to do some more checks. :mrgreen:
paullee
Veteran
Posts: 5119
Joined: Wed May 04, 2016 3:58 pm

Re: Draft 2d offset

Post by paullee »

Roy_043 wrote: Fri Feb 04, 2022 10:14 am There is a bug in the isReallyClosed() code used by the Draft_Offset command. It only checks if the first vertex of the first edge and the last vertex of the last edge coincide. But since the direction of the edges can vary, there are in fact 4 possibilities.

https://github.com/FreeCAD/FreeCAD/blob ... #L272-L276
Interesting :D

Should need to test Orientation then, would elaborate. In the meantime, this is history of revision for reference :)

https://github.com/FreeCAD/FreeCAD/comm ... c32b9856ce

https://github.com/FreeCAD/FreeCAD/comm ... 21581570b0#
paullee
Veteran
Posts: 5119
Joined: Wed May 04, 2016 3:58 pm

Re: Draft 2d offset

Post by paullee »

The arc edge orientation is found 'Reversed' - a situation I remember usually happen 'within edit mode' (EDIT: of a Sketch) for an arc. The arc (EDIT: geometry 'within a Sketch in edit mode') is always counter-clockwire in edit mode to my memory.

So it seems needs to verify the Vertex for testing should be 'Forward', otherwise switch to another Vertex.

Code: Select all

s=Gui.Selection.getSelection()[0]
ss=s.Shape
ssw=ss.Wires[0]

import draftgeoutils.wires as wires
wires.isReallyClosed(ssw)
False

# wire.Vertexes[0] is not wire.Vertexes[-1] as previously noted
ssw.Vertexes[0].Point
Vector (22.016533000365484, -22.04014152497416, 0.0)

ssw.Vertexes[-1].Point
Vector (-22.203595540784868, -21.85167977200638, 0.0)

ss.Edges
[<Edge object at 0x7f8d1400bbf0>, <Edge object at 0x55572c84ba60>, <Edge object at 0x55572c5d3ed0>, <Edge object at 0x55572c1a2760>, <Edge object at 0x55572c1a27e0>, <Edge object at 0x55572c1a2860>, <Edge object at 0x55572c1a28e0>, <Edge object at 0x55572c807610>]

sse1=ss.Edges[0]
sse1.Vertexes[0].Point
Vector (22.016533000365484, -22.04014152497416, 0.0)

len(ss.Edges)
8

# last edge Vertexes[1] is not 1st edge Vertexes[0]
sse2=ss.Edges[7]
sse2.Vertexes[1].Point
Vector (-22.203595540784868, -21.85167977200638, 0.0)


# found it is last edge Vertexes[0] == 1st edge Vertexes[0]
sse2.Vertexes[0].Point
Vector (22.016533000365484, -22.04014152497416, 0.0)

sse2v0=sse2.Vertexes[0]
sse2v1=sse2.Vertexes[1]

# found the vertex orientation is 'Reversed' for the arc
sse2v0.Orientation
'Reversed'

sse2v1.Orientation
'Forward'

sse1v0=sse1.Vertexes[0]
sse1v1=sse1.Vertexes[1]
sse1v0.Orientation
'Forward'
sse1v1.Orientation
'Reversed'


User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft 2d offset

Post by Roy_043 »

I was unaware of the Orientation property of vertices. It is indeed interesting. But why do we have the Draft isReallyClosed() function? what is wrong with isClosed()?
Last edited by Roy_043 on Fri Feb 04, 2022 5:26 pm, edited 1 time in total.
Post Reply