将类转换为Python列表

3 投票
1 回答
16057 浏览
提问于 2025-04-20 08:46

我无法把一个简单的 [0, 20, 0, 20, 0, 20] 转换成一个 list

代码:

geo = hou.pwd().geometry()

print geo.boundingBox()
print type(geo.boundingBox())

输出:

[0, 20, 0, 20, 0, 20]
<class 'hou.BoundingBox'>

测试:

list(geo.boundingBox())
len(geo.boundingBox())

我遇到了以下错误:

object BoundingBox is not iterable.
Object of type 'BoundingBox' has no len()

我看过所有相关的问题,但它们似乎没有解决我的问题。

1 个回答

3

Vector3可以转换成list,因为它们有可以访问单个元素的方法。

list(geo.boundingBox().minvec()) + list(geo.boundingBox().maxvec())

撰写回答