How to change from polyline to curves python scripts dynamo

These are my code

import sys
import clr
from Autodesk.DesignScript.Geometry import *
# Import Revit Services
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import Curve as RCurve
from Autodesk.Revit.DB.Structure import *

from Autodesk.Revit.UI import *

import Revit
from Revit.Elements import *

import System
import System.Array
from System.Collections.Generic import *

#get the document
doc = DocumentManager.Instance.CurrentDBDocument

def str(x1, y1, b, h, cover, shape, type, host, shook2, ehook2, shook1, ehook1, orient):
    nx1 = x1 - (b / 2) + cover
    nx2 = x1 + (b / 2) - cover
    ny1 = y1 - (h / 2) + cover
    ny2 = y1 + (h / 2) - cover
    nz1 = 0
    count = 0
    point_list = []
    outLine = []
    while (count < 1):
	    #Create Point
	    pt1 = XYZ(nx1, ny1, nz1)
	    pt2 = XYZ(nx2, ny1, nz1)
	    pt3 = XYZ(nx2, ny2, nz1)
	    pt4 = XYZ(nx1, ny2, nz1)
	    pt5 = XYZ(nx1, ny1, nz1)
	    pt6 = XYZ(0, 0, 0)
	    #Create Point List
	    #Use Point List Create PolyCurves
	    polycurve1 = DB.PolyLine.Create(point_list)
	    #Create array A
	    Aarray = [System.Array[RCurve]([polycurve1])]
	    Aarray2 = System.Array[System.Array[RCurve]](Aarray)
	    #Start Transaction
	    #Create Stirrup base on curves and shape
	    #Function : Rebar.CreateFromCurvesAndShape(Document, RebarShape, RebarBarType, RebarHookType (Start Hook), RebarHookType (End Hook), Element, XYZ (norm), IList<Curves>, RebarHookOrientation (Start), RebarHookOrientation (End))
	    stirrup1 = Rebar.CreateFromCurvesAndShape(doc, shape, type, shook2, ehook2, host, pt6, Aarray2, orient, orient)
	    count = count + 1
    return stirrup_list

pointx = IN[0]
pointy = IN[1]
width = IN[2]
height = IN[3]
covering = IN[4]
rebarshape = UnwrapElement(IN[5])
rebartype = UnwrapElement(IN[6])
element = UnwrapElement(IN[7])
vector = IN[8]
shooktwo = UnwrapElement(IN[9])
ehooktwo = UnwrapElement(IN[10])
shookone = UnwrapElement(IN[11])
ehookone = UnwrapElement(IN[12])
hooko = UnwrapElement(IN[13])

stirrup_list = []

result = str(pointx, pointy, width, height, covering, rebarshape, rebartype, element, shooktwo, ehooktwo, shookone, ehookone, hooko)

OUT = stirrup_list

I used these code try to create stirrup by curve and shape but got this error TypeError: expected Curve, got PolyLine and I can say that it come from conflicted in these line of code

#Create array A|
Aarray = [System.Array[RCurve]([polycurve1])]|

Because my polycurve1 is getting by using DB.PolyLine.Create() but in order to make it work I must change from polyline to curve. I have see dynamo node that change from polycurve to curve but I cant find code for creating polycurve in Autodesk.DB and also I cant find code that change either polyline or polycurve to curve. So how can I work around to get polycurve in form of curve. Right now it is close loop square shape polyline.

1 Like