Calling list nodes in a codeblock


#1

Is it possible to call the “List.xxx” nodes in a codeblock? If I try for instance List.Create or List.Map I get “Cannot find static method or constructor”.

Maybe there’s different syntax when calling these?


#2

Hi,
Probably you know it, but in the help of every method you have the syntax for using in code
01
List.Create and List.Map are a bit special and there is not code syntax in the help. For making a list (node List.Create) in code you can put directly the list content between {}
02
List.Map is a different history. Maybe it is possible to be called in a CBN, but I don’t know how. You can see here a somehow similar case (with some explanation that mention List.Map)


#3

I haven’t understood it well enough to provide a proper explanation, but it seems like the functionality of List.Map can be achieved (at least, to some extent) using Replication Guides (Replication guides are actually for lacing options, I think)

Regards,

Vikram Subbaiah


#4

Hello Vikram Subbaiah,

Your observation is correct for Replication Guides, it is similar to Lacing.

To simulate the same behavior as List.Map in CBN, you may write one definition and use it, which is similar to List.Map.

Thanks,

Ritesh

ListMapInCBN


#5

Or you can use below code in CBN. I know this is not intuitive but this is how it works right now.

__Map(fun, list);

Thanks,

Ritesh


#6

I hope that Ritesh Chandawar doesn’t mind some side notes of his answers:
-Probably you are going to use List.Map if you prefer not to use code.
-Defining DesignScript functions is really one of the killer apps of Dynamo 0.7. Sadly there is very little reference doc. yet (if any) about how to make DS Functions
-----You can define complex functionality calling all the default tools of the library or any other DS function that is defined already
-----When you specify the vars, you can set if the function expect an individual object (var), a list (var[]), a list of lists (var[][]), a lists of lists of lists (var[][][]) and so on… This make really easy to deal with complex lists of objects. There is no need at all of tedious list management when you use DS functions.
-----You can call any defined DS function in CBN as any other tool of the library. And you can use replication guides to control how the vars are combined, when you feed the arguments with lists of higher rank than the function expect.

You have a brief introduction here
http://dynamobim.org/cbns-for-dummies/
Some basic examples related to surface divisions and quads are explained in detail here:
http://dynamobim.org/forums/topic/how-to-subdivide-a-surface-to-polysurface-in-0-7-0/


#7

What I meant by using Replication guides to map is illustrated below.

However, I haven’t got it to work beyond accessing one level deep.

20140815-1

 

Regards,

Vikram Subbaiah


#8

Some more samples of replication guides …
01
I made this for answering here:
http://dynamobim.org/forums/topic/replicator-guides/


#9

A slightly better illustration of the way I have used Replication guides to manage/access specific parts of some lists (without creating functions) and an example of it's limitations

20140815-2

Regards,

Vikram Subbaiah


#10

Wow, this thread has surpassed my level by far. But great examples non the less.


#11

Hello Vikram Subbaiah,

If you are interested in Counting the items in List then you should use indexing mechanism rather than using <> brackets which is mainly for defining replication guides.

Replication Guides will not work on single argument, there should be at-least two arguments to apply Replication.

I have attached new image which shows example for List.Count on multi-dimension array.

@Eduardo P. Roca: Sorry for the inconvenience while using Functions in CBN, we have plan to come up with better use of code in CBN.

Thanks,

Ritesh
List.Count