Jump to content

Is there a way to use expressions in for Default attributes?


magneto

Recommended Posts

Hi,

I noticed the AttribCreate SOP doesn't allow using expressions in the Default parameter. Is it really like this? Because the error message says "bad data type", and the help doesn't mention this.

I assume this is done for optimization where Houdini assigns a single value to everything else at once that will get the default attribute value?

Is there a way to accomplish this?

Thanks :)

  • Like 1
  • Downvote 2
Link to comment
Share on other sites

But if you want to write a dynamic attribute, which is what you want to do, why don't you just put it in the "write values" fields. I don't see what benefit you're going to get by putting the same expression in the default fields.

Basically I only ever use the default fields when I turn "write values" off, which is sometimes needed to stop warnings that the attribute doesn't exist in SopSolver stuff or attribute transfer.

C

Link to comment
Share on other sites

Thanks, but I am not using the same expression in both. I want to use an expression for the actual attribute value for my Group, and use another expression for everything else.

I can do it using 2 AttribCreate nodes but I thought I could do it with one using the Default parameter.

Link to comment
Share on other sites

I would have thought that it would do everything it does on the group specified. So even if it did work, the default attribute would be on the group and everything else zero.

I've been through that mindset before with having to use two promotes to get max value and wrote it in Python as one node, which ended up being slower :) Best to just use two nodes and not let it bother you.

Link to comment
Share on other sites

No the Default actually applies everything else except the group if the attribute doesn't exist I think. It cannot apply to what's inside the group, a Value does that.

So group half of a Grid and then apply an AttribCreate with Cd. Set Value to either rand($PT) for red, or just red for instance. Then set the Default to Blue. You will see the other half outside the group will be Blue.

I just thought since I can dictate what to use for entities that doesn't have an attribute and outside the group, I could use expressions.

It's ok though, mine was just curiosity.

Link to comment
Share on other sites

You can have an expression in the Default field, but it cannot make reference to a currently iterating element since the default is a constant value across the history of the attribute.

An attribute's default value is defined once for the attribute on creation. You can think of it like creating an attribute and setting all elements to that Default value. When you then have something in the Value parameter and possibly in the group parameter, you basically then tell Houdini to set those elements to your new value. The default really comes into play when you add additional elements to your geometry. In your example above, if you then take another grid with no Cd attribute and merge it into your colored grid, you will see the grid turn blue. This is because the default value of the attribute is applied to the new geometry because it needs to have an attribute value now that it is part of the same detail.

Edited by graham
  • Like 1
Link to comment
Share on other sites

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...