Macro Texture Objects

A forum to discuss the implementation of a good Materials system in FreeCAD
User avatar
yorik
Site Admin
Posts: 11514
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Macro Texture Objects

Postby yorik » Mon Sep 15, 2014 6:32 pm

At the moment not right out of the box, but it should become possible at some point in time. At the moment your only solution would be to program a custom python object that supports textures.
User avatar
bernd
Posts: 8330
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Macro Texture Objects

Postby bernd » Thu Sep 18, 2014 9:09 pm

yorik wrote: Since all objects are internally in millimeters, it would be quite easy to maintain an accurate scale...
Is really in FreeCAD core everything changed to mm, even if one uses unit system for meter or imperial units ?
User avatar
yorik
Site Admin
Posts: 11514
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Macro Texture Objects

Postby yorik » Thu Sep 18, 2014 9:57 pm

bernd wrote:Is really in FreeCAD core everything changed to mm, even if one uses unit system for meter or imperial units ?
Yes
User avatar
bernd
Posts: 8330
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Macro Texture Objects

Postby bernd » Sat May 19, 2018 7:39 am

paullee
Posts: 1690
Joined: Wed May 04, 2016 3:58 pm

Re: Macro Texture Objects

Postby paullee » Sun May 20, 2018 9:06 pm

bernd wrote:
Fri Aug 01, 2014 8:14 am
Found the Macro Texture Objects and tested with imported material from ifc-file. I could'nt helpt to post the screens. I still need to clean and post the code for importing materials and properties. :oops:

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")
Thanks bringing this up - never know there had been discussion and macro available!

Wonder why this had not been improved, merged in Arch Module (or other general use) and widely used since so many year?