Projection Bug / resulting edges aren't joining to a Wire

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Projection Bug / resulting edges aren't joining to a Wire

Post by MRx »

Hi,

I have this object
OK4r0Y.png
OK4r0Y.png (7.49 KiB) Viewed 667 times
once I do a projection I can't get the wire anymore to recreate a face from the projected object, does anyone know how to fix that?

Code: Select all

print("original wire")
Part.Wire(App.ActiveDocument.a.Shape.Edges).Edges
print("create a projection")
e=App.ActiveDocument.b.Shape.project([App.ActiveDocument.a.Shape])
e.Edges
print("sort edges, wrong grouped - original wire is dead")
Part.sortEdges(e.Edges)

Code: Select all

>>> print("original wire")
original wire
>>> Part.Wire(App.ActiveDocument.a.Shape.Edges).Edges
[<Edge object at 0x7ffb0cae6c50>, <Edge object at 0x7ffb0ae17aa0>, <Edge object at 0x7ffb0ae8a750>, <Edge object at 0x7ffb0ae99130>, <Edge object at 0x7ffb0ae92e50>]
>>> print("create a projection")
create a projection
>>> e=App.ActiveDocument.b.Shape.project([App.ActiveDocument.a.Shape])
>>> e.Edges
[<Edge object at 0x7ffb0ab879c0>, <Edge object at 0x7ffb0ab0ae30>, <Edge object at 0x7ffb0abb6ee0>, <Edge object at 0x7ffb0ab0cee0>, <Edge object at 0x7ffb0c897970>]
>>> print("sort edges, wrong grouped - original wire is dead")
sort edges, wrong grouped - original wire is dead
>>> Part.sortEdges(e.Edges)
[[<Edge object at 0x7ffb0ad47610>, <Edge object at 0x7ffb0ad0af30>], [<Edge object at 0x7ffb0cbd4b20>, <Edge object at 0x7ffb0cbd4ba0>, <Edge object at 0x7ffb0cbfe460>]]

Code: Select all

>>> for i in e.Edges:
...     print("%s %s" % (str(i.valueAt(i.FirstParameter)), str(i.valueAt(i.LastParameter))))
... 
Vector (62.0, -11.819997052357218, -4.200000000000213) Vector (62.0, -3.3199967188075306, -4.200000000000213)
Vector (62.0, -11.819997052357218, -4.200000000000213) Vector (57.74453838142966, -11.819997052357218, -4.200000000000213)
Vector (57.74453755985066, -11.819997526696032, -4.200000000000213) Vector (50.668701354376935, -4.499997052357316, -4.200000000000214)
Vector (50.668701354376935, -4.499997052357315, -4.200000000000213) Vector (48.502275716517204, -3.3199970523573406, -4.200000000000213)
Vector (62.0, -3.319997052357227, -4.200000000000213) Vector (48.50227571651723, -3.319997052357227, -4.200000000000213)
Attachments
projectionbug.FCStd
(9.02 KiB) Downloaded 13 times
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: Projection Bug / resulting edges aren't joining to a Wire

Post by MRx »

ok I solved it myself with fixTolerance.
To add here, after fixTolerance, the item has to go through Part.Wire() to work with Part.sortEdges, directly running Part.sortEdges on the original item will still not work

Code: Select all

>>> Part.Wire(m.Edges)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Part.OCCError: BRep_API: command not done
>>> m.fixTolerance(1e-4)
>>> Part.Wire(m.Edges)
<Wire object at 0x7ffb0c8ac260>
>>> Part.Wire(m.Edges).Edges
[<Edge object at 0x7ffb08c61a20>, <Edge object at 0x7ffb0c5ebe50>, <Edge object at 0x7ffb0c58d220>, <Edge object at 0x7ffb0c6ee270>, <Edge object at 0x7ffb0c6e0ea0>]
>>> 
Post Reply