Isotropix Forums

Accessing elements from arbitrary CoreVector template

Clarisse Scripting related topics

Accessing elements from arbitrary CoreVector template

Unread postby briansilva » Thu Feb 20, 2020 1:56 pm

Hello! I know about the Python mappings for basic data types (ix.api.IntArray, ix.api.OfObjectVector, etc.), but is there a way to access CoreVector elements in Python if they're of a different type?

I'm trying to get at CommandSignaure objects, and I can get as far as this:

python code

for index in range(ix.api.CommandRegistrar.get_commands_count()):
cmd_caller = ix.api.CommandRegistrar.get_command(index)
if cmd_caller.get_command_id() == "AddReferenceFilename":
sigs = cmd_caller.get_signatures()
print sigs


The result is a list of:
Code: Select all
<Swig Object of type 'CoreVector< OfCommandSignature * > *' at 0x000001F0EAA97A80>


but I can't find any way to access the elements of the vector. Is there a way from Python, or do I need to jump into C++?
briansilva
 
Posts: 51
Joined: Mon Mar 25, 2019 12:43 pm

Re: Accessing elements from arbitrary CoreVector template

Unread postby anemoff » Thu Feb 20, 2020 2:08 pm

OfCommand* type wrappers aren't available in Python. You'll have to use C++.
CoreVector (and other containers) for specific types have to be explicitly wrapped in Python. We've exposed most of the commonly used types, but not all of them. Hence your problem with CoreVector<OfCommandSignature *>.

What are you trying to do with the commands?

Sorry for the inconvenience!
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Accessing elements from arbitrary CoreVector template

Unread postby briansilva » Thu Feb 20, 2020 3:43 pm

That's quite alright! There's probably a way simpler way to do this, but I was just hoping to get the names of the command arguments. I can get the types in Python with display_signatures, but the names aren't output.

Is there a better way to get documentation on commands?
briansilva
 
Posts: 51
Joined: Mon Mar 25, 2019 12:43 pm

Re: Accessing elements from arbitrary CoreVector template

Unread postby anemoff » Thu Feb 20, 2020 4:52 pm

This page should help: https://www.clarissewiki.com/4.0/sdk/namespacecmds.html
Currently, the link to the "cmds" namespace page is broken on the Namespaces root page (bug already logged).
Be sure to bookmark this one. ;)
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Accessing elements from arbitrary CoreVector template

Unread postby briansilva » Thu Feb 20, 2020 6:27 pm

Oh man, awesome, hahaha... I suspected it would be something simple. Thanks a lot! Bookmarked. :-)
briansilva
 
Posts: 51
Joined: Mon Mar 25, 2019 12:43 pm


Return to Scripting