Class Attribute With A Padding of 2

   1324   4   0
User Avatar
Member
128 posts
Joined: Sept. 2018
Offline
So my class attribute number starts with a "0" but I would like to take the class attribute that start with 0 and make it with a padding of 2 and make it a 00, then 01, 02, 03... ...10, 11, 12 and so on.

Can anyone help with this?
User Avatar
Member
35 posts
Joined: Dec. 2012
Offline
Are you in vex, python = v1.zfill(10), or hscript = padzero(size, value)? Also it would have to be a string instead of an int or float I believe.
User Avatar
Member
128 posts
Joined: Sept. 2018
Offline
TRex92
Are you in vex, python = v1.zfill(10), or hscript = padzero(size, value)? Also it would have to be a string instead of an int or float I believe.

I am currently using the connectivity sop, setting connectivity type to Primitive, and that is creating a class attribute. I have a prefix with "Mesh_". I just need the class attribute to be Mesh_00 instead of Mesh_0.
Edited by VGriffith - Nov. 4, 2021 18:16:12
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Side note regarding string based workflows: try to avoid using string for your classes, and prefer using integers when you can.
It seems that string classes are slower to work with.

For a simple comparison, you can just run a plain for-loop over string and integer classes: the latter should iterate much faster.
User Avatar
Member
4515 posts
Joined: Feb. 2012
Offline
Hi,

You can do it like this:

s@id = sprintf("Mesh_%02d", i@class);
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links