[SOLVED] Wire.isClosed() not working

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
brst
Posts: 87
Joined: Thu Apr 18, 2019 10:11 am
Location: Germany

[SOLVED] Wire.isClosed() not working

Post by brst »

Hello i got an
Message: class Standard_ConstructionError BRepFill :: profiles are inconsistent
error I wanted to post about, as i already tested if the profiles are closed.
Then I found out, that contrary to what the .isClosed() function tells me, the wire isn't actually closed, see screenshots.

Code: Select all

p = Part.read("C:/temp/error94.brp")
p.Wires
#[<Wire object at 0000022067457E30>]
p.Wires[0].isClosed()
#True
[vertex.Point for edge in p.Wires[0].Edges for vertex in edge.Vertexes]
#[Vector (-27.502025096552103, -27.5, 0.0), Vector (-27.5, 0.0, 0.0), Vector (-1.52262870366859e-08, -27.5, 0.0), Vector (-27.5, 0.0, 0.0), Vector #(-27.502025096552103, -27.5, 0.0), Vector (-1.52262870366859e-08, -27.5, 0.0)]

So there actually is a gap, which is not detected. In order to close the wire, I first need to know if it's broken.
Attachments
error94.brp
(1.52 KiB) Downloaded 23 times
2.PNG
2.PNG (3.51 KiB) Viewed 808 times
1.PNG
1.PNG (6.1 KiB) Viewed 808 times
Last edited by brst on Mon Jul 15, 2019 6:42 am, edited 1 time in total.
FreeCAD rookie
User avatar
brst
Posts: 87
Joined: Thu Apr 18, 2019 10:11 am
Location: Germany

Re: Wire.isClosed() not working

Post by brst »

.
Last edited by brst on Fri Jul 12, 2019 1:49 pm, edited 1 time in total.
FreeCAD rookie
wmayer
Founder
Posts: 20308
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Wire.isClosed() not working

Post by wmayer »

Then I found out, that contrary to what the .isClosed() function tells me, the wire isn't actually closed, see screenshots.
The wire describes the topology and it has three vertexes, not four:

Code: Select all

len(p.Vertexes) # is 3
So, from topology point of view there is no gap.

But it's true that the geometry has a gap:

Code: Select all

edge1.valueAt(edge1.LastParameter).distanceToPoint(edge2.valueAt(edge2.LastParameter)) # gives 0.00202
which is actually quite high. However, the tolerance of the vertex is 0.005, i.e. it's higher than the geometric gap

Code: Select all

edge1.Vertex2.Tolerance
and that's why it's not considered as gap.

So, the question is why there's set such a high tolerance. Usually you have values of 1e-7.
User avatar
brst
Posts: 87
Joined: Thu Apr 18, 2019 10:11 am
Location: Germany

Re: Wire.isClosed() not working

Post by brst »

Hmm this is from an imported step file intersected with a cube. The error just started to occur when I replaced the cube.cut(part) with cube.cut(part,0.01).

Code: Select all

p.fixTolerance(1e-7)
p.getTolerance(1)
#1e-07
p.getTolerance(-1)
#1e-07
# so setting the tolerance worked
p.Wires[0].isClosed()
#True
If the tolerance is set to 1e-7, the result is still the same :o
FreeCAD rookie
wmayer
Founder
Posts: 20308
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Wire.isClosed() not working

Post by wmayer »

The isClosed() method doesn't perform a real check but just queries a flag that was set presumably during the import. So, when you change the tolerance afterwards it doesn't reset this flag.

But what you can do is re-creating the topology from scratch:

Code: Select all

edge1=p.Edge1
edge2=p.Edge2
edge3=p.Edge3

c1=edge1.Curve.trim(*edge1.ParameterRange)
c2=edge2.Curve.trim(*edge2.ParameterRange)
c3=edge3.Curve.trim(*edge3.ParameterRange)

edges=[c1.toShape(), c2.toShape(), c3.toShape()]
wire=Part.Wire(edges)
wire.isClosed()
For me isClosed() returns False now.
User avatar
brst
Posts: 87
Joined: Thu Apr 18, 2019 10:11 am
Location: Germany

Re: [SOLVED] Wire.isClosed() not working

Post by brst »

That works, thank you!
FreeCAD rookie
Post Reply