Hello Dynos,
so i played around … i can`t manage it finally
i will get a excel file (exported from an IFC) keys are BAT_ID, each element got set 30 Parameters,
these are all there in my Revit-Modell.
the elements are not sorted by Revit specification. They have there own standards. The only intersection is the RevitID…
PyAllElementsInView.dyn (39.2 KB)
I want just if there is revitID → get values from excel and fill it…
test.xlsx (14.6 KB)
Hi Andreas,
I would do something like this:
Just need to adjust the lacing of the Element.SetParameterByName to accomodate your input structure.
If the Crumple-node doesn’t handle the Nulls, I’d write a custom node with a Try/except statement and then use the GetElement method from the Document class (GetElement Method (ElementId)).
Good luck 
1 Like
@MartinSpence ,
i found something from AusiBIMGuru… https://www.youtube.com/watch?v=pFT5vejNzqU
GetItemAtIndex and List.IndexOf is a good way… but matching the final data to each parameter i struggle…
to synchronize element(revit), Id(excel) and matching the Parameters(Revit) and Values(Excel).
PyAllElementsInView_V01.dyn (60.5 KB)
FYI we can’t actually tell what’s wrong based on your image. You’re only showing one node output and it’s not even erroring. We need to know all of the node outputs in order to have an idea of what might be happening.
As @MartinSpence showed, it should be as simple as separating the parameters from the Id and getting the element.
You could also create a dictionary for each element, and check for nulls before assigning values to each parameter in the dictionary. There are plenty of options here.
1 Like
@Nick_Boyts ,
steps are:
1.) make it run
2.) make it right
i changed the lacing( to longest) too at the end of the transaction. I have to check result, but revit collabes for now…
in my proposel i have 55 vales/Parameter to change…
finally i will change 80.000 elements with 25 Parameters… how can i handle that, when revit has issues even now ( i test in adetached model)
That’s 2,000,000 (2 million) changes in one transaction. That’s too many.
- Memory will likely be an issue and your graph will be very slow if it runs at all.
- You’re probably beyond the limit of what Revit considers a valid change to the database. If too many changes are made at once, Revit won’t be able to reconcile the differences with the central model.
You’ll want to break it up into smaller chunks.
1 Like
@Nick_Boyts ,
so i have to group them by soemthing manageable…
f.e. even by category is it between 8000 - 12000 elements
when i sort by MEPSystem is the same…
Just do a couple hundred elements at a time. No need to group them by anything in particular.
1 Like
Working with ranges @Nick_Boyts
1 Like
@Nick_Boyts @MartinSpence
how can i surpress this ?
it counts until 1247 but the list ends at 57 ?
or can i solve this in excel?
You probably had data in those rows at some point. Just clear (or delete) those rows and that should fix it. Otherwise you can always filter your data in Dynamo for empty rows.
1 Like
You can try to use pandas or .Net DataTable
example with pandas, deleting empty lines and a few others
(dataframes can be spliced if necessary (transactions))
import clr
import sys
import System
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import numpy as np
import pandas as pd
file_xls = IN[0]
df = pd.read_excel(file_xls)
# remove empty row by ElementId
df = df.dropna(subset=['Element ID'])
# apply a mask
df = df[df["Hersteller"] == "T1/5.4"]
# set value
TransactionManager.Instance.EnsureInTransaction(doc)
for index, row in df.iterrows():
elemId = ElementId(int(row['Element ID']))
print(elemId)
value_to_set = row["Feuerwiderstandsklasse_"] # row['Pruefintervall']
if pd.isnull(value_to_set):
pass
else:
elem = doc.GetElement(elemId)
para = elem.LookupParameter("Feuerwiderstandsklasse_")
if para is not None:
para.Set(value_to_set)
TransactionManager.Instance.TransactionTaskDone()
OUT = repr(df)
1 Like