# Dynamo Node Python error TypeError: iteration over non-sequence of type FamilyInstance

**URL:** <https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920>\
**Category:** Revit\
**Created:** [June 18, 2018, 11:44pm UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920 "2018-06-18T23:44:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![raymond.humes](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@raymond.humes](https://forum.dynamobim.com/u/raymond.humes)\
**Post date:** [June 18, 2018, 11:44pm UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/1 "2018-06-18T23:44:59Z")

</div>

Hi I’m trying to use a node from a package called RIE nodes and one specific node within this package is failing RIE.PowerElements, the node doesn’t output anything or show an error, but when I open the node and copy the python code into a python node and run it, it shows this error  
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
Traceback (most recent call last):  
File “”, line 39, in   
TypeError: iteration over non-sequence of type FamilyInstance

which I suppose is the source of my problem shown below. the code in this node was discussed in a previous post at the following link below and it seems to be working for the people using it there I compared it and the code appears identical I’m running revit 2018.2 and using dynamo 1.3.2.2480 can someone please point out whats wrong I think the problem may be in the For Loop?

> [@Python; Create new circuit in panel and assign electrical elements to circuit](https://forum.dynamobim.com/t/python-create-new-circuit-in-panel-and-assign-electrical-elements-to-circuit/16073/16):
>
> Great slight_smile It also seems that the script does not run well if already powered elements are part of the selection. I think that could be implemented in the script with a boolean input; Disconnect powered elements and connect the input elements all together, or to skip already powered elements and connect the remaining elements to a new circuit. By the way I have published a few nodes in a package called “RIE”. Nodes for creating circuits, selecting panel, and drawing wires for circui…

import clr  
clr.AddReference(‘ProtoGeometry’)  
from Autodesk.DesignScript.Geometry import \*

clr.AddReference(‘RevitServices’)  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
from RevitServices.Transactions import TransactionManager  
from System.Collections.Generic import \*

clr.AddReference(‘RevitNodes’)  
import Revit  
clr.ImportExtensions(Revit.Elements)

clr.AddReference(‘RevitAPI’)  
import Autodesk  
from Autodesk.Revit.DB import \*  
from Autodesk.Revit.DB.Electrical import \*  
from Autodesk.Revit.DB import MEPSystem

clr.AddReference(‘DSCoreNodes’)  
import DSCore  
from DSCore.List import \*

import sys  
pyt\_path = r’C:\Program Files (x86)\IronPython 2.7\Lib’  
sys.path.append(pyt\_path)

#/ Import List ( ICollection(ElementId) = ListElementId )  
clr.AddReference(“System”)  
from System.Collections.Generic import List

#The inputs to this node will be stored as a list in the IN variables.  
input = UnwrapElement(IN[0])

electComponents = ListElementId

for i in input:  
electComponents.Add(i.Id)

doc = DocumentManager.Instance.CurrentDBDocument  
uiapp = DocumentManager.Instance.CurrentUIApplication  
app = uiapp.Application  
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

TransactionManager.Instance.EnsureInTransaction(doc)

newcircuit = ElectricalSystem.Create(doc, electComponents, ElectricalSystemType.PowerCircuit)

OUT =   
OUT.append(newcircuit)

TransactionManager.Instance.TransactionTaskDone()

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [June 19, 2018, 12:16am UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/2 "2018-06-19T00:16:24Z")

</div>

@raymond.humes do you have an item only in your input? If so you need to create a list.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/75df0745af2569a9b42b75631ba7896820a9b95b.png)

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/5/a55941ad12d1c59b82db9db4e06ef8f7f02f81c2.png)

---

<div class="post-metadata">

**Author:** ![raymond.humes](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@raymond.humes](https://forum.dynamobim.com/u/raymond.humes)\
**Post date:** [June 19, 2018, 1:12am UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/3 "2018-06-19T01:12:56Z")

</div>

That solved the problem thank you I didn’t realize it required that kind of input.

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [June 19, 2018, 2:16am UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/4 "2018-06-19T02:16:47Z")

</div>

@raymond.humes Please mark as solved.

if you want your graph to work all the times, add the code below. it’ll be sure you always have a list with the correct structure.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/7/f757f0e95bea04e91201592ee1d65f922fc4c71f.png)

---

<div class="post-metadata">

**Author:** ![andre.abotnes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andre.abotnes/32/42003_2.png) [@andre.abotnes](https://forum.dynamobim.com/u/andre.abotnes)\
**Post date:** [June 19, 2018, 5:51am UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/5 "2018-06-19T05:51:49Z")

</div>

Hello. Nice to see that the issue has been resolved. I will update the RIE package to not require a list input for this particular node in the future.

---

<div class="post-metadata">

**Author:** ![andre.abotnes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andre.abotnes/32/42003_2.png) [@andre.abotnes](https://forum.dynamobim.com/u/andre.abotnes)\
**Post date:** [June 19, 2018, 5:56am UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/6 "2018-06-19T05:56:49Z")

</div>

The RIE package has now been updated to version 0.4.6.

---

<div class="post-metadata">

**Author:** ![raymond.humes](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@raymond.humes](https://forum.dynamobim.com/u/raymond.humes)\
**Post date:** [June 20, 2018, 11:27pm UTC](https://forum.dynamobim.com/t/dynamo-node-python-error-typeerror-iteration-over-non-sequence-of-type-familyinstance/22920/7 "2018-06-20T23:27:27Z")

</div>

Hi Andre thanks I tried it, its working I came up with an improvement you may want to include as part of an updated version of the node this gets rid of the problem of getting that error where you try circuiting elements that are already powered using the node Element.ElectricalCircuit from MEPover so it’ll skip over the elements that are already powered I also included a snippet of code you may want to publish as a separate node so the selected elements are each circuited individually to there own electrical system. By the way for your node if its used to power a element where the voltage is an instance parameter the field gets grayed out and set to zero and can’t be changed it only works right and doesn’t get grayed out if the voltage is a type parameter do you have any idea how to fix that?

 ![ANDRE%20RIE%20POWER](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/1/21095761bbcdb5fd27470bc16e4643bd50fe3a70.JPG)

 ![Andre%20CodeJPG](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/b/6bb6ca3d96aab24c250d78b7bf84af2c23aa0283.JPG)
