Error in getting curve through python

Hi There

Can anyone suggest what is problem here in my code. See attached images. It says there is some error on line 11. I couldn’t find or understand that error. Please explain.

feed the data to the Python Script node :grin:

You cannot get the centerline of a “list” which your “IN[0]” is (a list of 8 rebars), try to do a loop over the items in your input list.

Essentially IN[0] = {Rebar 211332, Rebar 211334, Rebar 211335 …}
If you insert a loop like: (Insert below instead of your line 11

Rebars = IN[0]

curves = []
for i in range(len(Rebars)):

… and then continue your script from line 12

Thanks for your reply and Suggestion.

i use that program but is’t not working.

See below :point_down::point_down:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
unexpected token 'dynamocurves’

Can you throw me a sample Revit file with the rebars in it so that I can perform a quick test?

TEST.rvt (1.6 MB)

Hi Robert
I guess the reason you want to use the “ToProtoType()” is to convert from Revit Geometry to Dynamo Geometry, although if you check the element type of the rebars as in my screenshot these are “elements” and not geometry. I’ve done this and get’s an output, is this what you desired? If not let me know what your end-goal is :slight_smile:

import clr
from Autodesk.DesignScript.Geometry import *

from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import * 
import Autodesk

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Rebars = UnwrapElement(IN[0])
dynCurve = []
curves = []
for i in range(len(Rebars)):
OUT = curves

This is interesting reading:

Hi Jonathan

As per your instruction & code supplied by you, i am getting output as circled in red. But i want output as shown in blue circle. Can you please provide suggestions on that.

Using the script provided by Einer (which I’m sure is the one you’re using) from this thread on a single rebar in your file i get the following output: Rebar 2d detailing (Like Sofistik) - #4 by Eduardo_Dilo


If you wish to get these curves back to a detailcurve you could have a look in this thread:

Hi Jonathan

Yes you are right. It works for single bar but not for multi bars. Please see attached image.

Can you please suggest anything to get same output for multi bars.

Like so:

dynCurve = []
for i in range(len(IN[0])):
    curves = (UnwrapElement(IN[0][i]).GetCenterlineCurves(0,0,0,0,0))
    for curve in curves:

If a comment solves your problem please mark that comment as the solution so that others might be helped in the future. And maybe leave a like here and there.

Hi Jonathan

I want sub-list of all archs in single rebar. For an example bar with hook of 180 degrees at both ends will have 3 lines & 2 archs. So i want list of all 5 in output. Can you please suggest a way for that.

Thanks mate…cheers…!!

You could consider something like this:

EDIT: updated code to be more efficient.

inCurves = list(UnwrapElement(IN[0]))
outCurve = []
for curves in inCurves:
    dynCurve = []
    for item in curves.GetCenterlineCurves(0,0,0,0,0):

Can i make it a Curve??

This is a new issue, please create a separate question for that, that is if a poly-curve doesn’t do the job for you.