Code Block Syntax Question

Why can’t a noob like me use a simple Python syntax like this one?

Hi @Andrej ,

Change the code block to List.Sort(list); you have to give a variable between the brackets

1 Like

Code blocks don’t take Python. They take DesignScript, which is the language which drive Dynamo.

Read more here: Code Blocks and DesignScript | The Dynamo Primer

1 Like

“The code-block has access to all of the Dynamo nodes and can define an entire graph in one node.”
Does this mean DesignScript can only use a syntax that describes some node? I’m sure I saw some folk use Python.

It worked. Ty

Correct. Design script calls nodes via the design script syntax.

Nope. Class names and dot notation do look similar though. Notice that every line in a code block ends with a ; which is not used as a end of expression marker in in Python.

1 Like

What about this?

What about the people who say they’ve built custom nodes in Python?

I’m confused…

These utilize a Python node, not a code block.

https://primer.dynamobim.org/10_Custom-Nodes/10-4_Python.html

aaaah, thank you. Now I get it.

So, I can use “Python Script” node, and edit it to open up this window where I can write Python. Did I get it right?

Yep!

Best to run though the entirety of the primer which I previously linked to, end to end, skipping nothing even if the outcome seems irrelevant as the methods are the important bit not the outcome. It covers all of the basics such as this, and can be done quite quickly.

1 Like