You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to cast a Gf.Vec3f to a float in python causes the Gf.Vec3f's floating point data to be interpreted as a string. I'm sure this applies to lots of other types of data casting, and lots of other pxr classes (at least within Gf). I don't really understand the mechanism here, since calling str() on a Gf.Vec3f generates a reasonable string representation of the data.
Steps to Reproduce
Run the following python code:
rom pxr import Gf
vec = Gf.Vec3f(34.56, 78.91, 23.45)
f = float(vec)
print f
This produces the following output:
Traceback (most recent call last):
File "converttofloat.py", line 4, in
f = float(vec)
ValueError: could not convert string to float: q=
B�ѝB���A
System Information (OS, Hardware)
Tested on Linux and Windows
Package Versions
USD 20.08
The text was updated successfully, but these errors were encountered:
I have mixed news on this one. I checked in a fix for how we implemented Python's buffer protocol for Python 2 for these types. It makes these examples raise TypeError, which seems good.
However, some Python 3 builtins like int() will just blindly attempt to treat bytes from objects that support the buffer protocol as string characters, ignoring what the actual data format is. I filed a Python bug for this, https://bugs.python.org/issue41707
When (if?) that Python bug gets fixed, that should resolve this for Python 3.
I have an array of corner pairs (min and max from 3D BB). How can I get the minimum and maximum corners from this array? each corner is in gf vec3d format.
Description of Issue
Trying to cast a Gf.Vec3f to a float in python causes the Gf.Vec3f's floating point data to be interpreted as a string. I'm sure this applies to lots of other types of data casting, and lots of other pxr classes (at least within Gf). I don't really understand the mechanism here, since calling str() on a Gf.Vec3f generates a reasonable string representation of the data.
Steps to Reproduce
rom pxr import Gf
vec = Gf.Vec3f(34.56, 78.91, 23.45)
f = float(vec)
print f
Traceback (most recent call last):
File "converttofloat.py", line 4, in
f = float(vec)
ValueError: could not convert string to float: q=
B�ѝB���A
System Information (OS, Hardware)
Tested on Linux and Windows
Package Versions
USD 20.08
The text was updated successfully, but these errors were encountered: