Python error: Creating Chamfered Wires with python




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.


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:

 import clr
 from Autodesk.DesignScript.Geometry import *

 import RevitServices
 from RevitServices.Persistence import DocumentManager
 from RevitServices.Transactions import TransactionManager
 from System.Collections.Generic import *

 import Revit

 import Autodesk
 from Autodesk.Revit.DB import *
 from Autodesk.Revit.DB.Electrical import *

 import DSCore
 from DSCore.List import *

 import sys
 pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'

 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]

 OUT = Wire.Create(doc,wireTypeId,view,wiringType,vertexPts,sConnector,eConnector)

Thanks for your inputs :slight_smile:


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.


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


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)


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