View Issue Details

IDProjectCategoryView StatusLast Update
0002777PartDesignBugpublic2020-07-16 02:56
Reporterhuskier Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
PlatformWindowsOSWindowsOS Version10
Product Version0.15 
Summary0002777: Part.Wire two individual edges (wires)
DescriptionWhen I execute the following code in FreeCAD's python console
>>> from FreeCAD import Base
>>> e1 = Part.makeCircle(1.6, Base.Vector(-23.5,0,0), Base.Vector(0,0,1))
>>> e2 = Part.makeCircle(1.6, Base.Vector(23.5,0,0), Base.Vector(0,0,1))
>>> ws = Part.Wire([e1,e2])

The system gives error as following:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
Part.OCCError: BRep_API: command not done
Steps To ReproduceJust following the description's code.
TagsNo tags attached.
FreeCAD Information

Activities

wandererfan

2016-11-19 13:07

manager   ~0007466

e1 and e2 are not connected. what result were you expecting?

huskier

2016-11-19 14:28

reporter   ~0007467

Last edited: 2016-11-19 15:18

Thanks @wandererfan.

I expect that e1 and e2 are combined into a wire group or a whole wire with two individual wires.

For the next step, I want to extrude ws.
>>> ws = Part.Wire([e1,e2])

wmayer

2016-11-19 14:54

administrator   ~0007469

A wire group or a wire containing two wires isn't possible and doesn't make any sense.
According to OpenCascade a wire is defined as either a set of connected edges or a single edge.

If you want to have a group of wires you must use a compound:
ws = Part.Compound([Part.Wire(e1.Edges), Part.Wire(e2.Edges)])

huskier

2016-11-19 15:17

reporter   ~0007470

Last edited: 2016-11-19 15:22

Thanks @wmayer.

Suppose that there are a list of edges, and the edges could form several independent connected edges, but we do not know which edges form which connected edges. In this case, how do we get a group of wires?

In a simple way, how do we determine that which edges could form a closed wires?

wandererfan

2016-11-19 15:44

manager   ~0007471

<<In a simple way, how do we determine that which edges could form a closed wires?>>
This is a hard problem. In version 0.15, there is no easy solution. TopoShapeCompound has a connectEdgesToWires() method that tries to connect edges into the longest possible wires, but if you are looking for closed regions, you may not be happy with the results.

In v0.17 there is TechDraw.edgeWalker which looks for closed wires in a pile of edges which may be closer to what you are looking for.

wmayer

2016-11-19 15:45

administrator   ~0007472

ws = ... # is a compound of a list of edges
comp_wires = ws.connectEdgesToWires() # returns a new compound with a list of wires
comp_wires.Wires # check each wire in this list if it's closed

huskier

2016-11-19 15:57

reporter   ~0007473

Thanks, @wandererfan.

Both connectEdgesToWires() and TechDraw.edgeWalker are useful for me, and I would try them first.

huskier

2016-11-19 16:47

reporter   ~0007474

Last edited: 2016-11-19 16:51

@wmayer

For the following code, three independent wires are expected after "connectEdgesToWires operation". However, comp_wires.Wires command returns ten wires.
[<Wire object at 0ED1DE98>, <Wire object at 0ED1E0B8>, <Wire object at 0ED1DF78>, <Wire object at 0ED1DEF8>, <Wire object at 0ED1DF18>, <Wire object at 0ED1DE78>, <Wire object at 0ED1DDB8>, <Wire object at 0ED1E0D8>, <Wire object at 0ED1DF38>, <Wire object at 0ED1E0F8>]

Is this OK with the "connectEdgesToWires" function?
"connectEdgesToWires() method that tries to connect edges into the longest possible wires"

****************************The Code***************************************

from FreeCAD import Base
e1 = Part.makeCircle(1.6, Base.Vector(-23.5,0,0), Base.Vector(0,0,1))
e2 = Part.makeCircle(1.6, Base.Vector(23.5,0,0), Base.Vector(0,0,1))
e3 = Part.Arc(Base.Vector(-17.038896,-5.7,0),Base.Vector(-19.44306,-4.70416,0),Base.Vector(-20.438896,-2.3,0))
e3 = e3.toShape()
e4 = Part.makeLine(Base.Vector(-20.438896,-2.3,0),Base.Vector(-21.25,2.3,0))
e5 = Part.Arc(Base.Vector(-21.25,2.3,0),Base.Vector(-20.25416,4.70416,0),Base.Vector(-17.85,5.7,0))
e5 = e5.toShape()
e6 = Part.makeLine(Base.Vector(-17.85,5.7,0),Base.Vector(17.85,5.7,0))
e7 = Part.Arc(Base.Vector(17.85,5.7,0),Base.Vector(20.25416,4.70416,0),Base.Vector(21.25,2.3,0))
e7 = e7.toShape()
e8 = Part.makeLine(Base.Vector(21.25,2.3,0),Base.Vector(20.438896,-2.3,0))
e9 = Part.Arc(Base.Vector(20.438896,-2.3,0),Base.Vector(19.44306,-4.70416,0),Base.Vector(17.038896,-5.7,0))
e9 = e9.toShape()
e10 = Part.makeLine(Base.Vector(17.038896,-5.7,0),Base.Vector(-17.038896,-5.7,0))

ws = Part.Compound([e1, e2, e3, e4, e5, e6, e7, e8, e9, e10])
comp_wires = ws.connectEdgesToWires()

*********************************The Code********************************

wmayer

2016-11-19 16:59

administrator   ~0007475

Here is the documentation of the corresponding OCC function:

ShapeAnalysis_FreeBounds
  //! Builds sequnce of <wires> out of sequence of not sorted
  //! <edges>.
  //! Tries to build wires of maximum length. Building a wire is
  //! stopped when no edges can be connected to it at its head or
  //! at its tail.
  //!
  //! Orientation of the edge can change when connecting.
  //! If <shared> is True connection is performed only when
  //! adjacent edges share the same vertex.
  //! If <shared> is False connection is performed only when
  //! ends of adjacent edges are at distance less than <toler>.
  Standard_EXPORT static void ConnectEdgesToWires (Handle(TopTools_HSequenceOfShape)& edges, const Standard_Real toler, const Standard_Boolean shared, Handle(TopTools_HSequenceOfShape)& wires);

So, since the shapes are created separately they don't share any vertexes and thus this function won't connect them. So, you have to use the function as:

comp_wires = ws.connectEdgesToWires(False,0.005)
comp_wires.Wires # three wires now

huskier

2016-11-19 17:10

reporter   ~0007476

Thank you very much,@wmayer and @wandererfan.You are the best!

My problem solved!

Issue History

Date Modified Username Field Change
2016-11-18 14:24 huskier New Issue
2016-11-19 13:07 wandererfan Note Added: 0007466
2016-11-19 13:08 wandererfan Status new => feedback
2016-11-19 14:28 huskier Note Added: 0007467
2016-11-19 14:28 huskier Status feedback => new
2016-11-19 14:54 wmayer Note Added: 0007469
2016-11-19 14:54 wmayer Status new => feedback
2016-11-19 15:17 huskier Note Added: 0007470
2016-11-19 15:17 huskier Status feedback => new
2016-11-19 15:18 huskier Note Edited: 0007467
2016-11-19 15:21 huskier Note Edited: 0007470
2016-11-19 15:22 huskier Note Edited: 0007470
2016-11-19 15:44 wandererfan Note Added: 0007471
2016-11-19 15:45 wmayer Note Added: 0007472
2016-11-19 15:57 huskier Note Added: 0007473
2016-11-19 16:47 huskier Note Added: 0007474
2016-11-19 16:49 huskier Note Edited: 0007474
2016-11-19 16:49 huskier Note Edited: 0007474
2016-11-19 16:51 huskier Note Edited: 0007474
2016-11-19 16:59 wmayer Note Added: 0007475
2016-11-19 17:10 huskier Note Added: 0007476
2016-11-19 17:29 wmayer Status new => closed
2016-11-19 17:29 wmayer Resolution open => no change required