Macro Texture Objects: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
m (minor)
Line 9: Line 9:
<!--T:3-->
<!--T:3-->
[[Image:Textured_objects.jpg|680px]]
[[Image:Textured_objects.jpg|680px]]
{{clear}}
</translate>
</translate>
{{clear}}



<translate>
<translate>

Revision as of 18:36, 7 August 2018

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: 2011-10-13
Author: yorik
Author
yorik
Download
None
Links
Macro Version
1.0
Date last modified
2011-10-13
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

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


Script

Macro_Texture_Objects.FCMacro

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)