Modifying flow with plugin

Tue 24. Jul 2018, 08:07

Hi.

I’m writing a plugin that will automatically export dialogues from documents to flow fragments, but I cant’t see an option to modify (remove or add) their children. Am I missing something or is it simply not possible?
KarolStola
 
Posts: 4
Joined: Tue 24. Jul 2018, 07:57

Re: Modifying flow with plugin

Tue 31. Jul 2018, 10:21

Hi Karol,

I am not sure that I understand what you really like to do. What do you mean by export from documents to flow fragments?
For my understanding an export is a task that creates data that leaves the scope of articy:draft e.g. a JSON or XML file or something like that.
So it seems to me that you like to create a flow based on a document. If that is the case a simple drag and drop of a document (or some of its chapters) from the navigator to the flow might be the thing you like to do.

If you like to create new objects use the Session.Create...() methods. All these methods require a parent reference, so the method can check if the desired object can be created within that parent container and to automatically add it to the parents children list.
The Session.DeleteObject deletes an object, its own children, dependent objects like incoming or outgoing connections and unlinks the object from the children of its parent.
User avatar
[Articy] Peter Sabath
Articy Staff
Articy Staff
 
Posts: 89
Joined: Wed 23. Nov 2011, 13:58
Location: Bochum

Re: Modifying flow with plugin

Tue 31. Jul 2018, 17:06

Hi Peter!

Sorry for being unclear. The problem I experienced was with the drag and drop functionality. It works fine if I have a ready dialogue I know won't change. The problem starts when I'd like to modify it in the document view: the flow remains unchanged. So my solution would be to create a plugin which automaticaly modifies the flow according to changes in document. The Create...() functions seem promising, but require to recreate the whole dialogue hierarchy on my own (or do they?). Is the default function used to create flow from document exposed? I mean the one that is called when drag and drop takes place.

Another thing would be to swap the connections between old and new flows which I don't know how to do yet.
KarolStola
 
Posts: 4
Joined: Tue 24. Jul 2018, 07:57

Re: Modifying flow with plugin

Wed 1. Aug 2018, 12:59

Hi Karol,

Thanks for the additional information, which helps me to understand your problem. With that information I can tell you:

  • No, the drag-and-drop from document to flow is not exposed to the API layer.
  • Yes, you need to re-create the dialogue hierarchy.
  • In the document the elements are ordered by the "document" order, while in the flow the objects need a position. But since documents are linear the order can be easily transformed to a position.
  • It might be helpful if you use the Technical name property of a document element to store a reference to the flow object if it already was created (e.g. "FlowID_0x0100001600000026") so you might check if you only need to update an existing object or create a new one.
  • There is no matching object for "Image" sections in the document, so you either need to drop them or convert then into something else.
  • If you use template on the document objects you need to create matching ones for the flow objects and use the ObjectProxy.GetAvailableProperties() to get the list of to-be-copyied/synced template/feature properties.
  • Connections can be created using the Session.ConnectPins(...) method with the given pins from the to-be-connected objects. Keep in mind: for connections that connect elements within the same container its a OutputPin -> InputPin connection. For connections the connect a container to its first inner object it is a InputPin [Container] -> InputPin [inner element] and for the last element to the container its a OutputPin [inner element] -> OutputPin [Container] connection.
User avatar
[Articy] Peter Sabath
Articy Staff
Articy Staff
 
Posts: 89
Joined: Wed 23. Nov 2011, 13:58
Location: Bochum

Re: Modifying flow with plugin

Thu 2. Aug 2018, 19:19

Thanks Peter!

It seem that I've been able to do what I wanted. For further reference, here is some quick and dirty implementation I've managed to create:

https://drive.google.com/file/d/1NBUI1G ... sp=sharing
KarolStola
 
Posts: 4
Joined: Tue 24. Jul 2018, 07:57

Re: Modifying flow with plugin

Wed 13. May 2020, 16:10

Hi,

After a couple of years I came back to the project and noticed a bug. Up to now I used GetChildren method on document to retrieve Object Proxies used to recreate the Flow. I simply connected them based on their index, assuming that they are layed out in order of the document. It turned out that adding a new dialogue element in the middle of the document adds it to the end of the child list. How can I retrieve document contents in order it appears in the editor?
KarolStola
 
Posts: 4
Joined: Tue 24. Jul 2018, 07:57

Return to articy:draft Macro Devkit

Who is online

Users browsing this forum: No registered users and 16 guests

Who We Are
Contact Us
Social Links