Jump to content

Dot Vector in Python ?


CinnamonMetal

Recommended Posts

def theLooper(curNode):
    for thePrim in curNode.geometry().prims():
        primColor = thePrim.floatListAttribValue("Cd")
        rounded = tuple((round(total,3)) for total in primColor)
        print(thePrim.number())
        print(primColor)
        print("Theese are the rounded numbers\n"+str(rounded))
        #print(round(primColor,3))
        dot = hou.Vector3(primColor).dot(hou.Vector3((rounded))
        tolerance = 0.000001
        if dot >= 1.0-tolerance and dot <=1.0+tolerance:
            print("match")
        else:
            print("no match")
    if curNode.geometry().findPrimAttrib("Cd"):
        print("yes")
    else:
        print("no")

The error is at the `tolerance` variable ?

Link to comment
Share on other sites

def theLooper(curNode):
    for thePrim in curNode.geometry().prims():
        primColor = thePrim.floatListAttribValue("Cd")
        rounded = tuple((round(total,3)) for total in primColor)
        print(thePrim.number())
        print(primColor)
        print("Theese are the rounded numbers\n"+str(rounded))
        #print(round(primColor,3))
        dot = hou.Vector3(primColor).dot(hou.Vector3((rounded))) # closing parentheses was missing
        tolerance = 0.000001
        if dot >= 1.0-tolerance and dot <=1.0+tolerance:
            print("match")
        else:
            print("no match")
    if curNode.geometry().findPrimAttrib("Cd"):
        print("yes")
    else:
        print("no")

 

Python tends to throw a syntax error on the following line when a line doesn't complete it's statement i.e. parentheses block not closed.

Link to comment
Share on other sites

Common I missed that. :wacko:

I suppose my truncated rounded variable is not working as I thought, if it was the results should be match :( 

Since one values gives me a valid float color value; any suggestions on how I can get Houdini to test if the truncated float color value is equal to that of the full float color value ?

Edited by CinnamonMetal
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...