Jump to content
CinnamonMetal

Dot Vector in Python ?

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 ?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

You are missing a closing parenthesis at the end of dot = hou.Vector3(primColor).dot(hou.Vector3((rounded)))

-b

Too late :)

Edited by bonsak

Share this post


Link to post
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

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

×