Hi Yorik,

Hi Yorik,

Thanks for you posting on texture mapping. I am having some issues with it, could you suggest a solution please? Here is what I posted on the issue:

Texture Mapping, On Individual Objects

Postby rogerzimmerman » Wed Nov 23, 2011 1:34 am In Freecad I want to put textures (from images) onto objects. I am having some difficulty in getting this working as I require, so any solutions are appreciated.

I am using Windows 7.

I can import an .jpg or .png image into the drawing, but it just goes to the 0,0,0 location, and not sure how to manipulatite it (with python scripts) to place it in the many different locations that I need it in my drawing. And this is also not really texturing, because I would need to place it over the exact size of any objects that I move it to.

So I found the "texture mapping" feature, but it puts the texture on "all" objects, not just on the the selected objects.

So I found a python macro that asks for a .jpg image file and uses it as texture on the object(s) selected, the macro is located at:

Yorik's link here....

import FreeCADGui from PyQt4 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) rootnode.insertChild(tex,1)

I tried this out, and oddly it removes any texturing from the object, and even if I use the "texture mapping" feature again, the texture never goes back onto the object that I applied the Macro to. The Macro pops open a window and asks which jpg file to use for the texturing. I tried it as both a macro and as scripts in the Python console, and the results are the same.

As a workaround, I could apply this macro to all the objects except the one I want to apply texturing, which means I could only texture one type of object in the drawing. So it is fairly inconvenient.

I would prefer if the macro would actually apply the texture only to the objects selected, this would be ideal.

Any suggestions on this issue?

Thanks

Roger