Macro from code

FlowCanvas Forums Support Macro from code

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #2335


    Is it somehow possible to ‘call’ a macro from code, giving it input and getting output ? treating it like a function(s) that can be called from script ?

    Basically like a data provider.




    Hello and very sorry for the late reply!

    While techically it is possible, there is not API to make it easy. With that said you can add these lines of code into Macro.cs somewhere so that this can be done easier.

    With these lines of code in there, you will then be able to use a Macro and either Set one of it’s Value Inputs, Call one of it’s Flow Inputs, or Get one of it’s Value Outputs from code. Remember though, that you will need to instantiate the Macro asset and call StartGraph to the instance. Here is an example:

    With all that said though, Macros can still not be treated exactly like a Function would, since a Macro can have multiple Value as well as Flow outputs and as such it is implemented to work differently than a function would.

    other alternative you may want to consider, is to actually use a “Custom Function” setup (in the browser -> “Function/Custom/New Custom Function”) which work similar to how a usual code function would and can also be invoked from code via the “CallFunction” method.
    For this alternative, you dont really need a Macro Asset, but a FlowScript Asset would be preferable since the inputs and outputs of the Macro does not matter.

    Thus what I would recommend doing, is to create a FlowScript Asset as normal and create a Custom Function within that FlowScript, like this example:

    Then from within your code, instantiate the flowScript asset and call “StartGraph” on it’s instance. Finally call “CallFunction” on the instannce wherever is required. Here is an example:

    You can of course have any number of Custom Functions implemented within the flowScript.

    Please let me know if any of two options above work for you, or if you need any more information or help.


    Join us on Discord:

    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.