[Python] .connectEdgesToWires() not building the longest possible wire

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

[Python] .connectEdgesToWires() not building the longest possible wire

Post by brst »

Hello forum members,

I am trying to apply the solution of this thread "https://forum.freecadweb.org/viewtopic.php?f=22&t=35723".
The difference here is, that there aren't two faces now, but a face and its projection.

So the problem here is, that the length of the Wires from the face and the compound's Wire list is different from the Wires list length. The face's wire list got the OuterWire/Wire merged into one Wire.

In order to merge the OuterWire into one Wire in the projection too, I used the following code:

Code: Select all

project = Face2.project([face1])

comp = Part.makeCompound([])
comp.add(project)
comp.Wires
[]
comp.connectEdgesToWires()
according to the documentation, it should already merge the longest possible wire possible, but it does not, even with using a reasonable
tolerance and trying out the Shared=True and =False option

Following is my failing approach to form the longest wire manually:

Code: Select all

outerWire = []
lenOuterWire = len(face.Wires[0].Edges)
for wire in comp.Wires[slice(None, lenOuterWire)]:
	outerWire.append(wire)

wire1 = Part.Wire(outerWire) 
wire2 = Part.Wire(comp.Wires[slice(lenOuterWire,None)])
wire2.append(wire1) 
#Part.OCCError: class Standard_NoSuchObject BRepFill_CompatibleWires::SameNumberByPolarMethod : the wires must be closed

wire1.isClosed()
# prints False
#The other wires are closed

wire1 = Part.Wire(outerWire, closed = True)  # didn't raise an error, but still is not closed.

wire = Part.Wire(project.Edges) # leads to Part.OCCError: BRep_API: command not done

Attachments
project_and_original_face.PNG
project_and_original_face.PNG (19.01 KiB) Viewed 526 times
FreeCAD rookie
Post Reply