FAQ: Code Block nodes and DesignScript in Dynamo 0.7


#1

What is DesignScript?

DesignScript is a programming language for exploratory design and analysis. It's intended for people who have never programmed before, through to domain experts. It's more flexible than any other languages you'll have seen. It is most directly experienced in Dynamo through Code Block Nodes, which are found in the Core>Input portion of the node library, or by simply double clicking in the Dynamo Canvas.

What can I use Code Block nodes for?

At the most simplistic, Code Block nodes can be used for number and string inputs, creation of ranges, or lists.

2014-04-03_2211

A bit more advanced, you can use Code Block Nodes to directly author relationships that might take a number of nodes to create.

2014-04-03_2218

 

Code Block Nodes will allow for any number of simple or complex sets of relationships to be created that have a seamless interaction with the rest of the graph.

2014-04-03_2233 2014-04-03_2229

These examples don’t really express the power of this way of working, but please watch the blog for more workflows and exploration of this interface.

How do I learn more about what you can do with Code Block nodes?

Play with it!

Another good place to start is the DesignScript Language manual, where you can find most answers to what is possible with DesignScript.


#2

If I’m looking to extend Dynamo’s functionality and want to learn to program ONLY to do so, I should look at exploring Design Script and not bother about learning Python?

Regards,

Vikram Subbaiah


#3

Hi Vikram,

It all depends on the way in which you want to extend Dynamo. Could you give me an example?

You can expect to see a lot about this in follow up posts, but in brief:

Our goal is that DesignScript is going to provide the best, most integrated, most designer friendly experience for scripting complex models in Dynamo. The 0.7.0 pre-release is the first step in that direction. But, it’s definitely a work in progress; you’ll be learning a moving target but one with the best long term integration and the best suited for the hand of a designer.

Python is more conventional, the language implementation is more solid and there is more documentation and a huge community available. We’re going to make Python support great, but there are going to be things that we can’t do with it because it was designed originally for a different purpose.

==

A concrete example of how the difference is going to feel is around lacing – what to do when you have functionality that knows how to do something to one item, but is given several.

  • DS attempts to do ‘the right thing’ it applies a default lacing and walks over each item without hassling you and gives you a list back.

  • Python reports an error instead and stops.

Both are correct in their context, they’re just different. The reasoning here is that changing your mind as to whether you have one thing or many is a very common occurrence for designers, and a relatively rare thing for conventional programmers. In a lot of conventional programming, having three things instead of one would represent a mistake so it’s best for a general language like Python to warn of the mistake and stop before any more damage is done.

But that’s just annoying for a designer, who would frequently work out how to do something to say a wall, and then expect it to do the same thing to each it it was passed multiple walls.

So - it rather depends on the way you’re trying to extend it Dynamo. If you’re making your graphs a little more powerful, I’d try out DesignScript but with a hard hat on. If you’re wanting to use a pre-canned algorithm that someone else written, I’d take a look at Python as there’s probably a version someone else has already built in it.

But which ever language, feel free to check back in here about what you’re thinking of doing, and any questions you have along the way.

Hope this helps,

Luke

 


#4

Thanks Luke.

I really don’t have anything specific in mind. On the dynamo forums, I saw a number of issues being resolved by using custom python nodes. I just wanted to know, if the same could be achieved using custom DS nodes.

I’ll probably seek direction again when I have a better understanding of how ‘programmed’ custom nodes work.

Anyway, I’m halfway through the Design Script manual. Now that I’ve been exploring Dynamo for a while, the DS manual makes some sense to the non programmer in me.

Thanks.

Regards,

Vikram Subbaiah


#5

I have a few questions.

First GREAT that design script is part of dynamo … well v 7.0xxxxx alpha

