Arch: Objects with same colors are now exported to IFC with same IfcSurfaceStyle
This commit is contained in:
parent
1f47d2cac0
commit
7a096acccd
|
@ -636,14 +636,15 @@ def export(exportList,filename):
|
||||||
of = pyopen(template,"wb")
|
of = pyopen(template,"wb")
|
||||||
of.write(ifctemplate)
|
of.write(ifctemplate)
|
||||||
of.close()
|
of.close()
|
||||||
global ifcfile
|
global ifcfile, surfstyles
|
||||||
ifcfile = ifcopenshell.open(template)
|
ifcfile = ifcopenshell.open(template)
|
||||||
history = ifcfile.by_type("IfcOwnerHistory")[0]
|
history = ifcfile.by_type("IfcOwnerHistory")[0]
|
||||||
context = ifcfile.by_type("IfcGeometricRepresentationContext")[0]
|
context = ifcfile.by_type("IfcGeometricRepresentationContext")[0]
|
||||||
project = ifcfile.by_type("IfcProject")[0]
|
project = ifcfile.by_type("IfcProject")[0]
|
||||||
objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True)
|
objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True)
|
||||||
objectslist = Arch.pruneIncluded(objectslist)
|
objectslist = Arch.pruneIncluded(objectslist)
|
||||||
products = {}
|
products = {} # { Name: IfcEntity, ... }
|
||||||
|
surfstyles = {} # { (r,g,b): IfcEntity, ... }
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
# products
|
# products
|
||||||
|
@ -988,12 +989,17 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess
|
||||||
|
|
||||||
if shapes:
|
if shapes:
|
||||||
|
|
||||||
|
# set surface style
|
||||||
if FreeCAD.GuiUp and (not subtraction) and hasattr(obj.ViewObject,"ShapeColor"):
|
if FreeCAD.GuiUp and (not subtraction) and hasattr(obj.ViewObject,"ShapeColor"):
|
||||||
rgb = obj.ViewObject.ShapeColor
|
rgb = obj.ViewObject.ShapeColor[:3]
|
||||||
|
if rgb in surfstyles:
|
||||||
|
psa = surfstyles[rgb]
|
||||||
|
else:
|
||||||
col = ifcfile.createIfcColourRgb(None,rgb[0],rgb[1],rgb[2])
|
col = ifcfile.createIfcColourRgb(None,rgb[0],rgb[1],rgb[2])
|
||||||
ssr = ifcfile.createIfcSurfaceStyleRendering(col,None,None,None,None,None,None,None,"FLAT")
|
ssr = ifcfile.createIfcSurfaceStyleRendering(col,None,None,None,None,None,None,None,"FLAT")
|
||||||
iss = ifcfile.createIfcSurfaceStyle(None,"BOTH",[ssr])
|
iss = ifcfile.createIfcSurfaceStyle(None,"BOTH",[ssr])
|
||||||
psa = ifcfile.createIfcPresentationStyleAssignment([iss])
|
psa = ifcfile.createIfcPresentationStyleAssignment([iss])
|
||||||
|
surfstyles[rgb] = psa
|
||||||
for shape in shapes:
|
for shape in shapes:
|
||||||
isi = ifcfile.createIfcStyledItem(shape,[psa],None)
|
isi = ifcfile.createIfcStyledItem(shape,[psa],None)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user