Revit Architecture Forum
Welcome to Autodesk’s Revit Architecture Forums. Share your knowledge, ask questions, and explore popular Revit Architecture topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set parameter by name doesn't work on instance parameters

5 REPLIES 5
Reply
Message 1 of 6
cozzalimatilde
276 Views, 5 Replies

Set parameter by name doesn't work on instance parameters

Hi everyone, I’ trying to compile parameters from an excel file.
I’ve obtained two lists from the sheet, one with the parameters names, and one with the parameters values.
When i try to use Element.SetParameterByName I see that It works only for the type parameters, and gives me error for the instance ones, that actually are the ones I want to modify trough excel.
Is there any solution? Do I have to use a different type of node?
Be nice, I’m not an expert!

cozzalimatilde_0-1693820080095.jpeg

the warning says that It can’t found any parameter with the given name, but I see that It can do that for the type parameters, and not for the instance

5 REPLIES 5
Message 2 of 6

Hi,

 

Can you try this out and see if it works?

- Add a custom Python script node

- Edit node and place this code:

import clr

# Add references for Revit API
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')

# Add references for Dynamo
clr.AddReference('RevitNodes')
clr.AddReference('RevitServices')

import Revit
import RevitServices
from Revit.Elements import *
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# The input to this node should be the Floor Type you've fetched from another node.
input_floor_type = UnwrapElement(IN[0])

# Empty list to collect instances
floor_instances = []

# Get all the floor instances in the project
floors = FilteredElementCollector(doc).OfClass(Floor).WhereElementIsNotElementType().ToElements()

# Iterate through all the floors and check their types
for floor in floors:
    if floor.FloorType.Id == input_floor_type.Id:
        floor_instances.append(floor)

OUT = floor_instances

 

Connect the node as in the print screen (between Floor Types and Element.setparameterbyname):

 

ralphdenhaan_0-1693821251125.png

 

Select Accept as Solution and Likes are always welcome. 


Ralph den Haan, (Lazy) BIM Specialist


LinkedIn | LazyBIM Blog


 

Message 3 of 6
L.Maas
in reply to: cozzalimatilde

You have to think where the information is available in the model. In your case you want to change the value of familyinstances (items placed in the model) but you are approaching the family type (the one in the family browser). So you do not want the floortype but the floor elements placed in the project.

 

Something like this:

LMaas_0-1693832610327.png

 

If you have a mix of instance and type parameters you have to separate them and then send them to the instance elements or to the type elements.

 

Or you can use special nodes which have that functionality build in. (this one from the Rhythm package)

LMaas_1-1693832820818.png

 

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Message 4 of 6

@L.Maas I've tried to use the Rhythm node (i was looking for something like that but i didn't find it), but it gives me error maybe due to the element i linked, is it right if i link the "floor type" node or i have to link another element? 

@ralphdenhaan I'll try the python script asap and i'll let you know, this is a master degree thesis so i'll try all the possible solutions to obtain an accurate study

Message 5 of 6

We both (me and @L.Maas) give the same solution as you need to gather all instances of that type. But the python script will gather all instances from the type you already have set (so it's a kind of shortcut).

Select Accept as Solution and Likes are always welcome. 


Ralph den Haan, (Lazy) BIM Specialist


LinkedIn | LazyBIM Blog


 

Message 6 of 6
L.Maas
in reply to: cozzalimatilde

As mentioned, you have to look where the information is stored.

 

Here a concept. Basically you collect the floor elements (placed instances) and then push the parameter values.

You can know that you have to find the placed instances (ELEMENTS) because the node tells you already.

LMaas_2-1693851980994.png

 

What the node is basically doing is that he stores the values for the instance parameter and then looks up the associated family type and then stores the type parameter value.

This also would mean that if you have multiple instances of the same familytype in the project  and you present every time different values for the type parameter only the last will stick (the previous values will be overwritten).

 

For example isntances 1 and 2 are both "Generic 150 mm" first it gets written Type Mark 2 then it gets Type Mark 3.

End result is that both those items will have type parameter Type Mark 3 (because it is the same familytype).

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Technology Administrators