Jump to content
Sign in to follow this  
bhbilbao

From group_nameX to intenger attribute

Recommended Posts

Hi,
 need some help.
After using duplicate node. I marked "Create Output Groups" for the copies as: zone$CY
Now I have some groups inside primitives spreadsheet named group:zone1group:zone2 | group:zone3..etc, with values 0 or 1.
I need to create a new intenger attribute named "zone" only with the number of the zone,

and then finally delete the groups. all this with attribute wrangle.

Thanks in advance.

Edited by bhbilbao

Share this post


Link to post
Share on other sites
string groups[] = detailintrinsic(0, "primitivegroups");

foreach(string s; groups){
    if (inprimgroup(0, s, @primnum)){
        i@zone = opdigits(s);
    }
}

 

There is no way to delete groups in VEX as far as I know. You will need to add a Group SOP and go to the Edit tab, then Delete and type zone*

Edited by Jero3d
Updated so it works with any number of groups, it would break after 10 groups before, new code should be fine
  • Like 2

Share this post


Link to post
Share on other sites

Thanks a lot Jero3D,

I saw that solution before in the forums but I dont understand why didnt work before.
I also solved in another ugly way, (except there is no value for zone0).
nodes:
name (group mask: zone*)
+
attribstringedit (From: zone . To: *empty*)

Bye.

Share this post


Link to post
Share on other sites

using Name SOP for that purpose it's not an ugly way, that's one of it's uses

the ugly part is keeping the number as a string, why don' tyou just keep the name?, you can always extract int from is using opdigits() VEX function when needed

Share this post


Link to post
Share on other sites

yes Tomas,

I finally stayed with the method explained by Jero3D. More clean.
Sorry about these questions but Im very newbie(1 week) with this software. I come here after more than 14 years with maya.
Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×