Automatic Suffix based on input file name and directory

   2727   2   2
User Avatar
Member
21 posts
Joined: April 2019
Offline
Hello Everyone. I've got an automation question for ya.

I'm working on a LOD system to generate LODs from an imported RAW 3D scan (model, not point cloud)

What I want to achieve is an automatic exporting system for the final LODs.

Here is and Example:

I have a file structure where I have my main asset Folder. Within my asset folder, I have a sub Folder called “AGIsoft” and another sub folder called “Houdini”

Within my HIP file, I import my scanned mesh, from the “AGIsoft” folder
Then I create all my LODs within the hip file, in a single geometry node.

at the end, I have 6 files to export.

LOD0, LOD1, LOD2, LOD3, LOD4 and a “RAW” file.

My important scan mesh, is called “RockBoulderLarge001_DEC”

I want my exported meshes to be named “RockBoulderLarge001_LOD1” etc for each of the LODs and RAW file.

So, it will have the same Prefix as the imported mesh, but have a different Suffix.
And I do not want it to export into the folder that my imported mesh came from. I want it to export into a different child folder of the parent.

Here is a screenshot of my file structure, where I import from, and where I want to export too:


To Recap:

My imported mesh from “Agisoft” folder is called “RockBoulderLarge001_DEC”
I want my LODs to be exported to the “Houdini” Folder as “RockBoulderLarge001_LOD0” etc.

The only change in the name is the suffix. But I want to export it into a different folder.

Is there a way to do this automatically? i.e call to the prefix of the imported mesh in the file node, use the prefix, but change the suffix and the folder to export too?

NOTE: my Hip file is not located within the asset folder. it is completely separate in a tools folder I have. so referencing the HIP directory doesn't work.

Please let me know what you think, and if it can be done. the goal is to not have to type in the names manually for every asset I run through the tool.

New to Houdini, my apologies if this is a very simple question. I don't have any experience with coding and scripting before Houdini and Vex.
Edited by Poliigon - March 6, 2020 18:30:41

Attachments:
FileStructure.JPG (62.8 KB)

User Avatar
Member
192 posts
Joined: Oct. 2018
Offline
You can use expressions to replace parts of strings which you would do once for the folder and again for the suffix. You can also utilize opdigits to get the number on the end of your sop if you want.

chs(“file”) is the parameter you would change to reference the input file.

`strreplace( strreplace(chs("file"), "Agisoft", "Houdini"), "DEC", "LOD") + opdigits(".")`
User Avatar
Member
21 posts
Joined: April 2019
Offline
mkps
You can use expressions to replace parts of strings which you would do once for the folder and again for the suffix. You can also utilize opdigits to get the number on the end of your sop if you want.

chs(“file”) is the parameter you would change to reference the input file.

`strreplace( strreplace(chs("file"), "Agisoft", "Houdini"), "DEC", "LOD") + opdigits(".")`

That did the trick! Thank you so much.
  • Quick Links