Naming objects based on their UDIM tile?

   3985   6   2
User Avatar
Member
13 posts
Joined: May 2014
Offline
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…

Attachments:
UDIM.png (796.9 KB)
Subnet.png (100.6 KB)

User Avatar
Member
8518 posts
Joined: July 2007
Offline
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
Edited by tamte - July 19, 2018 17:41:17
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8518 posts
Joined: July 2007
Offline
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);
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
7737 posts
Joined: Sept. 2011
Online
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");
User Avatar
Member
13 posts
Joined: May 2014
Offline
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.

Attachments:
MeshNameViaUDIMtile.hiplc (106.3 KB)

User Avatar
Member
8518 posts
Joined: July 2007
Offline
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

Attachments:
MeshNameViaUDIMtile_fix.hiplc (111.1 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
13 posts
Joined: May 2014
Offline
Thanks for your input, guys!
  • Quick Links