[ Fixed ] Draft.make_wire from Part.Wire: unexpected result

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

[ Fixed ] Draft.make_wire from Part.Wire: unexpected result

Post by Roy_043 »

The make_wire method accepts a Draft.Wire instead of a list of points. But the result is a bit unexpected. From the wire of a rectangular face an N-shape Draft_Wire is created.

Code: Select all

import FreeCAD as App
import Draft

doc = App.newDocument()

box = doc.addObject("Part::Box", "Box")
box.Length = 2300
box.Width = 800
box.Height = 1000

face_list = Draft.downgrade(box, delete=True)[0]

for face in face_list:
    Draft.make_wire(face.Shape.OuterWire)
    face.Visibility = False

doc.recompute()

Code: Select all

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.20.24893 (Git)
Build type: Release
Branch: master
Hash: 03855f793feaceeb4385c02f6520f3e1b6429c93
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Dutch/Netherlands (nl_NL)
Last edited by Roy_043 on Sun Jun 27, 2021 1:27 pm, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6094
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [ Bug? ] Draft.make_wire from Part.Wire: unexpected result

Post by onekk »

This code seems to work

Code: Select all

face_list = box.Shape.Faces

idx = 0
for face in face_list:
    wire = face.Wires[0]
    Part.show(wire, "wire_" + str(idx))
    idx += 1
    #face.Visibility = False

Hope it helps

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug? ] Draft.make_wire from Part.Wire: unexpected result

Post by Roy_043 »

onekk wrote: Tue May 25, 2021 5:49 pmHope it helps
Thanks but this is more about fixing the Draft.make_wire method.

Code: Select all

    if not isinstance(pointslist, list):
        e = pointslist.Wires[0].Edges
        pointslist = Part.Wire(Part.__sortEdges__(e))
        nlist = []
        for v in pointslist.Vertexes:
            nlist.append(v.Point)
        if DraftGeomUtils.isReallyClosed(pointslist):
            closed = True
        pointslist = nlist
User avatar
onekk
Veteran
Posts: 6094
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [ Bug? ] Draft.make_wire from Part.Wire: unexpected result

Post by onekk »

Sorry, I've misunderstood the topic.

But maybe simply Draft.downgrade or OuterWire results are not correctly ordered or returned?

Now I catch the N-shape thing.

Sorry for bothering.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug? ] Draft.make_wire from Part.Wire: unexpected result

Post by Roy_043 »

Thank you.
Post Reply