Getting OutPort Data from nodes in API

Hi all,

UPDATE* I am trying to get the set data of the input nodes in my workspace through the following code;

internal EngineController engine { get; set; }
public List<string> typologyList { get; set; }

public List<string> Typology43()
    {

        typologyList = new List<string>();
        

        foreach (Dynamo.Graph.Nodes.NodeModel node in readyParams.CurrentWorkspaceModel.Nodes)
        {
            
            if (node.IsSetAsInput)
            {
                var startIndex = node.OutPorts[0].Connectors[0].Start.Index;
                var startId = node.GetAstIdentifierForOutputIndex(startIndex).Name;

                var startMirror = engine.GetMirror(startId); 

                object start = null;

                start = startMirror.GetData().Data;

                string estasi = start.ToString();
                typologyList.Add(estasi);
            }
        }
        
        return typologyList;
    }

This is then taken to a method and called from Xaml;

public List<string> TypologyTypesv2
    {
        get
        {

            List<string> output2 = Typology43();

            return output2;
        }

    }

I followed the guidelines from How To Create Your Own Nodes · DynamoDS/Dynamo Wiki · GitHub but I just don´t get my xaml to populate the list of set values of those nodes while it is working with other properties.

Any idea why? I would appreciate your help.

Thanks
Jaime

Is the double colon messing it up?

1 Like

I double checked and retested without the double colon, but it is not working without that error. Updated the code above with more information.

Is there a typo here? GetAs(t)Identifier…

why are you using get mirror?

If it works for your use case, it will be probably be simpler to just get the inputData from those input nodes - unfortunately not all input nodes support this type - but it might work depending on your use case:
Dynamo/NodeModel.cs at master · DynamoDS/Dynamo (github.com)
InputData will contain some values depending on node type.

Also - about the xaml… no idea since we can’t see your xaml, or the binding you are creating - atleast I guess thats what you’re doing - you may also need to implement INotifyPropertyChanged - read about that interface and wpf bindings.

3 Likes

Thanks @Michael_Kirschner2 and @SeanP !

Mmm, I rechecked the method and GetAstIdentifierForOutputIndex should be fine.

I tried with InputData property of the nodes, but still I don´t get it working;

public List<string> Typology43()
    {

        typologyList = new List<string>();
        

        foreach (Dynamo.Graph.Nodes.NodeModel node in readyParams.CurrentWorkspaceModel.Nodes)
        {
            
            if (node.IsSetAsInput)
            {
                
                string estasi = node.InputData.ToString();
                typologyList.Add(estasi);
            }
        }
        
        return typologyList;
    }
[JsonIgnore]
    public virtual NodeInputData InputData
    {
        get { return null; }
    }

As the value I would like from the nodes is the OutputData as well as the possible options of the nodes, in dropdowns for instance.

I gave it a try to OutputData as well but after defining methods and variables I get a few errors that I don´t find a workaround;
1.- “SampleWindowViewModel.GUID” : no suitable method to override
2.- The name Properties does not exist in the current context.(I cannot find where it is defined in the link you sent above)
3.- “NotificationObject” does not contain a definition for “GUID”

Thank you

I finally got it! The code I used to create the string is;

string estasi = node.OutputData.InitialValue;

Nonetheless, there are some nodes that are passing an empty value such as Revit.Selection.Categories and similar. Is there any work around to get these set values as well?