Get ouput from a nodeModel

since you cant pass an object to an output and only use simple things like string, int, and double, how can i get the result from this

ReturnDocument =
AstFactory.BuildFunctionCall(getDoc,
new List { AstFactory.BuildStringNode(“file”)});

getDoc takes a string and returns a type Document, i want that document. how do i extract that from ReturnDocument which has the Document in it but as an AssociativeNode.

build an assignment between a function call ASTnode and one of the outputs of the node.

at runtime, when the AST is evaluated this means, call the function, and assign the result to the identifier which is represented by the output port of the node.

the function you call should be defined in some other assembly (not the one containing your nodeModel) - it also cannot be a lamda.

I can try to clarify a bit more - inside the buildAST function you should only deal with AST nodes - the function is not guaranteed to execute every time the node does - it’s like a compile step, sometimes you don’t need to recompile the node to execute it.

The suggestion above should let you return the result of that function call to the output port of your node, but from your question, I’m not sure thats what you need.

@Michael_Kirschner2 thanks, i am familiar with how to output that in the node and that works great. but i also want to use that output elsewhere in the node. so i have two choices but i need both

  1. option 1, get teh revit document i want, do stuff with it, but then i cant pass that as an output to the node because its not a string or double
  2. option 2, get the document using astfactofy function that passes a string to another method sitting in another dll, but i need to do stuff with that document but its all locked up in the ast.

so something I cant do but will give you an idea of what i am trying to do is

AssociativeNode ReturnDocument = AstFactory.BuildFunctionCall(getDoc,new List { AstFactory.BuildStringNode(“filePath”)});

Document theDoc = (Document) ReturnDocument; <- i want to cast , retrieve, convert…the Document that is in the AssociativeNode, i know its in there because the node outputs a Document

if you need access to the underlying document, the BuildOutputAST method is the wrong place.

What you can do, is use the vm data bridge - this will let you call an arbitrary c# action with real data (instead of AST nodes that represent that data) - you can see how it used here:

and here:

first register a call back, then generate some data to send it - the idstring is used to find the right callback.