# Python error: Creating Chamfered Wires with python

**URL:** <https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179>\
**Category:** Developers\
**Tags:** python\
**Created:** [December 7, 2017, 9:24am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179 "2017-12-07T09:24:24Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [December 7, 2017, 9:24am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/1 "2017-12-07T09:24:24Z")

</div>

Hi

I am trying to create chamfered wires with dynamo, inputing connectors, and vertexpoints etc.  
I have made the python script to create the wires myself, and I cannot get it to work.  
When I try to run the script I get a peculiar error.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/d/ede7cb2050d7dc0a5efc668caa382ff422d30a5f.png)

What causes this error, and is it possible to work around it?

Here is the python script (code pasted in bottom of post), along with the relevant inputs from the graph:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c85326e20081ede525573e3a7b64bbd844258786.png)

```
 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 *

 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)

 connectors = IN[0]
 vrtxpts = UnwrapElement(IN[1])
 wiretyp = UnwrapElement(IN[2])
 curview = UnwrapElement(IN[3])

 doc = DocumentManager.Instance.CurrentDBDocument
 wireTypeId = wiretyp[0].Id
 view = curview.Id
 wiringType = WiringType.Chamfer
 vertexPts = vrtxpts
 sConnector = connectors[0]
 eConnector = connectors[1]

 TransactionManager.Instance.EnsureInTransaction(doc)
 OUT = Wire.Create(doc,wireTypeId,view,wiringType,vertexPts,sConnector,eConnector)
 TransactionManager.Instance.TransactionTaskDone()

```

Thanks for your inputs 🙂

---

<div class="post-metadata">

**Author:** ![T\_Pover](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/t_pover/32/19147_2.png) [@T\_Pover](https://forum.dynamobim.com/u/T_Pover)\
**Post date:** [December 7, 2017, 10:15am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/2 "2017-12-07T10:15:27Z")

</div>

Without look at the rest of your code I would say that it might be because the OUT is caught in a transaction. I would put the OUT part after the transaction. assign the Wire.Create to a variable instead of OUT.

---

<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:** [December 7, 2017, 10:17am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/3 "2017-12-07T10:17:57Z")

</div>

Thanks. Tried to do that, but I still get the same error, on the same line.

---

<div class="post-metadata">

**Author:** ![T\_Pover](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/t_pover/32/19147_2.png) [@T\_Pover](https://forum.dynamobim.com/u/T_Pover)\
**Post date:** [December 7, 2017, 10:43am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/4 "2017-12-07T10:43:44Z")

</div>

It seems that it expects a generic collection List as input for the vertex points. Also you need to convert the Dynamo points to Revit points. You could try this for the vertextpoints:

```
from System.Collections.Generic import List

 #convert the dynamo points to Revit XYZ points:
 points = [x.ToXyz() for x in IN[0]]
 #put the points in a generic List:
 vertexpoints = List[XYZ](points)
```

---

<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:** [December 7, 2017, 11:52am UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/6 "2017-12-07T11:52:46Z")

</div>

It worked! 😃 Thank you!  
I just forgot to import geometry conversions.

---

<div class="post-metadata">

**Author:** ![Bill\_Mutert](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bill_mutert/32/192965_2.png) [@Bill\_Mutert](https://forum.dynamobim.com/u/Bill_Mutert)\
**Post date:** [June 1, 2018, 5:55pm UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/7 "2018-06-01T17:55:10Z")

</div>

What would be the node based approach to this task instead of using Python script?  
I am not a code writer

---

<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 4, 2018, 12:00pm UTC](https://forum.dynamobim.com/t/python-error-creating-chamfered-wires-with-python/17179/8 "2018-06-04T12:00:31Z")

</div>

The RIE package has a node for drawing wires. There is also a node for chamfered wires with input vertexpoints, but I am not sure if that one is working optimally.
