How do I get the destination of a Pin in code?

Thu 6. Apr 2017, 00:36

This seems like a basic task, but I cannot find any relevant fields / properties. I am traversing a dialogue tree setup in the flow editor and want to output what fragments each pin points to. I can iterate over the output pins. Given a pin, how do I get it's destination fragment / ObjectProxy?
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: How do I get the destination of a Pin in code?

Fri 7. Apr 2017, 00:12

I have changed my approach to using LinearizeFlowSegment to get FlowListNodes and traverse the tree.

Is this the only way to do it?

I would like to traverse ObjectProxys directly
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: How do I get the destination of a Pin in code?

Fri 7. Apr 2017, 19:15

Using linearization, I am now trying to jump two fragments over and it seems more complicated than it should be.

FlowListNodes have a field JumpTargets, but JumpTargets comtains FlowReferences, not FlowListNodes, so I cannot then continue my traversal, as FlowReferences have no JumpTargets. I have to find the corresponding FlowListNode in the original list and use it's JumpTargets.

I would expect to in some way be able to go from node to node in a flow just following links in the node. Pins seemed to do this, but as my original post said, I cannot see a way to actually get what the Pin connects to.

Am I missing something obvious here?
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: How do I get the destination of a Pin in code?

Wed 12. Apr 2017, 11:05

Hi doday,

The linking elements in the Flow are the "Connection" objects. This Objects are Children of the container object.
For example if your context object is a dialog whose object proxy is in the variable "dlg" you can collect all connections:

Code: Select all
foreach ( var obj in dlg.GetChildren() )
{
  if ( obj.ObjectType == ObjectType.Connection )
  {
    var srcPin = obj[ObjectPropertyNames.SourcePin] as ObjectProxy;
    if ( srcPin != null && srcPin.Id == myPin.Id )
    {
        // found a connection at the given pin, get the target pin and target object
        var tgtPin = obj[ObjectPropertyNames.TargetPin] as ObjectProxy;
        var tgtObj = obj[ObjectPropertyNames.Target] as ObjectProxy;
    }
  }
}


depending on you use case you might first collect all connections of a context object if you need to check them multiple times.
User avatar
[Articy] Peter Sabath
Articy Staff
Articy Staff
 
Posts: 89
Joined: Wed 23. Nov 2011, 13:58
Location: Bochum

Re: How do I get the destination of a Pin in code?

Thu 13. Apr 2017, 18:10

thanks, that is much cleaner than the solution I had cobbled together
doday
 
Posts: 29
Joined: Wed 15. Mar 2017, 23:06

Re: How do I get the destination of a Pin in code?

Mon 20. Nov 2017, 12:40

[Nevigo] Peter Sabath wrote:Hi doday,

The linking elements in the Flow are the "Connection" objects. This Objects are Children of the container object.
For example if your context object is a dialog whose object proxy is in the variable "dlg" you can collect all connections:

Code: Select all
foreach ( var obj in dlg.GetChildren() )
{
  if ( obj.ObjectType == ObjectType.Connection )
  {
    var srcPin = obj[ObjectPropertyNames.SourcePin] as ObjectProxy;
    if ( srcPin != null && srcPin.Id == myPin.Id )
    {
        // found a connection at the given pin, get the target pin and target object
        var tgtPin = obj[ObjectPropertyNames.TargetPin] as ObjectProxy;
        var tgtObj = obj[ObjectPropertyNames.Target] as ObjectProxy;
    }
  }
}


depending on you use case you might first collect all connections of a context object if you need to check them multiple times.

Correct me if I'm wrong, so Input/Output pins and the connections are children of an ObjectProxy (flow-fragment for example).
If I want to check if a connection exists between two ObjectProxies:
Code: Select all
objectproxyA.GetOutputPins[position] == connection["SourcePin"]
//And
objectproxyB.GetInputPins[position] == connection["TargetPin"]
//Implying position gave an existing escenario
//If those two conditions are met there exist a connection between objectproxyA & objectproxyB

Image
Julen
 
Posts: 5
Joined: Thu 9. Nov 2017, 09:59

Re: How do I get the destination of a Pin in code?

Tue 28. Nov 2017, 17:20

Connections provide the properties
Source: the object that is the source of this connection (e.g. a FlowFragment or Hub or any other connectable object)
Target: the object that is the target of this connection (e.g. a FlowFragment or Hub or any other connectable object)
SourcePin: the pin object from where the connection originates. (The Parent of the pin is the same as the "Source" of the connection)
TargetPin: the pin object to which the connection is targeted. (The Parent of the pin is the same as the "Target" of the connection)

So if you only need to know if ObjectProxyA is connected to ObjectProxyB you can check like this
Code: Select all
connection["Source"] == ObjectProxyA && connection["Target"] == ObjectProxyB


if that is found you may also check the pins if required. (e.g. If you only accept a connection which connects to the topmost input pin)
Code: Select all
if ( (int)connection[TargetPin][PinIndex] == 0 )
{
  // pin is connected to the topmost pin
}


Hope that helps
User avatar
[Articy] Peter Sabath
Articy Staff
Articy Staff
 
Posts: 89
Joined: Wed 23. Nov 2011, 13:58
Location: Bochum

Return to articy:draft Macro Devkit

Who is online

Users browsing this forum: No registered users and 11 guests

Who We Are
Contact Us
Social Links