Build directory path from DynamoPlayer input

Hi all,

Below is part of a bigger workflow that copies a number of families to a project folder.
I would like to run this script by the DynamoPlayer.

I found the Python code in this thread by @Mostafa_El_Ayoubi.
It’s a simple but effective code that adds (new) subdirectory’s to a existing path.

I would like to get some help to adjust the code.

  • If the input string starts with “15” it should build a path like “H:\2015\input string”.
  • If the input string starts with “16” it should build a path like “H:\2016\input string”.
  • If the input string starts with “17” it should build a path like “H:\2017\input string”.

The above directory’s allready exist, so its just about creating a Dynamo path.

  • The part of the code that is adding the new subdirectory’s to the end of the above path is just fine.
  • Last wish would be that the “output” of the Python script would be the complete path.
    So in this case “H:\2017\170017\test\test2”.

I hope it makes sense, any help is much appreciated.
build directory path.dyn (2.9 KB)

Kind regards,

Can’t do it with Python, but I can with design script.

Define all paths first with dynamo, then use a nested if statement similar to the thread below to pull correct directory based on the substring value for the first two characters.

Hi @jacob.small and @4bimfercesp,

Thank you very much for your responses :grinning: :+1:
@jacob.small i have no experience with designscript, but i am very curious if i can figure out what you mean.
@4bimfercesp Your second solution looks very promising.
I don’t have computer with Dynamo here so i will have to wait till monday before i can try your solutions.
Thanks again, and have a nice weekend.

Kind regards,

Hi Mark,

Dynamo/Python version of make directory.

build directory path_new_ver2.dyn (4.4 KB)

you can add IN[1] if you wish so it will be same as you have on your screen shot above. I thought it is not needed if you already decided on what the main folders will be and only getting you sub-folders from the string input.

let me know how you get on.

Hi @4bimfercesp,

Thank you very much for your solution.
It is exactly what i was after (i only changed the order of the folders a little to my needs).

@jacob.small and @erfajo thanks for your input as well. I will dive into it, as i am very keen on learning everything that has to do with Dynamo :grinning:
build directory path_v02.dyn (2.8 KB)

Kind regards,

1 Like

is possible to do it with designscript with codeblock?

I am trying to write that OOTB node in designscript basically