1

I created a curve with several points. Now I want to delete some points based on one of their attribute (will_be_removed).

geometry spreadsheet

As is shown in the picture above, those points with i@will_be_removed set to 1 will be removed.

I tried using the VEX code below but it said invalid subscript for type: int.will_be_removed

if(@ptnum.will_be_removed == 1)
{
    removepoint(0, @ptnum);
}

How can I correctly reference those points?

Doug Richardson
  • 10,483
  • 6
  • 51
  • 77
John John
  • 111
  • 1
  • 4

3 Answers3

1

The error in this code

if(@ptnum.will_be_removed == 1)
{
    removepoint(0, @ptnum);
}

is because @ptnum is a VEX type int. @ptnum can also be written i@ptnum to exlicitly indicate it's type, but since it is a well known attribute (see documentation in link) you can also write it shorthand as @ptnum.

int types are numbers, and do not contain collections of other data.

Regarding attributes, you also want to keep in mind if they are vertex, point, primitive, or detail attributes.

Attribute precedence

When two components in the same geometry have an attribute with the same name, the attribute on the "lower level" of geometry is used, so:

Vertex attributes, which override:

     Point attributes, which override:

         Primitive attributes, which override:

                 Detail (whole geometry) attributes

Doug Richardson
  • 10,483
  • 6
  • 51
  • 77
1

or one liner wrangler will be

if (@will_be_deleted == 1) removepoint(0, @ptnum);
mehulJ
  • 109
  • 1
  • 12
0

I think I figure out a way to do it. Use @will_be_removed instead of @ptnum.will_be_removed instead:

if(@will_be_removed == 1)
{
    removepoint(0, @ptnum);
}
John John
  • 111
  • 1
  • 4