RebarStyle("StirrupTie") - not accepted for creating a rebar from RebarFromCurve in the api

I am trying to create a rebar from the revit api using RebarFromCurve method.
As I enter the RebarStyle as a StirrupTie (node from the Structural Design package) I recieve the following error: Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 40, in
TypeError: expected RebarStyle, got str

Thing is I am not entering a string…

Next I tried entering the element directly from the API - RebarStyle.StirrupTie but I still get the same warning.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
curves = UnwrapElement(IN[0])
rebarStyle = UnwrapElement(IN[1])
rebarType = UnwrapElement(IN[2])
startHookType = UnwrapElement(IN[3])
endHookType = UnwrapElement(IN[3])
startHookOrientation = UnwrapElement(IN[4])
endHookOrientation = UnwrapElement(IN[4])
host = UnwrapElement(IN[5])
vector = UnwrapElement(IN[6])


#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
newRebar = Rebar.CreateFromCurves(doc,rebarStyle,RebarStyle.StirrupTie,startHookType,endHookType,host,vector,curves,startHookOrientation,endHookOrientation,True,True)
TransactionManager.Instance.TransactionTaskDone()

OUT = newRebar

Anyone?

hello,

the error indicates that you probably passed the type name instead of the type itself at node input

You have some examples here

https://forum.dynamobim.com/search?expanded=true&q=Rebar.CreateFromCurves%20%20tags:python%20before:2022-01-10

Thanks for the reference but none of them refer to my issue. Plus, most of the examples don’t have any responses…
Btw I actually managed to get passed that, I changed the input to RebarStyle.StirrupTie and it works.
But I now have an issue that I am not managing to get passed with the following warning:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 40, in
TypeError: expected XYZ, got List[object]

I am changed the input to “vector = IN[6].ToXyz()” but I am still getting the message that “list object has no attribute to ToXyz”. Any reason why it would read the Vector object as a List object?
image

Any ideas?

try :
vector = IN[6][0].ToXyz() should solve this error

1 Like

This is the message that I get when implementing this change:
Warning: AttributeError : ‘list’ object has no attribute ‘ToXyz’ [’ File “”, line 34, in \n’]

Don’t know why but it worked when I flatten the list. Weird thing is that I used the flatten list previously and it didn’t work then but now it is working…

But now pops up a different problem :slight_smile:. I’ll just have to take care of that now.

I’ll update on further issues if I can’t solve them. Thanks!

So my next problem is with the code for the method “CreateFromCurves”, here is the warning that I get:
“Warning: TypeError : No method matches given arguments for CreateFromCurves: (<class ‘Autodesk.Revit.DB.Document’>, <class ‘int’>, <class ‘NoneType’>, <class ‘Autodesk.Revit.DB.Structure.RebarHookType’>, <class ‘Autodesk.Revit.DB.Structure.RebarHookType’>, <class ‘Autodesk.Revit.DB.FamilyInstance’>, <class ‘Autodesk.Revit.DB.XYZ’>, <class ‘str’>, <class ‘str’>, <class ‘list’>, <class ‘bool’>, <class ‘bool’>) [’ File “”, line 40, in \n’]”

Can it be that it doesn’t recognize the method or the inputs?

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
curves = UnwrapElement(IN[0])
rebarStyle = UnwrapElement(IN[1])
rebarType = IN[2]
hookType = UnwrapElement(IN[3])
hookOrientation = UnwrapElement(IN[4])
host = UnwrapElement(IN[5])
vector = IN[6][0].ToXyz()


#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

newRebar = Rebar.CreateFromCurves(doc, rebarStyle, hookType, hookType, host, vector, hookOrientation, hookOrientation, hookOrientation, True, True)

TransactionManager.Instance.TransactionTaskDone()

OUT = newRebar

You forgot the list of curves in the arguments of your method. (which must be converted with “ToRevitType()” and cast it into an .Net List[Curve] Collection)

As you have changed Python engine, it would be wise to create a new topic

1 Like

Sure thing I’ll create a new post.
Just a couple of question:

  1. All the errors are to do with the casting of the curves to .net?
  2. How would I cast the list to a .net list?

No

an example

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

#import net library
from System.Collections.Generic import List

listDB_Curves = List[DB.Curve](myPythonlistOfCurves)
1 Like