Traceback (most recent call last):
File "/Users/***/miniconda/envs/freecad_py37/Mod/Arch/ArchBuildingPart.py", line 629, in updateData
colors = self.getColors(obj)
File "/Users/***/miniconda/envs/freecad_py37/Mod/Arch/ArchBuildingPart.py", line 649, in getColors
if len(child.ViewObject.DiffuseColor) == len(child.Shape.Faces):
<class 'AttributeError'>: 'Gui.ViewProviderDocumentObject' object has no attribute 'DiffuseColor'
This is due to WPProxy (the one automaticaly created whit the BIM porject setup tool), labels and text as can be seen from print traces I've put in the code
Code: Select all
BBL .... trace test no DiffuseColor === WPProxy
BBL .... trace test no DiffuseColor === WPProxy001
BBL .... trace test no DiffuseColor === WPProxy002
BBL .... trace test no DiffuseColor === WPProxy003
BBL .... trace test no DiffuseColor === Text
BBL .... trace test no DiffuseColor === Axis
BBL .... trace test no DiffuseColor === WPProxy004
BBL .... trace test no DiffuseColor === WPProxy
BBL .... trace test no DiffuseColor === WPProxy001
BBL .... trace test no DiffuseColor === WPProxy002
BBL .... trace test no DiffuseColor === WPProxy003
BBL .... trace test no DiffuseColor === dLabel002
BBL .... trace test no DiffuseColor === dLabel003
BBL .... trace test no DiffuseColor === dLabel
BBL .... trace test no DiffuseColor === dLabel001
BEFORE .....
Code: Select all
def getColors(self,obj):
"recursively get the colors of objects inside this BuildingPart"
colors = []
for child in Draft.getGroupContents(obj):
if hasattr(child,'Shape') :
if len(child.ViewObject.DiffuseColor) == len(child.Shape.Faces):
colors.extend(child.ViewObject.DiffuseColor)
else:
c = child.ViewObject.ShapeColor[:3]+(child.ViewObject.Transparency/100.0,)
for i in range(len(child.Shape.Faces)):
colors.append(c)
return colors
Code: Select all
def getColors(self,obj):
"recursively get the colors of objects inside this BuildingPart"
colors = []
for child in Draft.getGroupContents(obj):
if hasattr(child,'Shape') and (hasattr(child.ViewObject,"DiffuseColor") or hasattr(child.ViewObject,"DiffuseColor")):
if hasattr(child.ViewObject,"DiffuseColor") and len(child.ViewObject.DiffuseColor) == len(child.Shape.Faces):
colors.extend(child.ViewObject.DiffuseColor)
else:
c = child.ViewObject.ShapeColor[:3]+(child.ViewObject.Transparency/100.0,)
for i in range(len(child.Shape.Faces)):
colors.append(c)
return colors
OS: macOS Mojave (10.14)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19107 (Git)
Build type: Release
Branch: master
Hash: ad952191297fe53593c4d4b0ac80b43fd6664b22
Python version: 3.7.6
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)