some problems left:
- how to get rid of the textures without closing the file
- scale of the textures (roof and bricks)
- orientation (bricks sometimes going upwards)
Code: Select all
def textureMaterial():
""" Texturen nach Material setzen
"""
import FreeCADGui
from PyQt4 import QtGui
from pivy import coin
print "Texturen"
texturefilepath = '/home/hugo/Documents/projekte--ifc/freecad/BIM--IFC/Texturen--Vorlageproj/'
material2texture = { 'noMaterial' : texturefilepath+'noMaterial.jpg',
'Beton' : texturefilepath+'beton_bewehrt.jpg',
'Backstein' : texturefilepath+'backstein.jpg',
'Kalksandstein' : texturefilepath+'kalksandstein.jpg',
'Baustahl' : texturefilepath+'stahl.jpg',
'Eindeckung' : texturefilepath+'dachziegel.jpg'
}
for o in FreeCAD.ActiveDocument.Objects:
if '_FreeCAD_shape_body' not in o.Name: # es waere cooler ein eigenes PythonFeature
if hasattr(o,'Shape'):
o.ViewObject.Visibility = True
if hasattr(o,'IfcObjectType') and hasattr(o,'IfcMaterial'):
o.ViewObject.Transparency = 0
o.ViewObject.ShapeColor = (1.0,1.0,1.0)
rootnode = o.ViewObject.RootNode
tex = coin.SoTexture2()
tex.filename = material2texture['noMaterial'] # weisse textur
if o.IfcMaterial in material2texture:
#print material2texture[o.IfcMaterial]
tex.filename = material2texture[o.IfcMaterial]
else:
print (o.Name + ' --> ' + o.IfcObjectType + ' --> ' + o.IfcMaterial)
rootnode.insertChild(tex,1)
else:
o.ViewObject.Transparency = 0
o.ViewObject.ShapeColor = (0.0,0.0,0.0) # black
#print (" Object " + o.Name + " has no IfcObjectType or no IfcMaterial")