Control lacing for Function Apply node

Hey everyone,

I’m using a Function Apply node after an If node. Currently the result shows that the node is functioning similar to cross-product lacing.

I’m trying to get the list structure of the output to be the same as the inputs. So, in my case, the result should show [ ‘42" x 132"’, ElementType 495877, ElementType 495879]. I can’t find a way to control the lacing of Function Apply node, I’ve tried using List.Combine and List.LaceShortest nodes as well, but none of these seem to work with Function Apply node as the output shows null objects. Is there a way to get the desired result through Function Apply node or even any other method in Dynamo?

I’m Using Dynamo 2.10 with Revit 2022.

Thanks in advance,


I maybe confused… It’s a bit difficult to work out how to get your result without a simple sample file… If you’ll forgive me I’ll try to understand…

You are feeding in 3 functions & 3 unique items and you are getting 9 results? So you are getting what you want, I think that if you add a transpose, you will get the list structure you are after…

Here is my simple example:

But you are getting nulls, so something isn’t working… if your output from If is ‘identity, duplicate, duplicate’ then presumably you can’t duplicate twice? Perhaps you need to be able to define a different name (I think Springs has a node for that).

Hope that helps,


Hi @Mark.Ackerley , thanks for responding.

Actually, in my case, I want just three items in a flat list instead of 9 items in a two-tier list. So basically, each function in list should be applied to just the corresponding argument.
And I suppose transposing the result would still get me 9 items.

And regarding those null values, those are not an issue as I want that behaviour to further control the flow of graph using another If node after that.

Also, I apologize I didn’t upload a sample file. Here’s a basic sample file and it’s screenshot -

The arrows are to show how I want it to be executed.

FunctionApplyLacing_Sample.dyn (11.4 KB)

Oh ok, it’s good to get the clarity :slight_smile:

So if duplicates aren’t a problem? Feed the input to the object.identity & duplicate… then use the output of the If node? & omit the function.apply?

Apologies I’m out of time for today…



1 Like

Initially I was doing that only, feeding the “Unique Items” to the ElementType.Duplicate input directly. But then I had introduced a conditional statement node to omit the warning errors because some of the unique items could already be present in the Revit document and don’t need to be duplicated.

But in my case, I want some output if the element is already present, therefore, I used Object.Identity function. Because null values are being used to evaluate whether the Function Apply node is getting executed at all or not. So when I get nothing but a null value then that would just mean that the Function Apply node didn’t get any input at all, which, as I had said earlier, helps me control the flow of graph

PS. Let me clarify though that the overall Dynamo graph works just fine because that logic of getting atleast some value to evaluate the execution of the Function Apply node still holds even if I get a nested list. That’s why this thread is just about controlling the lacing of Function Apply node. I’m uploading the original Dynamo file as well, in case anyone is interested. :slight_smile:

Curtain Walls to Windows.dyn (105.7 KB)

That being said, do let me know if there’s a way to get the desired behaviour.


See if doing it with Design Script suits you …

FunctionApplyLacing_Sample.dyn (8.0 KB)

def mltFun (a:var[])
	return [DSCore.Object.Type(List.GetItemAtIndex(a,0)),

Hi @Vikram_Subbaiah, thanks for responding.

Yes, that’s exactly how I want the list structure to be. But is there a way to achieve this when number of indices or the function to be applied is not pre-determined?

Because in the original graph, the indices and the corresponding applied functions are determined by a condition.
I could try looping but can we call built-in functions dynamically in Design Script, i.e. if we can have variables for built-in functions or ootb nodes?

Might be possible, but can’t say for sure until you provide a sample file/sketch as you did earlier

I’m thinking looping might help in this case. But I suppose DesignScript alone does not support “for” loop. I was trying Python scripting for the first time in Dynamo, but can’t get the code to work. I’ve just started learning Python a couple weeks back. Following is a crude version of what I want to achieve through the code (I’m familiar with Python keywords but only ever coded in C++ or DesignScript, so the code below is a mix of both).

> n = List.Count(List1);
> for (i in 0..n)
> 	{ if (List2[i] == false)
> 		{x = append(ElementType.Duplicate(fType, List1[i]));
> 		}
> 	else
> 		{x = append(List1[i]);
> 		}
> 	}
> return x;

Here I’m taking three inputs, two are of list type (List1 and List2) and the third is a FamilyType (fType). List1 has a set of unique items to Duplicate and List2 has the same number of boolean values.
Could you tell me how to convert this to Python script?

May not be necessary. (Refer to the Associative code block below)

It does. In Imperative mode (Example provided below)

ImpAndAsc.dyn (9.4 KB)

1 Like

:open_mouth: Thanks for introducing me to Imperative language block! I read about it just after reading your reply.

And kudos! This is exactly the solution I wanted.
Both the code blocks work perfectly. Although associative code block shows a warning, the output shows the desired result without any null value, so must be just a bug.

1 Like

I just realised that the associative code works just like what Mark had said, that’s why it’s giving a warning error because both the functions are getting executed for each unique item, but only the function output that satisfies the conditional statement is getting returned.

This also is a part solution so marking this as a Solution as well. :slight_smile:


1 Like