Force dynamo to rerun the node multiple times

Hi everyone. Let’s say I have the script to create the circle which has 10*t diameter (t is the sequence from 1 to 100). Is there any loop condition node to make dynamo create totally 100 circles with different diameter value (because there are 100 values of parameter t).
Thank you.

Hi,
It’s difficult to answer precisely without seeing the context.

Thank you @Alban_de_Chasteigner but this is not what I am looking for. Creating circle with different diameter is just an example. I want to make a condition loop to run many nodes over and over again. For example, creating circle with different diameter and then extrude, rotate with a different angle (5*t degree)

I think Alban is right. We can manage most of the cases by simply feeding the sequence of nodes you want to iterate a list of items to work with (that’s what Alban did).

In case you want to iterate on a sigle value and feeding back the node sequence the result of the previous operation, you cant try something like this. (Note that for the case you described in your initial post, it is overkill)

1 Like

Hi @mellouze. Actually I don’t see the difference between your code and while loop node. Because the funct input just only allows one node to wire in. I want many nodes to rerun in the loop not only one.

You can add as many functions and initial values in input as you want, you just have to specify it when defining the loopNTimes function.

def loopNTimes(var1:var[]..[],var2:var[]..[],n:int,func1:Function,func2:Function,func3:Function){

	c = [Imperative]{
		i = 0;
		v1 = var1;
		v2 = var2;
		v3 = var2;
		while(i<n){
			v1 = __Apply(func1,v1);
			v2 = __Apply(func2,v2);
			v3 = __Apply(__Apply(func3,v3),v2);
			i = i+1;
		}
		return [v1,v2,v3];
	}
	return = c;
};

Hello @mellouze ,

With some googling I ended up here and tried your sollution. I’m trying to let my script run for every excel row entry and save the file with those settings. AKA:

Excel row 1 -> script -> save as -> Excel row 2 -> script -> … -> no data rows left

The number of data-rows is variable. I the case of 2 data rows (image) I end up with 2 files both based on the last data row.

Do you know a solution for my problem?

Hope you can help!! Regards, Rien.

Hi :slight_smile:

I have some difficulty understading what’s your problem/goal.
Could you please provide some more information, i.e. :

  • What is your input data ?
  • What is your desired output ?
  • What is the problem that you are encountering ?

Hello @mellouze ,

Thanks for the quick reply!

Input: Excel data file with 3 coloms
image

Script:
Changes global parameters, then saves files.

Desired output:
New Revit files based on the input. In this case 2 files with both different configurations:

  1. 4800_9600_38.rvt (configuration global parameters: 4800, 9600, 38)
  2. 5100_9900_39.rvt (configuration global parameters: 5100, 9900, 39)

Problem:
Both files are based on the last row from excel. The script doest not run by excel row. It first runs all the options in excel and stops at the last row (in this case 4800, 9600, 38). Then saves-as the document with this configuration multiple times (in this case 2).

Output now (wrong output):

  1. 4800_9600_38.rvt (configuration global parameters: 5100, 9900, 39)
  2. 5100_9900_39.rvt (configuration global parameters: 5100, 9900, 39)

Hope this gives enough details :smiley:

It is hard understanding what your script does without all the previews turned on :confused: But i’ll try my best !

Have you tried creating a custom node ? You could create one such as this one :

  • Input data : Name of the parameters you want to change + Value of those parameters
  • What the node does : Change the parameters then save the file

It should not be very hard to accomplish that step (you script already does it :wink: ).

Then, try feeding your custom node all the different names/values of the parameters and see if it solves your problem.

If not, you could try using my approach (the one with only one function), with the function being the custom node you created.

Hope this helps !