# Codeblock node for encoding

**URL:** <https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965>\
**Category:** DesignScript\
**Created:** [September 20, 2017, 12:51pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965 "2017-09-20T12:51:29Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 20, 2017, 12:51pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/1 "2017-09-20T12:51:29Z")

</div>

Colleagues tell me how to write code into the code block:

t1 = Categories (“Spaces”);

t2 = All Elements of Category (t1);

String from Object (t2);

Not one of the above code blocks can not be written to the code block.

 ![Bim2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/d/1d36c4b7adfe6c737b0221bf8bae8e4c86ef42e0.jpg)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 20, 2017, 12:56pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/2 "2017-09-20T12:56:28Z")

</div>

> [@toaxan](#):
>
> Not one of the above code blocks can not be written to the code block.

Not all nodes can be written to code block. You could use Python or leave as individual nodes.

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 20, 2017, 12:59pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/3 "2017-09-20T12:59:16Z")

</div>

I need to write these nodes in the code block to perform the “function”

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 20, 2017, 1:01pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/4 "2017-09-20T13:01:53Z")

</div>

There may be a way to get those nodes into code blocks but I’m unaware of it. You may have to split your function into 3 parts: first code block, node portion, second code block.

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 20, 2017, 1:03pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/5 "2017-09-20T13:03:52Z")

</div>

In this case, the meaning of such an action is lost. Because you will not be able to exclude the “threads” of node communications

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 20, 2017, 1:05pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/6 "2017-09-20T13:05:16Z")

</div>

Can you replace the node with a python code? writing it into the code block?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 20, 2017, 1:07pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/7 "2017-09-20T13:07:42Z")

</div>

You would have to write the whole function in Python. I’m pretty sure you can’t embed a Python function in a code block.

What is your overall goal here? There might be another option we could try.

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [September 20, 2017, 1:17pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/8 "2017-09-20T13:17:30Z")

</div>

And what is the error with _Element.ToString_? The format and format provider maybe?

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 20, 2017, 1:32pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/9 "2017-09-20T13:32:13Z")

</div>

![Bim23](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/f/4f4fecd2a4167a5893f90bfe70967e52f2089403.jpg)

Green is a function tester that works correctly.  
red - the code blocks that I want to designate as a function.

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [September 20, 2017, 1:46pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/10 "2017-09-20T13:46:12Z")

</div>

This page could help:

> <https://github.com/DynamoDS/DesignScript/blob/master/LanguageSpec.md>

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 20, 2017, 1:47pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/11 "2017-09-20T13:47:22Z")

</div>

You can convert anything to a string by adding an empty string to it.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/c/bcde1a5fb0091aec23d2588c59880ce4c24c29bf.png)

Why does everything need to be contained within a single function? I understand why the string conversion caused a problem but now that it’s fixed couldn’t you write your function to take a list of generic elements… and just input the space elements manually?

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 21, 2017, 11:47am UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/12 "2017-09-21T11:47:16Z")

</div>

Thank you!  
But there was a question how to get all the space to the codeblock?

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 21, 2017, 11:48am UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/13 "2017-09-21T11:48:34Z")

</div>

![Bim33](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/3/335e3bb8ac68112d3633079f1b7ecdc681f2ac3b.jpg)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [September 21, 2017, 12:06pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/14 "2017-09-21T12:06:22Z")

</div>

@toaxan This is how I handle functionality that has no Design Script equivalent …  
 ![20170921-6](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/8/182aad64a8c3bd9ee2076cb35088b2447cce69ff.png)

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 21, 2017, 1:22pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/15 "2017-09-21T13:22:11Z")

</div>

Thank you so much!  
But is it possible to include in the codeblock and “all elements of category”

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [September 21, 2017, 1:28pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/16 "2017-09-21T13:28:51Z")

</div>

> [@toaxan](#):
>
> is it possible to include in the codeblock and “all elements of category”

Not yet, unfortunately

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 23, 2017, 8:14am UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/17 "2017-09-23T08:14:52Z")

</div>

All welcome!  
There is a suggestion to make a custom node by writing the code on the python, which gets all the spaces.  
This node can be written to the codeblock.  
Thus I hope to leave the node "all element …"  
But I do not know the python can someone write the code on the python that gets all the space on the output.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 23, 2017, 2:14pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/18 "2017-09-23T14:14:59Z")

</div>

We gave this option some thought before, and abandoned it as it means a user has to edit Python code to make the node pick up areas. Or rooms. Or bubblegum. We felt that leaving the dropdown and selection outside of the single node you make it easier to review, repurpose, and troubleshoot.

Keep in mind that there is no good way to test the intermediate function results of of a Python node - only the input and output are seen.

You could use a custom node with the categories and all elements of category nodes as well if you jus want to simply node placement.

---

<div class="post-metadata">

**Author:** ![toaxan](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@toaxan](https://forum.dynamobim.com/u/toaxan)\
**Post date:** [September 23, 2017, 2:36pm UTC](https://forum.dynamobim.com/t/codeblock-node-for-encoding/14965/19 "2017-09-23T14:36:02Z")

</div>

Thanks for the answer.  
It’s not entirely clear why the “All elements of category” node can be written to the codeblock. ?  
Why this limit. ?  
This node does not allow you to use the “design script” in full.
