Macro Texture Objects: Difference between revisions

From FreeCAD Documentation
(replace "qApp" by "QApplication")
(Date=2023-12-08)
Line 8: Line 8:
|Description=This macro allows you to temporarily put a texture image on selected objects. To remove the textures, simply close and reopen the document.
|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
|Author=yorik
|Version=1.0
|Version=1.1
|Date=2011-10-13
|Date=2023-12-08
|Download=[https://www.freecadweb.org/wiki/images/d/da/Macro_Texture_Objects.png Icon Toolbar]
|Download=[https://www.freecadweb.org/wiki/images/d/da/Macro_Texture_Objects.png Icon Toolbar]
|FCVersion= 0.18 and below
|FCVersion= 0.18 and below

Revision as of 21:02, 8 December 2023

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.1
Last modified: 2023-12-08
FreeCAD version: 0.18 and below
Download: Icon Toolbar
Author: yorik
Author
yorik
Download
Icon Toolbar
Links
Macro Version
1.1
Date last modified
2023-12-08
FreeCAD Version(s)
0.18 and below
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.QApplication.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)

Links