Jump to content
Sign in to follow this  
AndrewVK

"float 3" attribute & python

Recommended Posts

I am trying to change (if exist) or create (if not exist)

"spritescale" point attribute from python sop

There is no problem with changing...

and it looks like

i can create something similar to spritescale.

But...

if geo.findPointAttrib('spritescale'):
   for point in geo.points():
	  # Works Fine #
	  point.setAttribValue('spritescale',(2,2,2))
else:
   # Looks like everything Ok  but it is NOT "spritescale" attribute
   # recognized by mantra
   geo.addAttrib(hou.attribType.Point,'spritescale',(1,1,1))

   for point in geo.points():
	  #!!!ERROR!!! No attribute with this name, type and size exist
	  point.setAttribValue('spritescale',(2,2,2))

How to create "float 3" attribute from python?

Share this post


Link to post
Share on other sites
attr = geo.addAttrib(hou.attribType.Point,'spritescale',(2,2,2))

for point in geo.points():
	point.setAttribValue(attr,(1,2,3))

Edited by hoknamahn

Share this post


Link to post
Share on other sites

Does not work... :(

Same problem here...i have 'spritescale' attribute...but sprite procedural can not recognize it.

//Sorry...russian here//

Хок проблема не в этом.

Если спрайтскейл создан стандартными средствами (в попах или атрибкриейтом)

то я могу рулить им просто по имени point.setAttribValue('spritescale',(2,2,2))

Это работает.

Если же я пытаюсь создать спрайтскейл питоном то он его создает без проблем

и выглядит он в спредшите точно так же...типа float3...

Но блин спрайт процедурал его не хавает...рендерит точки.

Edited by AndrewVK

Share this post


Link to post
Share on other sites
Does not work... :(

Same problem here...i have 'spritescale' attribute...but sprite procedural can not recognize it.

//Sorry...russian here//

Хок проблема не в этом.

Если спрайтскейл создан стандартными средствами (в попах или атрибкриейтом)

то я могу рулить им просто по имени point.setAttribValue('spritescale',(2,2,2))

Это работает.

Если же я пытаюсь создать спрайтскейл питоном то он его создает без проблем

и выглядит он в спредшите точно так же...типа float3...

Но блин спрайт процедурал его не хавает...рендерит точки.

Чичаз попробую тоже покрутить

Share this post


Link to post
Share on other sites

The problem is in the definition of "3 floats". When you set an attribute as (1, 1, 1) Python creates the tuple of integers instead of floats. So you have to give a hint "those numbers are really floats" as (1.0, 1.0, 1.0) which is also good from the readability point of view.

Also check any variable which supposed to be used in such "3 floats" attribute. This won't work:

a = 1
...
point.setAttribValue(attr,(a, a, a))

But this should:

a = 1.0
...
point.setAttribValue(attr,(a, a, a))

So be careful using "weak" type systems :lol:

Edited by hoknamahn

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  

×