Lacing in CodeBlocks... (SetParameterByName)

Hi all . I have questions…

I want to know about lacing in Codeblocks using “<>”. In fact I already read documentation (Dynamo Primer), But I cannot understand all about it… because there were lack of data about lacing using “Codeblocks”.

First I just wonder what is it mean “Elem<1>”, “name<2> and val<2>” in group of “A”.
Second. how “B(Element,SetParameterByName)” can work exactly like A. I have no idea…
please let me know…

You can use the “node to code” function to better understand what is going on.

(Select the nodes in question and rightclick outside the nodes and select “node to code”.

Thanks Jonathan It’s really helpful. But actually… I still don’t know…

I want to remove “-1” and just get only <1>… Is it possible to make B to A

22

Lacing (shortest, longest or cross product) can be expressed in Codeblock like so:
image

1 Like

I think part of the problem is that the current list levels you’re using probably aren’t doing what you want them to.
Do you want to set all 6 parameters to blank for all 6 elements? Or one parameter per element?

If you want to set all parameters for all elements you would do it like this:

If you’re only setting one parameter per element then no list levels are needed.

There are two things at work here, Lacing and List@Level. In DesignScript, lacing is controlled using Replication Guides.

The syntax for Replication Guides is as follows: variable< number >

The number itself only matters in relation to the other numbers within the Replication Guides (To my knowledge).

So x<1>, y<2>, z<3> is the same as x<21>, y<35>, z<771> - What matters in this case is that both X-values are the lowest Replication Number, both Y-Values are the middle and both Z-Values are the highest.

Within Replication, you are telling DesignScript how to pair data. This is done hierarchically. In your example, you are taking your primary list of Elements, and pushing them against a parameter name and a parameter value where all of these lists have a variance in number.

As other examples in this thread point out, you can achieve this using List@Level, but it is also achievable via Replication.

In order to take a variable list of Elements as input (In my example below Areas), and take a variable list of Parameters to then subsequently wipe out any housed data with a single input list, you can approach replication as follows:

My list of Areas are defined by the Elem input port. Because I want to replicate over every element in here, this list needs to have the highest priority. We thus put in a replication of the lowest number: In this case it’s <1>.

We then want to take a variable amount of Parameters to set data to, which we will stipulate as our third strongest replication over the name input port: In this case it’s <3>. The reason for this is that we want to pair every single one of these (In essence, a longest lacing or cross-product option) to the val input port which contains a singular item (Empty string) set to a replication level of <2>.

The result of this is that every single element (Area), will push an empty string (Val) to every single parameter chosen (name).

If you switch up the Replication, the results change as can be seen below:

Here when we stipulate a paired replication, it will simply mimic the shortest lacing option.

The concept itself is a little escoteric, but supremely powerful. You can, in essence, pair any number of data points with any other number. It both mimics Shortest, Longest and Cross-Product lacing options but also extends that functionality beyond.

12 Likes

Sometimes I wish I could sticky a reply… Well said @solamour!

1 Like

I really thank you!!!

2 Likes