[FIXED] Ticket #4301 - Draft Pattern problem (upstream coin3d API change)

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
clifcox
Posts: 8
Joined: Sun Mar 22, 2020 3:49 pm

[FIXED] Ticket #4301 - Draft Pattern problem (upstream coin3d API change)

Post by clifcox »

Hi Folks,

sorry for reopening this old thread, but I think there might be a regression here between 0.18 (where it works) and 0.19 (where it doesn't). I was following the the draft WB tutorial in the manual when I noticed the problem. Here are the two systems info:

OS: Debian GNU/Linux 10 (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.
Build type: Release
Python version: 2.7.16rc1
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: C/Default (C)

AND:

OS: Debian GNU/Linux 10 (buster) (MATE/lightdm-xsession)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20325 (Git)
Build type: Release
Branch: master
Hash: 7c9d5fe57c94eeec0289317e6be8a99bdceea11f
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: C/Default (C)

When I run the example code:

Code: Select all

import Draft
pl = FreeCAD.Placement()
pl.Rotation.Q = (0.0,0.0,0.0,1.0)
pl.Base = FreeCAD.Vector(-3.46933150291,0.713757812977,0.0)
rect = Draft.makeRectangle(length=4.00172472,height=-1.73174029589,placement=pl,face=True,support=None)
rect.MakeFace = True
App.ActiveDocument.recompute()
rect.ViewObject.Pattern = "simple"
I do get the rectangle filled with the simple pattern in 0.18. If I save that file and try to view it in 0.19 I only get a solid grey filled one, no matter what pattern I try. If I then delete that one and run the python script again, I just get a plain empty rectangle, though the relevant properties are set correctly.

I only tried this on one computer, and I thought someone else might like to verify.

Thanks for a great project,
Clif
Last edited by Kunda1 on Thu Nov 05, 2020 12:34 pm, edited 1 time in total.
Reason: [FIXED]
chrisb
Veteran
Posts: 54168
Joined: Tue Mar 17, 2015 9:14 am

Re: Draft Pattern problem

Post by chrisb »

Moved to Python forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Draft Pattern problem

Post by vocx »

clifcox wrote: Tue Mar 31, 2020 5:24 am sorry for reopening this old thread,
You can open your own thread. You don't have to open a several years old thread.
I do get the rectangle filled with the simple pattern in 0.18. If I save that file and try to view it in 0.19 I only get a solid grey filled one, no matter what pattern I try...
Yes, patterns broke at some point, and nobody knows why. I don't know if it was during the LinkMerge or what but it happened.

The error message seems to come from Coin (pivy), as if the necessary method "removeChild" was removed in a new version of Coin. Or maybe Draft's code was changed.

Code: Select all

Traceback (most recent call last):
  File "/opt/freecad-build-debug-vocx/Mod/Draft/Draft.py", line 3240, in onChanged
    r.removeChild(self.texture)
  File "/usr/lib/python3/dist-packages/pivy/coin.py", line 4746, in __getattr__
    raise e
  File "/usr/lib/python3/dist-packages/pivy/coin.py", line 4738, in __getattr__
    return SoBase.__getattribute__(self, name)
<class 'AttributeError'>: 'SoPolygonOffset' object has no attribute 'removeChild'
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
clifcox
Posts: 8
Joined: Sun Mar 22, 2020 3:49 pm

Re: Draft Pattern problem

Post by clifcox »

Ok cool,

I'm trying to follow the recommended bug tracker workflow. Has this bug been submitted yet, or would you like me to do that?

Best,
Clif
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Draft Pattern problem

Post by Kunda1 »

issue #4301: Draft Pattern problem ticket was opened and associated with this thread
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4301 - Draft Pattern problem (upstream coin3d API change)

Post by Kunda1 »

Note: Thread was split off older thread https://forum.freecadweb.org/viewtopic.php?f=22&t=17628
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Roy_043
Veteran
Posts: 8541
Joined: Thu Dec 27, 2018 12:28 pm

Re: Ticket #4301 - Draft Pattern problem (upstream coin3d API change)

Post by Roy_043 »

A bit of investigating:
  1. Open a new document
  2. Draw a rectangle
  3. Run test code below
  4. Compare V0.18 and V0.19 results
Conclusion:
In V0.18 vobj.RootNode.getChild(2).getChild(0).getChild(2) is a SoSeparator.
In V0.19 it is a SoPolygonOffset.

Creating a work-around is relatively easy.
view_base.py:

Code: Select all

                                    r = vobj.RootNode.getChild(2).getChild(0).getChild(2)     # line 290
                                    if type(r) == coin.SoPolygonOffset:                       # workaround
                                        r = vobj.RootNode.getChild(2).getChild(0).getChild(3) # workaround
Test code:

Code: Select all

vobj = Gui.ActiveDocument.Rectangle
print(vobj.RootNode.getChild(2).getChild(0).getChild(0))
print(vobj.RootNode.getChild(2).getChild(0).getChild(1))
print(vobj.RootNode.getChild(2).getChild(0).getChild(2))
print(vobj.RootNode.getChild(2).getChild(0).getChild(3))
Result V0.18:

Code: Select all

>>> vobj = Gui.ActiveDocument.Rectangle
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(0))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x062EEC08> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(1))
<pivy.coin.SoPolygonOffset; proxy of <Swig Object of type 'SoPolygonOffset *' at 0x062EECC8> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(2))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x062EECC8> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(3))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x062EEA58> >
Result V0.19:

Code: Select all

>>> vobj = Gui.ActiveDocument.Rectangle
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(0))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x000000B12D50F480> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(1))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x000000B12D50F480> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(2))
<pivy.coin.SoPolygonOffset; proxy of <Swig Object of type 'SoPolygonOffset *' at 0x000000B12D50F480> >
>>> print(vobj.RootNode.getChild(2).getChild(0).getChild(3))
<pivy.coin.SoSeparator; proxy of <Swig Object of type 'SoSeparator *' at 0x000000B12D50F480> >
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [FIXED] Ticket #4301 - Draft Pattern problem (upstream coin3d API change)

Post by Kunda1 »

Associated the commit to the ticket on Mantis. Change this thread to [fixed]
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply