Remove empty attributes

   878   7   0
User Avatar
Member
15 posts
Joined: 6月 2015
Offline
In Houdini, check all the attributes of the current node, points, vertices, faces, and details. No matter whether the attribute type is integer, floating point, vector, string, quaternion, as long as the attribute value is empty, delete the empty attribute. How to do it? How to write it in vex?
User Avatar
Member
293 posts
Joined: 1月 2013
Offline
What do you mean by an attribute being empty?
All attributes have some default value. For example, for int type it will be zero, but zero is not an empty value. The only thing that fits the definition of an empty attribute is a string.
Edited by alexwheezy - 2024年6月22日 03:15:44
User Avatar
Member
2115 posts
Joined: 9月 2015
Offline
If you want to remove attributes there is the Attribute Delete node or if in a vex context you can use one of the removeattrib function or one of its variations - https://www.sidefx.com/docs/houdini/vex/functions/removeattrib.html [www.sidefx.com]
User Avatar
Member
8753 posts
Joined: 7月 2007
Online
alexwheezy
What do you mean by an attribute being empty?
All attributes have some default value. For example, for int type it will be zero, but zero is not an empty value. The only thing that fits the definition of an empty attribute is a string.
On top of this, the default value is user defined

Like if int attrib like i@id has default value -1 would you consider it empty if all elements are at -1 ? Or still 0

And likewise if a string attribute has default value other than empty string, would you consider that attribute empty if all elements are at that default value or rigidly stick to an empty string which is technically a non-dedault value in such case and technically makes it not "empty"
Edited by tamte - 2024年6月22日 10:02:38
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
293 posts
Joined: 1月 2013
Offline
tamte
Like if int attrib like i@id has default value -1 would you consider it empty if all elements are at -1 ? Or still 0

Thanks, I forgot that Attribute Wrangle binds the attribute with a default value of -1 if no other value is specified while Attribute Create starts with 0 and the user needs to explicitly set -1 to match the Attribute Wrangle behavior.
User Avatar
Member
8753 posts
Joined: 7月 2007
Online
Cant chack right now, but I believe Wrangle sets some defaults and type automatically based on common attribute names like @id, @orient, @Cd

However most numerical attribs will still default to 0

What I meant by user having control over default value is that you always can set it explicitly whether in Attrib Create or in wrangle as long as that wrangle is a creator of that attribute, like this:
int @id = 123;

But ultimately I just wanted to point out varying default values so that OP can decide what is considered "empty" for their case
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
15 posts
Joined: 6月 2015
Offline
This is just an example. Sometimes when you import something, there will be many such attributes, but the attribute values ​​are empty.

Attachments:
{11751-x-7479135603497}.png (15.5 KB)

User Avatar
Member
2115 posts
Joined: 9月 2015
Offline
Yes, that is an empty string attribute called name.
You can delete it in the way I mentioned before.
  • Quick Links