Codeblock node for encoding

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.

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

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

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.

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

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

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.

And what is the error with Element.ToString? The format and format provider maybe?

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

This page could help:

2 Likes

You can convert anything to a string by adding an empty string to it.
image

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?

6 Likes

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

@toaxan This is how I handle functionality that has no Design Script equivalent …
20170921-6

1 Like

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

Not yet, unfortunately

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.

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.

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.