Skip to content

Replication and Replication Guide Part 2

Yu Ke edited this page Jul 27, 2016 · 4 revisions

Replication and Replication Guide

  1. Replication and Replication Guide 1: Replication
  2. Replication and Replication Guide 2: Design for Replication
  3. Replication and Replication Guide 3: Replication Guide

In Replication and Replication Guide Part 1 we explain how Replication computation is done. The signature of a node decides Replication behavior. In Dynamo, we have two ways to specify the signature:

  1. For custom node, we can specify the expected type in input node:

  2. For parameter in zero touch function (T below could be any type):

  • Multidimensional array in C# will be imported as multidimensional list with corresponding dimension. For example, if the type of parameter is T[] in C#, it will be imported as T[], T[][] will be imported as T[][] and so on.
  • IEnumerable<T>, List<T> and IList<T> will be imported as T[].
  • IEnumerable<T> with Autodesk.DesignScript.Runtime.ArbitraryDimensionArrayImportAttribute attribute specified on the parameter will be imported as T[]..[].
  • IList will imported as var[]..[].

Definitely, you can directly define a function with corresponding parameter types in code block node as well.

Now let's look at a case where Replication isn't quite helpful. Let's say we want to get the first item from each sub-list from input {{"foo", 1, 2}, {"bar", 3, 4}}, node List.FirstItem(list:var[]..[]) looks promising. If we connect input to this node, what do we get?

The node returns {"foo", 1, 2} which is the first item of list. It is not what we want! One way to get the desired result is to use some functional node like List.Map, List.Reduce, etc., to enforce the iteration:

These functional nodes come from functional programming land, not all users are familiar with them. Plus, we now need an extra node to complete the workflow.

In summary, Replication doesn't have answers for these questions:

  • What if the lengths of argument are the not same? For example, {1, 2, 3, 4} + {5, 6}? Here we need different Zip Replication strategy.
  • How to decide Cartesian Replication order? For example, for {1, 2} + {"foo", "bar"} there are two possible options:
    • {{"1foo", "1bar"}, {"2foo", "2bar"}}, or
    • {{"1foo", "2foo"}, {"1bar", "2bar"}}

These questions will be answered by Replication Guide.

Releases

Roadmap

How To

Dynamo Internals

Contributing

Python3 Upgrade Work

Libraries

FAQs

API and Dynamo Nodes

Clone this wiki locally