View Full Version : maybe someone can complete this...
09-20-2012, 10:14 AM
i would like to write a script to import all textures from a folder onto card with alpha
like the imageplane coffee-script (dont know the author) which works, but only for a single image.
so i have a python-code snippet which asks for the folder and creates materials and more,
but im not a programmer and so not able to finish it and make it work.
heres what i got so far:
from c4d import gui
path=c4d.storage.LoadDialog(c4d.FILESELECTTYPE_ANYTHING, "Please choose a folder", c4d.FILESELECT_DIRECTORY)
for fname in dirList:
c4d.CallCommand(600000042) # Material
mat = doc.GetFirstMaterial()
if mat is None: return False
shd = c4d.BaseList2D(c4d.Xbitmap)
shd[c4d.BITMAPSHADER_FILENAME] = fname
myPlane = c4d.BaseObject(c4d.Oplane)
mat[c4d.MATERIAL_COLOR_SHADER] = shd
mat[c4d.MATERIAL_ALPHA_SHADER] = shd
the wish-list for this is:
choose a folder
import texture from folder into color and alphachannel
apply to standing plane with height/width same as bitmap in pixels
put pivot on lower end of plane
so please when someone has an idea how to do that would be great....
09-21-2012, 06:21 PM
I wrote this script (http://pastebin.com/WxG6YDA6) for you in a few mins. I hope it is doing what you search for. When you run it, you wil be asked to select a directory. After that, another window opens, asking you for a glob-patterns. You may know this from Unix systems. Here (http://en.wikipedia.org/wiki/Glob_%28programming%29)'s more about it. You can seperate multiple glob-patterns with a semi-colon (as well as leading and trailing spaces to make it more readable).
The default glob-pattern matches all *.tif and *.tiff files. Note that passing the same pattern two times will import the files matching the pattern two times.
09-22-2012, 09:27 AM
thanks a lot niklasR, absolutely amazing,
works like a charm
one thing would be great, to make the plane standing (-Z) and set the pivot to the lowest middle
but i´m also very happy with what i got now
09-22-2012, 08:43 PM
VERY useful, Niklas!
Had to do it manually only yesterday.
09-22-2012, 08:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.