Macro Texture Objects: Difference between revisions

From FreeCAD Documentation
m (date)
m (date)
Line 1: Line 1:
<translate>
<translate>
<!--T:1-->
<!--T:1-->
{{Macro|Icon=Text-x-python|Name=Texture Objects|Description=This macro allows you to temporarily put a texture image on selected objects. To remove the textures, simply close and reopen the document.|Author=yorik|Version=1.0|Date=00/00/0000}}
{{Macro|Icon=Text-x-python|Name=Texture Objects|Description=This macro allows you to temporarily put a texture image on selected objects. To remove the textures, simply close and reopen the document.|Author=yorik|Version=1.0|Date=13/10/2011}}


<!--T:2-->
<!--T:2-->

Revision as of 11:53, 27 September 2017

File:Text-x-python Texture Objects

Description
This macro allows you to temporarily put a texture image on selected objects. To remove the textures, simply close and reopen the document.

Macro version: 1.0
Last modified: 13/10/2011
Author: yorik
Author
yorik
Download
None
Links
Macro Version
1.0
Date last modified
13/10/2011
FreeCAD Version(s)
None
Default shortcut
None
See also
None

This macro allows you to temporarily put a texture image on selected objects. To remove the textures, simply close and reopen the document.

import FreeCADGui
from PySide import QtGui
from pivy import coin

# get a jpg filename
jpgfilename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open image file','*.jpg')

# apply textures
for obj in FreeCADGui.Selection.getSelection():
    rootnode = obj.ViewObject.RootNode
    tex =  coin.SoTexture2()
    tex.filename = str(jpgfilename[0])
    rootnode.insertChild(tex,1)