Ezz Posted July 1, 2013 Share Posted July 1, 2013 Hi good folks!! I am playing with Python(expression) i Houdini and I am allready stuck with some syntax-problems. What I want is to assign a primitiveattribute(string) called "map" with this Hscript-expression like this: $HIP\pic\butterfly`$PR % 7+1`.pic but i Python. My goal is to point at a folder, on my harddrive, with random jpg`s(or like) and let the expression figure the rest out. What I have so fare is: import os file = os.filepath("U:erik/pictures") texturepath = file[primitivenumber] - Here I am stucked!! return texturepath Is there a method to this like the above descriped Hscript?? Thank you very much!! Erik Quote Link to comment Share on other sites More sharing options...
anim Posted July 1, 2013 Share Posted July 1, 2013 to get equivalent to $PR in Python (on nodes that evaluate per primitive) you can use lvar('PR')[/CODE]or[CODE]pwd().curPrim().number()[/CODE] Quote Link to comment Share on other sites More sharing options...
Ezz Posted July 5, 2013 Author Share Posted July 5, 2013 Hi Thomas Thank you for guiding me in the right direction. Here is the expression so far: import os thepath = os.listdir("U:/martin/awesome 3d stuff/") mod = len(thepath) primnum = int(lvar("PR")) myimagenumber = primnum % mod tex = ("U:/martin/awesome 3d stuff/" + thepath[myimagenumber]) return tex Next step is to make a variable from a nulls file-parameter, so that I dont have to write the images path in the expression. Just to make it easier to point at the files. Thanks again :-) Erik Quote Link to comment Share on other sites More sharing options...
Ezz Posted July 10, 2013 Author Share Posted July 10, 2013 Hi. Here is a file with two ways of fetching files via Python. My next goal is to put several imagesequences in the same folder and have different sequences pr primitive. I miss a smart Python-trick to isolate the different filenames in a list. Let say I have 300 frames in one list called [ fileA.0000.jpg -> fileA.0099.jpg, fileB.0000.jpg -> fileB.0099.jpg, fileC.0000.jpg -> fileC.0099.jpg ] How can I make a new list containing only containing [ fileA, fileB, fileC ] ?? Cheers Erik fileOnPrim_v002.hipnc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.