Arch: Fixed bug with arch objects that are a clone and have a material

This commit is contained in:
Yorik van Havre 2016-12-30 19:25:42 -02:00
parent 6aedc47a2c
commit 0993a525b1
4 changed files with 18 additions and 8 deletions

View File

@ -219,6 +219,12 @@ def cloneComponent(obj):
c.CloneOf = obj
c.Placement = obj.Placement
c.Label = obj.Label
if hasattr(obj,"BaseMaterial"):
if obj.BaseMaterial:
c.BaseMaterial = obj.BaseMaterial
if hasattr(obj,"IfcAttributes"):
if obj.IfcAttributes:
c.IfcAttributes = obj.IfcAttributes
def setAsSubcomponent(obj):
'''Sets the given object properly to become a subcomponent (addition, subtraction)

View File

@ -361,7 +361,7 @@ class Component:
pl = obj.Placement
obj.Shape = obj.CloneOf.Shape.copy()
obj.Placement = pl
for prop in ["Length","Width","Height","Thickness","Area","PerimeterLength","HorizontalArea","VerticalArea","BaseMaterial","IfcAttributes"]:
for prop in ["Length","Width","Height","Thickness","Area","PerimeterLength","HorizontalArea","VerticalArea"]:
if hasattr(obj,prop) and hasattr(obj.CloneOf,prop):
setattr(obj,prop,getattr(obj.CloneOf,prop))
return True
@ -633,20 +633,21 @@ class ViewProviderComponent:
if "(" in obj.BaseMaterial.Material['DiffuseColor']:
c = tuple([float(f) for f in obj.BaseMaterial.Material['DiffuseColor'].strip("()").split(",")])
if obj.ViewObject:
obj.ViewObject.ShapeColor = c
if obj.ViewObject.ShapeColor != c:
obj.ViewObject.ShapeColor = c
elif prop == "Shape":
if obj.Base:
if obj.Base.isDerivedFrom("Part::Compound"):
if obj.ViewObject.DiffuseColor != obj.Base.ViewObject.DiffuseColor:
obj.ViewObject.DiffuseColor = obj.Base.ViewObject.DiffuseColor
obj.ViewObject.update()
self.onChanged(obj.ViewObject,"ShapeColor")
self.onChanged(obj.ViewObject,"ShapeColor")
elif prop == "CloneOf":
if obj.CloneOf:
if obj.CloneOf and not(obj.BaseMaterial):
if obj.ViewObject.DiffuseColor != obj.CloneOf.ViewObject.DiffuseColor:
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
obj.ViewObject.update()
self.onChanged(obj.ViewObject,"ShapeColor")
self.onChanged(obj.ViewObject,"ShapeColor")
return
def getIcon(self):

View File

@ -639,7 +639,8 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
obj.ViewObject.NodeType = "Area"
else:
obj.ViewObject.NodeType = "Linear"
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
else:
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
def onChanged(self,vobj,prop):
if prop == "ShowNodes":
@ -692,7 +693,8 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
self.pointstyle.pointSize = vobj.NodeSize
elif prop == "NodeType":
self.updateData(vobj.Object,"Nodes")
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
else:
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
def setEdit(self,vobj,mode):
if mode == 0:

View File

@ -688,7 +688,8 @@ class _Window(ArchComponent.Component):
# because of load order, but it doesn't harm...
pass
FreeCAD.ActiveDocument.recompute()
ArchComponent.Component.onChanged(self,obj,prop)
else:
ArchComponent.Component.onChanged(self,obj,prop)
def execute(self,obj):