Jump to content

Image per primitive


Ezz

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...