Input multiple values into one family parameter

Hello,

I’m quite new to Dynamo and I’m sure that what I’m doing is totally worng, but anyways, I’ll ask.

I need to input a list of values into several parameters from a family. This family returns me another parameter (called “Code”) depending on the previous parameters’ values. I need to do this to get al the “Codes” that family can give me. I’ve tried doing this using the nodes as shown in the screenshot, but the setparameter node only returns the highest value of list in all the parameters.

Anyone can help me?

Shouldn’t you be linking all the “Element.SetParameterByName” nodes to the same “FamilyInstance” Output with their element inputs?

I already tried that too, and it didn’t work.

Well you actually didn’t try that.

Try connecting every every Element.SetParameterByName element input to the FamilyInstance output. Now you’ve just put them in a serie which I don’t think make much sense.

Like this?

It still inputs only the greater value to every parameter. The strange thing is that in the get.parameter, it gives me the default parameter value, not the changed one…

Hey, as far as I can tell, your problem is that you input only one family and you try to assign more than one value to the parameters of that family. Also, I think your lacing is a bit off.
Could you upload your script?

Yes, I input only in one family element. What I want is to run multiple parameter values through that family element and output the “Code” parameter for every combination of values possible.

Here is the script. You can see that for now I make only an element fot the first family type of the category, that’s just to try the script. When it Works, I want to run the script though all the family types on that category and retrieve all the “Code” parameters.

Thanks in advance.

I am not sure I understand what you wish to obtain by doing this? Could you elaborate a little more on what your end goal is?
As I understand it, you want the element to have more than one value in a parameter at the same time, which it can’t have.

Either you have to duplicate it and assign each value to a different element or you could make a Python script.
Depends on what your end-goal is though.

OK, I’ll elaborate. I have a bunch of families, each of them has a way to output a “code” parameter depending on the dimension parameters of that family (some families have Lookup tables, others have IF formulas, others have type parameters,…). I need to run a script on each of those families that assigns all possible values to the dimension parameters, and get the “code” parameters that the families can output. So I need a way to assign all these possible parameter combinations to each of the family types, to get the “code” parameters and write them to an excel file (to get a database of all codes in my familiies).

Now I think I understand what you are after here, as well as what the issue is.

Each time you change each parameter you get a new code. There is only one element to collect all the parameters, and only one value can be stored in each parameter so you can only return one result - the last one written wins the day, and your highest value is the last one in your lists so it wins out and you get the highest number each time.

So to test all of the codes you have two choices that I can think of at the moment:

  1. You can create an instance for each possible output and assign each one the next unique value in the list of all possible values. This is doable with standard nodes.

  2. You can assign a set of values, and append those values and the resulting code to a list of all values, and then iterate over the list of inputs. This is easiest with Python.

Thanks for the reply. So I was wrong about my approach. I just started learning dynamo, and know nothing about Python (yet) so your second choice is impossible for me just yet, but it would be great if you could point me to some online resources about sets of values and appending them as you suggest.
And about your first option, should I set a familyInstance.bypoint with a list of points, or should I set a bunch of elements in my Project, then use a familyinstance.settype instead? The problem with this option is that I have to set lots of elements because the combination of parameters can go to thousands…

Ah! If you have thousands than the Python node will be the best option. It will require some scoping statements and such. For now have a look at the Dynamo primer and I’ll try and post something tonight (east coast of the us here) unless someone beats me to it.

Try this:

The python code is as follows:

import clr
# Import RevitNodes
clr.AddReference("RevitNodes")

#define inputs
fam = IN[0]
vals = IN[1]

#create empty lists for outputs
h = []
w = []
l = []
codes = []

#create scope of work for list of vals, defined at line 7. 
for v in vals: 
	#sets the height, width, and length parameters based on the contents of the vals list, defined at line 7
	fam.SetParameterByName('Height', v[0])
	fam.SetParameterByName('Width', v[1])
	fam.SetParameterByName('Length', v[2])
	#sets the code parameter value according to the vals list, which was defined at line 7.
	#if your families have a method for defining the code already built in than you don't need to run the next two lines, and can comment them out by adding a # to the front of the line. 
	codeval = str(v[0]) + "x" + str(v[1]) + "x" + str(v[2])
	fam.SetParameterByName('Code', codeval)
	#adds the Height value found at index 0 to the h list. Since this set the height it is the equivilent of getting the Height value. 
	h.append(v[0])
	#adds the Width value found at index 1 to the w list. Same idea as what we just did with the height. 
	w.append(v[1])
	#Same concept as what was done with H and W before. 
	l.append(v[2])
	#gets the code value from the family and appends it to the list of codes. This method was used instead of self defining it as was done for line 26 so that families which use formulas or other methods to define the code can work with the same python script. 
	code = fam.GetParameterValueByName('Code')
	codes.append(code)
	
#defines the outputs, which is the family name, the list of heights, the list of widths,  the list of lengths, and the list of codes with all results appended to the dataset.
OUT = [fam, h, w, l,codes]

You’ll need to make more than a few changes to make this work for you, but it should be doable thanks to the amount of notations I put in there.

Thanks for your reply! I tried your code and it works! but the problem is that I have to run values from 1 to 3000 in 3 or more parameters, and that crashes Dynamo. So I think my approach to the task was worng all along. I think that, instead of grabbing the codes running values through the dimension parameters, I’m going to try to grab them from the lookup tables, the if formulas or whatever way each family has its code implemented, as I don’t need those dimension parameters in my DB.
Thanks anyway!