[BUG] Part::FeaturePython with App::GroupExtensionPython

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

[BUG] Part::FeaturePython with App::GroupExtensionPython

Post by carlopav »

When adding an "App::GroupExtensionPython" to a "Part::FeaturePython" object, the result is an object that gets it's representation from its children. This seems weird, is it the default behavior?

Code: Select all

class py_object:
    
    """Base class for all blenderbim objects"""
    
    def onChanged(self, obj, prop):
        return

    def attach(self, obj):
        obj.addExtension("App::GroupExtensionPython")

    def __getstate__(self):
        return None

    def __setstate__(self, state):
        return None
    
    def execute (self, obj):
        pass

class py_vp_object:

    """Base class for all blenderbim view providers"""

    def attach(self, vobj):
        self.Object = vobj.Object
        vobj.addExtension("Gui::ViewProviderGroupExtensionPython")

    def getDisplayModes(self, obj):
        return []

    def getDefaultDisplayMode(self):
        return "FlatLines"

    def setDisplayMode(self,mode):
        return mode

    def onChanged(self, vobj, prop):
        return

    def updateData(self, obj, prop):
        return

    def __getstate__(self):
        return None

    def __setstate__(self, state):
        return None


obj0 = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'IfcObject', py_object(), py_vp_object(), True)
obj0.Shape = Part.Shape(Part.makeBox(1,1,1))
obj1 = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'IfcObject', py_object(), py_vp_object(), True)
obj1.Shape = Part.Shape(Part.makeCylinder(0.5,3))
obj2 = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'IfcObject', py_object(), py_vp_object(), True)
obj2.addObject(obj1)
obj1.addObject(obj0)
If you execute this code this structure is created:
catt.png
catt.png (16 KiB) Viewed 1420 times
The top level group, IfcObject002, does not have a shape, in fact:
App.ActiveDocument.IfcObject002.Shape.isNull() returns True

But it is represented on the scene and is selectable! :cry:
Last edited by carlopav on Sun Nov 06, 2022 4:28 pm, edited 2 times in total.
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: App::GroupExtensionPython on Part::FeaturePython

Post by carlopav »

If then for example you want to move one object, the one whose Shape isNull, you obtain this strange effect:

catt.png
catt.png (42.35 KiB) Viewed 1361 times
And you can select the object by clicking on its coin representation...
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: App::GroupExtensionPython on Part::FeaturePython

Post by carlopav »

I feel this is a bug... I'm changing topic title.

The bug is present in 0.20 and also in last daily:

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.30858 (Git)
Build type: Release
Branch: master
Hash: 7a5019b2625a148acb23fb915df48ffa69636fe9
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: Italian/Italy (it_IT)
Installed mods: 
  * 3D_Printing_Tools
  * A2plus 0.4.59e
  * ArchDesign
  * bimtester
  * BIM_Workbench 2021.12.0
  * BOLTSFC
  * Curves 0.5.11
  * Defeaturing 1.2.0
  * Design456
  * DynamicData 2.46.0
  * fasteners 0.4.16
  * FreeCAD-BlenderBIM 2022.10.20
  * freecad.archdesign
  * FreeCAD_Assembly4
  * FreeCAD_SketchArch-master
  * IconThemes
  * Manipulator 1.4.9
  * parts_library
  * sheetmetal 0.2.58
  * TabBar
  * trails

The bug is not present in LinkBranch, the current version behaves correctly as expected, without duplicating the children representation:

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 2022.1021.26244 +5249 (Git)
Build type: Release
Branch: LinkDaily
Hash: d307b5c936403e8dca3f24b5c1e64bd16c88b28d
Python version: 3.9.13
Qt version: 5.12.9
Coin version: 4.0.1
OCC version: 7.5.3
Locale: Italian/Italy (it_IT)

Edit: perhaps this is related to:
https://github.com/FreeCAD/FreeCAD/pull/2759
https://forum.freecadweb.org/viewtopic. ... 9&start=60
follow my experiments on BIM modelling for architecture design
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [BUG] Part::FeaturePython with App::GroupExtensionPython

Post by Kunda1 »

Can you open a ticket?
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
captain_morgan
Posts: 30
Joined: Tue Mar 12, 2019 5:42 pm

Re: [BUG] Part::FeaturePython with App::GroupExtensionPython

Post by captain_morgan »

Was a ticket ever filed for this? I cannot seem to find it if so.

I'm also encountering this issue on recent main branch and can provide a test case and open a ticket, would be great to see this resolved as I cannot see a path forward to using FeaturePython with children until it is.
Post Reply