Set ProjectParamter with Loop

Hey Everyone,

i am pretty new to Dynamo and Python. I have the task to set project paramters for the current Document. I get the parameters from an excel file. So far so good. I managed to collect all the informations i needed in three lists. I wrote a little python script to set the parameters but it doesnt work like i want too. The Script writes in all elements the same value and i cant figure out why. I think its a loop problem but, i cant find the problem. Can anybody help?

PS: Sorry for my bad english.

i wrote a litte python script who looks like this:

# Phython-UnterstĂĽtzung aktivieren und DesignScript-Bibliothek laden
import clr
import sys

# import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# import Revit API UI
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
# import Revit Services 
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager 


# get Revit's current Document file.
doc = DocumentManager.Instance.CurrentDBDocument
# get the current application 
app = DocumentManager.Instance.CurrentUIApplication.Application
#get the user interface application 
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# Die Eingaben fĂĽr diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
elements = IN[0]
pnames = IN[1]
pvalues = IN[2]

for ele in UnwrapElement(elements):
	for pvalue in pvalues:
		for j in range(0,len(pnames)):
			TransactionManager.Instance.EnsureInTransaction(doc)
			
			p = ele.LookupParameter(pnames[j])
			p.Set(pvalue[j])
			
			TransactionManager.Instance.TransactionTaskDone()

What i expect:

Set Paramters for every element right

What i get:
set for every element the same parameters.

image

Here is the python code for testing:

elements = [2131026,2131560,2132029]

pnames = ["lfNr","BT/Etage","Raum / Bereich","DN","Nennweite Q3 = m³/h","AKS","Zähler Nr.","Stand"]

pvalues = [

    ["1","AU1", "WWB Küche Sanitärzentrale A.-2.TE.020","25","6,3","AU2_014_SAN_ZAE_WZ005","…","0,00"],

    ["2","AU2","Fettabscheider Sanitärzentrale A.-2.TE.020","15","2,5","AU2_014_SAN_ZAE_WZ006","…","0,00"],

    ["4","AU4","Enthärtungsanlage Küche Sanitärzentrale A.-2.TE.020","25","6,3","AU2_014_SAN_ZAE_WZ007","…","0,00"],

    ]

for ele in elements:

    print(ele , "-----------------------------------------------------------------------------------")

    for pvalue in pvalues:

        #print(pValue)

        for j in range(0,len(pnames)):

            #print(j)

            #print(ele)

            pGet = pnames[j]

            pSet = pvalue[j]

            print(pGet)

            print(pSet)

            print("-----------------")

problem solved:

# Phython-UnterstĂĽtzung aktivieren und DesignScript-Bibliothek laden
import clr
import sys

# import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# import Revit API UI
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
# import Revit Services 
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager 


# get Revit's current Document file.
doc = DocumentManager.Instance.CurrentDBDocument
# get the current application 
app = DocumentManager.Instance.CurrentUIApplication.Application
#get the user interface application 
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# Die Eingaben fĂĽr diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
elements = IN[0]
pnames = IN[1]
pvalues = IN[2]

for element, values in zip(UnwrapElement(elements),pvalues):

	for name, value in zip(pnames,values):
	
		TransactionManager.Instance.EnsureInTransaction(doc)
			
		p = element.LookupParameter(name)
		p.Set(value)
			
		TransactionManager.Instance.TransactionTaskDone()
	


# Code unterhalb dieser Linie platzieren

# Weisen Sie Ihre Ausgabe der OUT-Variablen zu.
1 Like