How to check port value for null in BuildOutputAst & post warning

How can I check to see if a connected port has a null input and then post a warning?
I know I can call InPorts[0].IsConnected but I want to handle the case when the port is connected but the input is null

        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            var node0 = inputAstNodes[0];
            var port0 = InPorts[0];

I can’t find a property or method on either node0 or port0 that gets the value of the input
Thanks

Hi,
I don’t know if this can help you.


Sincerely,
Christian.stan

Sudo code, but something like:

If (input == None)
{
LogWarningMessageEvents.OnLogWarningMessage(“The input is null and cannot be processed. Check for null in the provided data”);
return new List();
}

Thank you @jacob.small, but where does input get its data? My point is that I want to add a check inside BuildOutputAst to see if the user is inputting “null” to a specific input node.

My thought is that input is the content from the dynamo environment.

The first exercise in the Advanced Dynamo Node Customization section in the developer primer is an example of this behavior. https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/8-advanced-dynamo-node-customisation

I was mistakenly thinking that I needed to post the warning in BuildOutputAst in the NodeModel.
Instead the value can be checked and the error posted in the NodeFunctions code.

1 Like