Run a query in a plugin

Tue 4. Apr 2017, 18:38

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?
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: Run a query in a plugin

Wed 5. Apr 2017, 00:54

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?
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: Run a query in a plugin

Wed 5. Apr 2017, 11:57

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.
User avatar
[Articy] Peter Sabath
Articy Staff
Articy Staff
 
Posts: 89
Joined: Wed 23. Nov 2011, 13:58
Location: Bochum

Re: Run a query in a plugin

Wed 5. Apr 2017, 17:47

Sweet, thanks for the info
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Return to articy:draft Macro Devkit

Who is online

Users browsing this forum: No registered users and 9 guests

Who We Are
Contact Us
Social Links