#DesignScript LM – Chapter 21 Translation -Collection Rank and Jagged Collections

Hi Everyone:

This translation is from the twenty-first chapter of the DesignScript Language Manual and can be found at DSLM  (pages 62-63) and is entitled; Collection Rank and Jagged Collections. There is a previous video tutorial on collections which may help with this chapter and can be found on the DS website’s tutorials.

The initial manual translation was made on the Autodesk DesignScript Community Forum and DesignScript.org. Now it can be found at can be found at Collection Rank and Jagged Collections. (Note that it can be not longer be found on the Autodesk Labs Website, as linked)

Continuing on, open the DS Editor and create a new file, lets copy and paste the code from Chapter 21 (pages 62 &63) into the editor. Run the code in Debug mode and step-in and step-out.

Chapter 21 Collection Rank & Jagged Collections-.ds#1

Chapter 21 Collection Rank & Jagged Collections-.ds#1

The above illustration is of the DS Editor and shows the results of the code being run, pasted in for reference, with the corresponding scripts being noted as 1,2 &3.

We can see that as intended, that the second script draws an error as adding a collection to an integer fails, appropriately so…although take care to add the highlighted parenthesis as shown below, otherwise the script will not execute properly.

Chapter 21 Collection Rank & Jagged Collections-.ds#1-insert

Chapter 21 Collection Rank & Jagged Collections-.ds#1-insert

Moving on, paste the same script into a blank canvas on DesignScript Studio.

Chapter 21 Collection Rank & Jagged Collections#a1

Chapter 21 Collection Rank & Jagged Collections#a1

Edited out the commenting out so the script will be activated.

Chapter 21 Collection Rank & Jagged Collections#a1-edited

Chapter 21 Collection Rank & Jagged Collections#a1-edited

Again we see that “defining language blocks are not supported” for the imperative portion of the script. (marked #2 in the DS Editor illustration above and on the top of page 62.) A work-around method is used in the DS  Studio canvas to get a return on the code.

Developing and breaking out the script into code blocks is shown in the DS Studio canvas in it’s initial translation.

Chapter 21 Collection Rank & Jagged Collections#1

Chapter 21 Collection Rank & Jagged Collections#1

Continuing on with the more detailed and defined translation with the naming of the variables to identify and reference into them to their corresponding nodes.

Chapter 21 Collection Rank & Jagged Collections#1a

Chapter 21 Collection Rank & Jagged Collections#1a

Since we are dealing with collections it might be noted here that there isn’t a graphic Window counterpart with geometry displayed, but it’s noted that the canvas does return a value.

Then with the naming and identifying complete,  the “Node to Code” operation can take place.

Chapter 21 Collection Rank & Jagged Collections#1b

Chapter 21 Collection Rank & Jagged Collections#1b

We see that editing is in order as highlighted above with the results displayed below.

Chapter 21 Collection Rank & Jagged Collections#1b-edited

Chapter 21 Collection Rank & Jagged Collections#1b-edited

Reiterating, this was done on the stand-alone version of DesignScript, rather than as a plugin for AutoCAD. The files are available for downloading from the Drop-Box links below.

2014_03_03-Chapter 21 Collection Rank & Jagged Collections#a1

2013_10_29-Chapter 21 Collection Rank & Jagged Collections#1

2014_03_03-Chapter 21 Collection Rank & Jagged Collections#1a

2014_03_03-Chapter 21 Collection Rank & Jagged Collections#1b

Thanks for looking.

T!M

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s