Change the revit family parameter depend on the element ID?

Dear all

I need help in dynamo script , i want to change the family parameter base on its ID , for example if the ID =11125 then the family parameter called x=123

You will find that you need to fill in more information than what you are telling us but this is how you could do it:

The null is put in there on purpose because you need to have a value for when the Id is not what you are looking for. Replace the null with whatever value that is.

thank you
what if its complete list , and the value can be taken from excel file

element ID x
111213 123
121254 456
564464 789
556446 5454

Then it is probably easier to use the archi-lab node called Select.ByElementId and select the elements by the Id’s you have in the excel file and then set the parameter afterwards. It would keep the lists sorted properly.

1 Like

but how will make the if condition to fill the x parameter ?
thank you in advance

If you do it this way, you do not need an if condition.

2 Likes

i try and the value of x doesn’t change

Can you post the graph with all of the outputs showing and paste what the errors are? Just showing a picture and saying it doesn’t work doesn’t help us.

Warning: Select.ByElementId operation failed.
Unable to cast object of type ‘System.Double’ to type ‘Autodesk.Revit.DB.ElementId’.

It looks like you are feeding Select.ByElementId a double (a number with decimals) instead of integer. You have to convert them to integers for it to work.

it taken from excel , how to to transfer to integer ?

thank you in advance

Again, for the third time, please post a picture of your outputs. It helps a lot more if I can see what the output of List.FirstItem looks like instead of guessing wildly what your data may be.

Credit to @Einar_Raknes and Convert Double to Integer

Put a codeblock with x:int[]; between List.FirstItem and Select.ByElementId. See if it works.

And what does the error say?

It looks like you have some nulls in the list, so I would check your earlier nodes and find where the nulls come from. Chances are your problem isn’t from Select.ByElementId but somewhere upstream.

12_change the revit family parameter base on element ID ( connect to excel file).dyn (24.8 KB)

i check the list and there is no nulls in it

Can you post the revit file and the excel file? The dynamo graph can’t do anything on its own.

Thank you very much for your help, i found the problem and solved .
the problem was the X was integer , and it shall be text in parameter

1 Like