# Dot Vector in Python ?

## Recommended Posts

Outside of the formatting issue, it looks fine.

Your error isn't related to that code(unless its related to the formatting issue)

##### Share on other sites

Sorry, can you point out the formatting issue ?

##### Share on other sites

The section entitled "Few Important Things to Remember" at the end, briefly goes that.

I recommend going through other tutorials I found here,

##### Share on other sites

I know that; what I can't figure out is the error.  I get an error related to hou.py in the python library.

##### Share on other sites

I recommend posting an example file showing the issue like Bonsak suggested.

##### 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))
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 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 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 on other sites

Common I missed that.

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 on other sites

Why would it match (and why would you need it to?), your rounding to the .001th decimal place and testing for a tolerance to .00001th place.

## Create an account

Register a new account