point.setAttribValue() error

   4057   2   1
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
I have the following code in a python otl which gives me error message unless I suppress the if statements part of code. (hip file and olt are attached)

Advices are appreciated!

import math

# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()

# Add code to modify the contents of geo.

point = geo.points()

position = point.position()

origin = hou.Vector3(0,0,0)
north = hou.Vector3(0,1,0)
vertical_surface_normal = hou.Vector3(0,1,0)

distance = hou.Vector3.distanceTo(position, origin)

zeta = 90 - hou.hmath.fit(distance, 0,1, 0,90)

pai = hou.Vector3.angleTo(position, north)

surface_normal_azimuth = hou.Vector3.angleTo(vertical_surface_normal, north)

diff_btw_pai_and_surface = pai - surface_normal_azimuth

height = math.cos(math.radians(zeta))*math.cos(math.radians(diff_btw_pai_and_surface))

if height < 0:
height = 0

attrib_h = geo.addAttrib(hou.attribType.Point, “H”, 0.0)

point.setAttribValue(attrib_h, height)

Attachments:
Archive.zip (17.5 KB)

User Avatar
Member
1908 posts
Joined: Nov. 2006
Online
What is the error message exactly? (Sorry, don't have time to check the file).

Edit:

The only glaring thing I see is your handling of a negative height. If the height is less than 0 you are setting it to the integer value 0, which might cause a problem with the setAttribValue() call. Try setting height to 0.0 in that case, since it expects a float.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
Dear graham,

You advice points out exactly the error in my code: integer zero is not the same as a float zero.

In my case, the if related code should be:

if height < 0.0:
height = 0.0

Thank you very much for you prompt and kind help!

- J
  • Quick Links