TypeError: expected int, got list

I search the forum but couldn’t find the answer.
Why is this happend?

Error:
image

Inputs:


image

import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes

def GetName(ele):
	elename = None
 	try:
 		elename = ele.Name
 	except:
 		elename = RDB.Element.Name.__get__(ele)
 	return elename 
 

#einde code omrekenen revit feet naar huidig ingestele document units

#categoriëen ophalen
cat_list = [RDB.BuiltInCategory.OST_PipeCurves, RDB.BuiltInCategory.OST_PipeFitting]
typed_list = MGen.List[RDB.BuiltInCategory](cat_list)
filter = RDB.ElementMulticategoryFilter(typed_list)
elementen = RDB.FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType().ToElements()

#Alle pipes en fittings ophalen 
pipe_elem = []
for nw in elementen:
	p_name = GetName(nw)
	if p_name.Contains("Bochtstraal") or p_name.Contains("Alupex"):
		pipe_elem.append(nw)
		
#Pipe fittingen ophalen
pipe_fitting = []
for pf in pipe_elem:
	pf_name = GetName(pf)
	if pf_name.Contains("Bochtstraal"):
		pipe_fitting.append(pf)
		
#geconnecte pipe ophalen
refs = []

for x in pipe_fitting:
	connset = x.MEPModel.ConnectorManager.Connectors
	conn_pipes = []
	for c in connset:
		if c.IsConnected:
			for lc in c.AllRefs:
				conn_pipes.append(lc.Owner)
	refs.append(conn_pipes)

#section van geconnecte buis ophalen
p_section = []
for r in refs:
	p_section.append([]) #lege lijst maken voor behoudt structuur
	for i in r:
		section = i.get_Parameter(RDB.BuiltInParameter.RBS_SECTION).AsValueString()
		p_section[-1].append(section)	#-1 zorgt ervoor dat lijst in structuur blijft.	
		
#Unique items eruit halen
ukeys= p_section
listOfList = [ukeys]
ukeys1 = [item[0] for item in ukeys]
ukeys2 = []
for u in ukeys1:
	ukeys2.append(int(u))
	
#Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

n_section = []
for pf in pipe_fitting:
	n_section.append(pf.LookupParameter("Section").Set(ukeys2))
		
TransactionManager.Instance.TransactionTaskDone()

OUT= n_section

@jw.vanasselt that is one long script, not sure what you are doing, if you can provide a small Revit sample file to test your code, it would be better; Nevertheless, based on the error you posted, maybe a zip to loop at the same time over 2 different variables might solve your problem, try it likes this:

for pf, i in zip(pipe_fitting, ukeys2):
	n_section.append(pf.LookupParameter("Section").Set(i))
1 Like

Thanks! This is a solution to do this.
I found this solution too:

#toevoegen van sections aan bochten
n_section = []

uk = 0
n_section = []
for pf in pipe_fitting:
	pf.LookupParameter("Section").Set(ukeys2[uk])
	n_section.append(pf)
	uk += 1 	
#Einde transaction
TransactionManager.Instance.TransactionTaskDone()
1 Like

@jw.vanasselt yep, basically it is the same, instead of looping over items, you are getting the items by accessing the list through their indices, and incrementing the indices to loop over the items.

1 Like

Thanks for you’re help! :slight_smile:

1 Like

Hi @Elie.Trad ,

I have in another script the same error but my list is deeper.
How can i use this method:

It’s about this forum: