Search - User list
Full Version: Naming objects based on their UDIM tile?
Root » Houdini Indie and Apprentice » Naming objects based on their UDIM tile?
BrandonRiza
Hello.

I'm splitting very dense meshes up with an Attribute VOP, re-UVing the resulting mesh sections, then arraying those UVs into UDIM space. I'm outputting both a re-welded single mesh in addition to all of the mesh sections themselves as a sequence of OBJ files. I need to name each OBJ file in that sequence based on what UDIM tile the mesh occupies; such as “Mesh_1001.obj”, “Mesh_2005.obj”, etc. The attached images show the meshes arrayed in UDIM space and the Subnet i'm (currently) using to both control the output amount and name the meshes. I'm not sure how to go about pulling in the UDIM tile data and assigning it to the mesh name. Is this something i'd do in my current Attribute Wrangle? Any pointers would be much appreciated.

Thanks…
tamte
1. Attribute Promote you uv attribute from Vertex (or if your uvs are Point from Point) to Primitive level as Average
- uncheck Delete Original

2. in your Prim wrangle do:
int udim = 1001 + int(v@uv.x) + int(v@uv.y)*10;
s@name = sprintf("udim_%d", udim);

3. you can delete prim uv attrib if you don't need it anymore
tamte
I guess easier without promoting would be just purely doing this
1. Prim Wrangle:
vector uv = primuv(0, "uv", @primnum, set(0.5, 0.5, 0));
int udim = 1001 + int(uv.x) + int(uv.y)*10;
s@name = sprintf("udim_%d", udim);
jsmack
There is also the texprintf() function that lets you skip the udim calculation step.

vector uv = primuv(0, "uv", @primnum, set(0.5, 0.5, 0));
@name = texprintf(uv.x, uv.y, "%s_%(UDIM)d", "udim");
BrandonRiza
Thanks for the replies, guys. I appreciate the input.
I've made a sample file and verified that the name attrib is jiving with the number of UDIM tiles (reads 4 unique strings…duping the tiles and feeding them into the merge yields 8…), but how would you guys go about spitting out these four tiles into a sequence of bgeo files?
1001.bgeo
1002.bgeo
1003.bgeo
1004.bgeo

Cheers, and thanks.
tamte
you can for example loop over the name attrib and use File SOP in Write mode to write each iteration to separate file
or as in this example, create filename attrib based on udim and use that directly as a path for each file in a loop
BrandonRiza
Thanks for your input, guys!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB