Jump to content

From group_nameX to intenger attribute


bhbilbao

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
Link to comment
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
Link to comment
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.

Link to comment
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

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...