Hello! I would like to know if there is a way to create our own zero-touch nodes which can save input data after closing and saving Dynamo?
Like Slider component saves the value which is set on, OR codeblock component saves the code.
Thank you for your help in advance!
You can’t do this with ZT, but you can use write an explicit nodemodel node.
/// depending on the culture of the system Dynamo is running on.
/// Read more: https://docs.microsoft.com/en-us/dotnet/framework/resources/creating-resource-files-for-desktop-apps
/// You can use the -l "es-ES" flag when starting DynamoSandbox.exe to replace the English strings with Spanish ones.
/// For more info on the CLI interface read more: https://github.com/DynamoDS/Dynamo/wiki/Dynamo-Command-Line-Interface
/// </summary>
[NodeName("LocalizedNode")]
[NodeDescription("CustomNodeModelDescription", typeof(Properties.Resources))]
[OutPortNames("string")]
[OutPortTypes("string")]
[IsDesignScriptCompatible]
public class LocalizedCustomNodeModel : NodeModel
{
public LocalizedCustomNodeModel()
{
RegisterAllPorts();
}
[JsonConstructor]
public LocalizedCustomNodeModel(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts) { }
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
(this example is just a simple nodeModel)
If you add a public property to a nodeModel it will be serialized if it’s something newtonsoft json can serialize easily.