Isotropix Forums

How to get position data from GeometryPositionArray??

Clarisse Scripting related topics

How to get position data from GeometryPositionArray??

Unread postby mnhan32 » Sat Dec 17, 2022 5:02 am

Hey,
I was playing around with Clarisse Python API to get positions from a GeometryAbcPointCloud at certain frame.
What I used to do is to set current frame and use the `get_positions` method from `GeometryPointCloud` class
Code: Select all
ix.cmds.SetCurrentFrame(1001)
item = ix.selection[0]
geo = item.get_module().get_geometry()
point_cloud = geo.get_point_cloud()
positions = ix.api.GMathVec3fArray()
point_cloud.get_positions(positions)

Recently, I found out there is a method called `get_positions_at`[clarissewiki_link] which can return geometry point cloud positions at given frame. I figure this suits me better, since set current time will actually force scene data to update. However, this method return a `GeometryPositionArray`[clarissewiki_link] and I have no idea how to get position data. i'd tried operator[] but got `object is not subscriptable` error.
Code: Select all
sel = ix.selection[0]
point_cloud = sel.get_module().get_geometry().get_point_cloud()
geometry_position_array = point_cloud.get_positions_at( 1001 )
print(geometry_position_array[0])

Code: Select all
Traceback (most recent call last):
File "<string>", line 4, in <module>
TypeError: 'GeometryPositionArray' object is not subscriptable

I check the doc, other than operator[], it only has methods to return count.Can anyone explain how am I supposed to get data from GeometryPositionArray?
mnhan32
 
Posts: 8
Joined: Wed Oct 16, 2019 4:21 pm

Re: How to get position data from GeometryPositionArray??

Unread postby anemoff » Mon Dec 19, 2022 5:39 pm

Hi,

The type "GeometryPositionArray" is not fully exposed in Python, so the operator [] is not accessible.
I'm afraid there's no workaround for now and you'll have to use "get_positions" instead.

The documentation reflects the C++ API, and the associated Python bindings are not always exposed completely or at all.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 491
Joined: Wed Jan 13, 2016 10:10 am

Re: How to get position data from GeometryPositionArray??

Unread postby mnhan32 » Wed Dec 21, 2022 4:07 am

Thanks for the reply,
I will just use get_positions for now. By the way, is there anyway to tell wether python binding are exposed completely or not in doc?
mnhan32
 
Posts: 8
Joined: Wed Oct 16, 2019 4:21 pm

Re: How to get position data from GeometryPositionArray??

Unread postby sam » Wed Dec 21, 2022 8:34 am

you can use print(dir(object)) object being your variable/class. This will list the methods available for the input class.

https://docs.python.org/3/library/functions.html#dir
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1870
Joined: Fri Jan 25, 2013 11:33 pm

Re: How to get position data from GeometryPositionArray??

Unread postby mnhan32 » Fri Dec 23, 2022 3:47 am

Thanks for the tip.
mnhan32
 
Posts: 8
Joined: Wed Oct 16, 2019 4:21 pm


Return to Scripting