Jump to content
Sign in to follow this  
sant0s81

[Solved] Create folder structure on harddrive with callback script

Recommended Posts

Posted (edited)

Hi,

for learning purpose I would like to create a folder structure on my harddrive by clicking a button parameter.

I found examples on how to create new folders in the parameter interface - but not how to do that on the HDD.

Actually I was thinking about adding a "string parameter" (or using "multiparm block list")  to write a name and than use that parameter, to create a folder with that name after clicking on the "button parameter".

Is that possible with the callback script or does that make absolutly no sense? :D

Thx! :)

 

Edit: I also just found examples with a TOP network.
Does a great job. Wonder, if I can start the "cooking" process with a Button Parameter.

 

 

Edited by sant0s81

Share this post


Link to post
Share on other sites

Hi, 

Try something similar:

 

import os
f_num = hou.evalParm('/obj/geo1/null/folder_parm')
for idx in range( 1,f_num+1):
    os.makedirs( os.path.join( 'a:', os.sep, 'temp', hou.evalParm('/obj/geo1/null/folder'+str(idx))))
    

image.thumb.png.d869b3712e9aa357c4bd027bfb7f1175.png

 

  • Like 1

Share this post


Link to post
Share on other sites

@gemini,

thx alot, works almost perfect for me :D


When I create the NULL and add a string parameter (Language set to Python) to get the script window, I dont get the "Run" parameter you have and its not executing.
When I use a Python Sop, your code example works and creates the folders - but its looping all the time and gives me an error, that the folder alreay exists.

Is there something in the Parameter Settings, that I have to add to get the "Run" parm?

Anyway, thx again for the example, helps alot! :)

 

Share this post


Link to post
Share on other sites

Use this as a callback:  image.thumb.png.8c47f4787c140168bdb55d98e00db197.png

 

image.png

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

Thank you very much again @gemini

Just to finish the topic:

I modified the code a bit to add a path an project name.

I dont know if that is the best way.
If I can optimize the code, would like to know how :)

Thx alot,

sant0s

create_folders.thumb.jpg.c7ecc93f7a931ed37d9e1dda59a17297.jpg

Edited by sant0s81

Share this post


Link to post
Share on other sites
Posted (edited)

Morning :)

have one more question:

I would like to use toggles to pass over the names to os.makedirs .

But whatever I do, I never get the marked toggles and always only the first.

I understand, that the "Multiparm Blocklist" has an ID - but when I change the Folder Type to simple, I have no idea how to pass over the toggles since there is no more ID.

And something else I wonder how to do that: how could I create a list of folder presets and pass them over?

Thanks alot! :)

edit: In this line here I dont know, how to choose all parameters instead of "folder"

hou.evalParm('../null/folder'+str(idx))))

Of course "folder" is wrong - but I tried stuff like "*" to choose all. But of course, not working :D

create_project.thumb.jpg.2c5ce25258dd16219808b3861c98e3d2.jpg

Edited by sant0s81

Share this post


Link to post
Share on other sites

I did some research and I think I have to give a callback script to each toggle parameter, to send the parameters name.
Is that the right direction?

Something like transfering each toggle parameter into a function that reacts on the callback script.

Dont even find words what I wanna do, sry :D

 

Share this post


Link to post
Share on other sites
Posted (edited)

I am just trying parameters from the Redshift_ROP.

They also use the Multiparm Block (list) to choose the different AOVs.

In the Redshift_ROP, as soon as I choose an AOV like Diffuse, the string textblock changes the name to Diffuse, too.

I copied these parameters to see what they did.
But as soon as I copy the parameters to my new geometry, the text stays on the default value and is not changing automaticly.

Is there something missing?

I add the hip below.

parameters.thumb.jpg.adbc1413dd6c9a76c947d6e0a6c6d2a4.jpg

 

create_folders_v001c.hiplc

Edited by sant0s81

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×