Python error - 'List[object]' object has no attribute 'append'

Hi all i am trying to write a script for finding all possible paths in a connected piping network.I am taking one pipe element as input and using a for loop i am trying to add connected elements to the master list.I am looping through a list of revit elements.i am getting an error which says …
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 108, in
File “”, line 45, in listappend
AttributeError: ‘List[object]’ object has no attribute ‘append’

i have attached the python script also…can anybody help me to debug it.
Water Pressure Zoning Master2020.dyn (6.4 KB)

by default IronPython converts a CPython list to NetList (IronPython.Runtime.List) with properties and methods specific to CPython and Net Collection

However, if a method returns a .Net collection it keeps its properties and its methods (as we are working in a Net environment, you might as well take advantage of the Net methods / properties)

2 solutions

  • if you want use append → convert your Net List to Python list: Master = list (Flatten (Master))
    or
  • you can replace append by Add: Master.Add (element)
1 Like

great …it worked…thanks a lot…can you help me with one more thing…my list master (used as for loop list) will start with one element first…then inside the body of for loop it will get updated with its connected element…when the for loop runs for the second time i want for loop to use the updated master list…can you suggest me with any logic or methods to achieve it.thanks

Here is a reflection (untested)

1 get all items connected
2 find the end pipes connected to terminals or panels
3 find groups of pipes (+ fittings) by analyzing fittings with more than 2 connectors
4 for each pair of end pipes, find the best path with groups

Thanks…Will try this logic…