Design Script syntax problem

I’ve started trying out the design script document, and I could see that most of the examples with syntax is oudated as per lastest Dynamo. Could anyone help me find out resources or links to learn design script for latest version of dynamo?

@Arun_Prakash

DesignScriptDocumentation.pdf (705.5 KB)
DesignScriptGuide.pdf (3.7 MB)

Dynamo-2.0-Language-Changes-Explained

DESIGNSCRIPT LANGUAGE CHANGES: The following items have been changed to make Designscript more legible, more predictable, and easier to maintain (For a detailed explanation of the language changes refer to this wiki post):

  • Unify List@Level syntax to more closely match the UI found in nodes, preview bubbles, and watch nodes. For example, @-2 will now be @L2.
  • To reduce ambiguity about what function is being called, you will need to be more precise about the data you pass into a node. Before functions that share the same method like Geometry.Translate and FamilyInstance.Translate would look at the first item of the list being passed into the function and try to look for the correct method call. It then would replicate over that method for the rest of the items in the list. This would lead to problems in lists with heterogeneous data. For instance, prior to this change, FamilyInstance.Translate would take in any geometry and translate. Now, you must be precise about what type of data you use as your input for these type of nodes.
  • Nodes that have the same name as another method but only differed in parameter rank have been cleaned up. For instance, if there were two nodes that were both named “foo”, but one of them took in a list and the other took in a single item, the node that only took in a single item would be deprecated. This is to reduce the redundancy in the node library and make it easier to support in the future.
  • “=” is no longer required in for return statements in function definitions or imperative code. This should make it easier for you to write DesignsScript in code blocks without needing to remember if this syntax is required. For example, you can write simply return x; rather than return = x;
  • Variables are immutable in code blocks. If you use a variable like “x” in a code block, you cannot redefine “x” again in the same code block.
  • Variables defined in imperative blocks will be local to imperative block scope. Cross-talk between variables defined inside and outside of Imperative blocks will no longer be allowed, because this previously led to unpredictable behavior and instability.
  • Single items are no longer promoted to lists automatically. This is to prevent the creation of unnecessary, extraneous list structures. For instance, if you have a list of numbers and a single number in a cross lacing situation, you will now have a flat list rather than a nested list.

2 Likes

@m.rijsmus

Thankyou so much, now i have something to start with :slight_smile:

1 Like

another one

http://designscript.io/

1 Like

Biggest change is the switch from Curley braces to Square brackets when it comes to Lists. Most existing code should work with this in mind :slight_smile:

1.X = {“Old”, “Style”, “List”};
2.X = [“New”, “Style”, “List”];

4 Likes

Thank you @solamour :slight_smile:

1 Like