Articy Forum


https://www.articy.com:443/forum/

Run a query in a plugin

https://www.articy.com:443/forum/viewtopic.php?f=47&t=18155

Page 1 of 1

Run a query in a plugin

Posted: Tue 4. Apr 2017, 18:38
by doday
I want to find all objects of a certain template and export them using my custom exporter.

RunQuery is in the articy.API namespace, and requires an ApiSession object. I assume when I am running plugin code, a session has already been created. Can I access the current session?

Is this a task that is possible using a Plugin, or would I need to an an articy API license?

Re: Run a query in a plugin

Posted: Wed 5. Apr 2017, 00:54
by doday
Further delving revealed RunQuery is also a function on ObjectProxy. Does this limit the query to objects underneath the invoking object within the articy hierarchy, or is the invoking object irrelevant, except for the "self" term if you want o use it in queries?

Re: Run a query in a plugin

Posted: Wed 5. Apr 2017, 11:57
by [Articy] Peter Sabath
Hi doday,

Your task perfectly fits for a plugin. The API license is only needed if you want to write an stand-alone program or windows service that works with articy:draft data.

If you write a plugin you derive your plugin class from from "MacroPlugin" base class which provides the current articy:draft ApiSession object as property.

Using the RunQuery(...) method on an ObjectProxy set the "self" reference to that object. If the query does not use that keyword it is the same as calling RunQuery on the session.

To get all Objects with a certain template you could use a query similar like:

Code: Select all
SELECT * FROM Project WHERE TemplateName='MyTemplate'


You can download the source code of our demo plugins here. They might give you a better overview than reading the documentation alone.

Re: Run a query in a plugin

Posted: Wed 5. Apr 2017, 17:47
by doday
Sweet, thanks for the info

All times are UTC
Page 1 of 1