Python: Arrays supported?

   4154   6   2
User Avatar
Member
339 posts
Joined: June 2013
Online
Hi
Delving into python and noticed some trouble with getting array attributes with it. Scene attached.




When it comes to processing a whole geo an generate lists of an attribute's values in all elements or a list of the unique values, I'm guessing VEX is faster than Python, no? So I generated those in VEX and was expecting to collect them in Python, but no luck.

Am I missing something or are arrays not supported? Values fetched for arrays seem to be default: 0, “”, etc.

Thanks
Edited by probiner - Feb. 7, 2019 01:11:45

Attachments:
Python Get Detail String Array.hipnc (80.5 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hey, this seems the function you are looking for
print geo.stringListAttribValue(“mats”)
User Avatar
Member
339 posts
Joined: June 2013
Online
Thanks, that works!

When I was roaming hou.Geometry() [www.sidefx.com] I did a page search for “array” and nothing of the sort was picked up, so thought the other one was the way to go.

Cheers
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hello again,

I was trying to collect the values of a point attribute with the following:
geo.pointIntAttribValues("myAttribute")

and I get this error: “Attribute must support tuple access”
I guess that's because my attribute is an integer array, and that function can't deal with it?

Anyway, I can collect the arrays if I iterate through each point:
allArrays = []
for point in geo.points():
    myAttribute = point.intListAttribValue("myAttribute")
    allArrays.append(myAttribute)

but I wanted to use the pointIntAttribValues() function because it is said to be faster than iterating through each point, when you want all the values for one attribute.
User Avatar
Member
72 posts
Joined:
Offline
Big coincidence, I'm working on a weights exporter (unpacking capture weights first) where I need to use pointIntAttribValues as well.
Exactly for what Andr is saying…Any insights would be great, got a feeling it's a bug, because what other type then list can we store in a point attribute if we need variable lenght.

-Johan
Edited by Johan Boekhoven - Feb. 18, 2019 12:05:34
User Avatar
Member
339 posts
Joined: June 2013
Online
Sample scene file?
If you want to collect an array appended from all points, do that in vex into an detail attribute and gather it with the function you mentioned to me.
Edited by probiner - Feb. 18, 2019 14:04:09
User Avatar
Member
72 posts
Joined:
Offline
Here's a test file, the error is:
return _hou.Geometry_pointIntAttribValues(*args)
OperationFailed: The attempted operation failed.
Attribute must support tuple access

So it seems that function can only pull int values that are “packed” as tuples. But if you think about it it makes little sense.
And the helpfile is quite ambiguous about the method.

Attachments:
pointIntAttribValues_error.hiplc (193.4 KB)

  • Quick Links