I am trying to learn design script and never used it before…

 

  1. what does the classic “import” statements mean in a code block in dynamo? Such as “”"“import(“ProtoGeometry.dll”);”"""""

are all .dll preloaded so you dont need to say it? what if there were some .dll that were not loaded how do you load them?

since the code block does not allow import statements

 

  1. looping

I read the design script user manual and the looping example does not work if you simply copy paste the example in the code block and wire it to a watch node

Code is below.

you get errors. Were you able to get this to work?

 

"geometry = [Imperative]

{
x = 1;
start = Point.ByCoordinates(0, 0, 0);
end = Point.ByCoordinates(x, x, x);
line = Line.ByStartPointEndPoint(start, end);
while (line.Length < 10)
{
x = x + 1;
end = Point.ByCoordinates(x, x, x);
line = Line.ByStartPointEndPoint(start, end);
}
return = line;
}

"

 

were ALL EXAMPLES from the design script manual tested in the code block of dynamo?

 

  1. could you explain how design script studio (that uses boxes and wires similar to dynamo) fit in with dynamo? will it ever be a part of dynamo? would it be to confusing to have two visual programming styles in one program?

  2. where could I find EVERY available command for design script language. the design script manual does not have them all in there?.

  3. will design script in the code block window ever have intelligent typing? meaning I could type “line = Line.” and when I place the dot if gives me the following options a.

  1. a. ByCoordinates</span>
  2. b. BySphericalCoordinates
  3. c. Point.ByCartesianCoordinates
  4. d. Point.ByCylindricalCoordinates
.............................

like visual studio? Would make life so much easier…

thanks

 


#6

Hey Marcello,

Great questions, taking them one at a time, my text in bold

I have a few questions.

First GREAT that design script is part of dynamo … well v 7.0xxxxx alpha

:slight_smile: :slight_smile:

I am trying to learn design script and never used it before……

  1. what does the classic “import” statements mean in a code block in dynamo? Such as “”"”import(“ProtoGeometry.dll”);”"”"”"

are all .dll preloaded so you dont need to say it? what if there were some .dll that were not loaded how do you load them?

since the code block does not allow import statements

Import statements don’t really exist in the Dynamo implementation of DesignScript. They will appear via a menu item, see here: https://www.youtube.com/watch?v=9Iwq32JCu2g for an example of how it’s going to look.

This features wasn’t included in 070 Alpha whilst we harden it. We’ll be turning it on again soon when we’ve got some bugs worked out.

If you’re feeling really optimistic, you can turn it on by re-enabling these lines in DynamoView.xaml, and rebuilding.

<MenuItem Header="_Libraries" Name="LibraryManagerMenu" Focusable="False" IsEnabled="True">

<MenuItem Focusable=“False” Header="_Import Library…" Command="{Binding Path=DataContext.ImportLibraryCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}" Name=“importLibrary”/>

</MenuItem>

Alternatively, hang tight for a couple of our quick increment releases.

It’s worth noting, we’re committed to this feature. We use it for loading all of the features you see in the libraries view. So it will be coming back.

  1. looping

I read the design script user manual and the looping example does not work if you simply copy paste the example in the code block and wire it to a watch node

Code is below.

you get errors. Were you able to get this to work?

Imperative code in Code Block Nodes is not really supported in 070 Alpha. Sorry.

Again, we had a lot to get working, and we decided to turn the features on progressively rather than delaying the release. Imperative and looping will be coming online in a subsequent increment release, like the import above.

were ALL EXAMPLES from the design script manual tested in the code block of dynamo?

No. Quite a few of them weren’t. Sorry about that. We’ll be folding the manual into the Dynamo manual and updating it.

  1. could you explain how design script studio (that uses boxes and wires similar to dynamo) fit in with dynamo? will it ever be a part of dynamo? would it be to confusing to have two visual programming styles in one program?

The best bits of DesignScript Studio are being taken and folded into the Dynamo interface. If you look back at Dynamo from before we started the merge (about 6 months ago) and look at it now, you’ll see a bunch of similarities to DSS. And there’ll be more to come.

  1. where could I find EVERY available command for design script language. the design script manual does not have them all in there?.

Hmmm. We have a language specification, but it’s not really great for humans (as opposed to programming language implementors).

As the DS engine now underlies Dynamo, everything that you see in the library is really a ‘command’ in the language. In terms of keywords, expressions, statements etc. the manual pretty much contains them. But you’re right, we should produce a cheat-sheet summary. Tracking this task internally as MAGN-3100.

  1. will design script in the code block window ever have intelligent typing? meaning I could type “line = Line.” and when I place the dot if gives me the following options a.

YES! Back in the day, the DesignScript Editor used to be able to do this. For various reasons involved in the design of the language we can do even better than Visual Studio on this - supporting this ‘intelligent typing’ very well was one of my key design concerns in the design of the DesignScript execution engine. I know it’s really really important.

Hope this helps, love the questions, please keep them coming and bear with us through the incremental releasees turning the features you’re asking for back on.


#7

Great answers to questions.

I’ve got one, well actually a few.

Are you guys going to update DesignScript Studio on it’s own at some point?

And what about the integration of Robot Structural, Ecotect, SMARTform and Genetic Algorithm?

Thanks

 

T!M


#8

Hey Tim,

Great to see you over here, I really appreciated your work over on DesignScript.org. I’m looking at ways of migrating it over and I’ll reply to your email soon. But in the meantime:

Are you guys going to update DesignScript Studio on it’s own at some point?

There aren’t currently any plans to do so. The plan is to make Dynamo everything that DSS was and more. Is there something that you’re feeling that you’d like to see that you had in DSS but don’t have in Dynamo?

And what about the integration of Robot Structural, Ecotect, SMARTform and Genetic Algorithm?

There’s a lot of interest in integrations like this with Dynamo. A lot. Specific details will need to follow on when we’re out of Alpha, but suffice to say there’s active work going on in supporting other plugins for things like structural and environmental analysis. The architecture that we’ve put into Dynamo as part of 070 makes this a whole lot more tractable.

Cheers,

Luke


#9

Hey Luke:

Thanks for your answers. For your question,

" Is there something that you’re feeling that you’d like to see that you had in DSS but don’t have in Dynamo?"

Actually not familiar enough with Dynamo yet, so I’ll have to get to it soon, maybe after some (end of May) Vasari news.

Given that, DesignScript Editor is quite complete and stable, but the Studio portion ( for architects-designers, non programmer’s) isn’t.

But anyone can see is that it is designed as quite an elegant program. Love to see you guys (generic) complete your work.

(even if for autocad users, lol)

best regards,

T!M