3

I can't convert a simple [0, 20, 0, 20, 0, 20] to a list.

Code:

geo = hou.pwd().geometry()

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

Output:

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

Test:

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

I get the following error:

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

I read all the related questions but they don't seem to solve my problem.

10
  • 3
    classes may override the __str__() and __repr__() methods to display anything they want. Just because they display to look like a list doesn't mean they are. Commented Sep 8, 2014 at 0:35
  • What are the attributes of hou.BoundingBox? Are you able to get it's size by calling len(geo.boundingBox()) (or similar)? Are you able to index into it (geo.boundingBox()[1])? Commented Sep 8, 2014 at 0:39
  • @GregS yes, I know what you mean, I tried from string to list but I get the classic : ['[', '0', ',', ' ', '2', '0', ',', ' ', '0', ',', ' ', '2', '0', ',', ' ', '0', ',', ' ', '2', '0', ']'] Commented Sep 8, 2014 at 0:39
  • 1
    @Neo: If you mean they return BoundingBoxes, no they don't. If you mean they return the same type as each other, I don't see why that matters. Commented Sep 8, 2014 at 0:44
  • 2
    Yes, but those are easily convertible to lists, as they support __len__ and __getitem__. Ignacio's answer shows you how. Commented Sep 8, 2014 at 0:47

1 Answer 1

3

Vector3s can be converted to list since they implement item access methods.

list(geo.boundingBox().minvec()) + list(geo.boundingBox().maxvec())
Sign up to request clarification or add additional context in comments.

3 Comments

This does not work you have to call boundingbox first
geo.boundingBox().maxvec()
by saying Item access methods, you mean iterable?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.