These are my scripts
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import Revit Services
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
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 *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference("RevitNodes")
import Revit
from Revit.Elements import *
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
import System
import System.Array
from System.Collections.Generic import *
#get the document
doc = DocumentManager.Instance.CurrentDBDocument
#Function
def stirrup(x1, y1, b, h, cover, shape, type, host, norm):
nx1 = x1 - (b / 2) + cover
nx2 = x1 + (b / 2) - cover
ny1 = y1 - (h / 2) + cover
ny2 = y1 + (h / 2) - cover
nz1 = 0
point_list = []
outLine = []
#Create Point
pt1 = XYZ(nx1, ny1, nz1)
pt2 = XYZ(nx2, ny1, nz1)
pt3 = XYZ(nx2, ny2, nz1)
pt4 = XYZ(nx1, ny2, nz1)
#Create Point List
point_list.append(pt1)
point_list.append(pt2)
point_list.append(pt3)
point_list.append(pt4)
#Use Point List Create PolyCurves
polycurve1 = PolyCurve.ByPoints(point_list, true)
outLine.append(polycurve1)
#Change from PolyCurves to Curves
curve1 = PolyCurve.Curves(polycurve1)
#Getting hook parameter from rebar type family
hook_at_start_parameter = rebartype.LookupParameter("Hook At Start")
hooks = hook_at_start_parameter.AsString()
hook_at_end_parameter = rebartype.LookupParameter("Hook At End")
hooke = hook_at_end_parameter.AsString()
#Get Family by name
shook = UnWrapElement(Family.ByName(hooks))
ehook = UnWrapElement(Family.ByName(hooke))
#Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#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, shook, ehook, host, norm, curve1, left, left)
stirrup_list.append(stirrup1)
#End
TransactionManager.Instance.TransactionTaskDone()
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]
stirrup_list = []
result = stirrup(pointx[0], pointy[0], width[0], height[0], covering[0], rebarshape[0], rebartype[0], element[0], vector[0])
OUT = stirrup_list
When I run these code it show this error unexpected indent and I can’t find the cause of this error.
Rebar.CreateFromCurvesAndShape(Document, RebarShape, RebarBarType, RebarHookType (Start Hook), RebarHookType (End Hook), Element, XYZ (norm), IList<Curves>, RebarHookOrientation (Start), RebarHookOrientation (End))
This function I try to get RebarHookType (Start Hook) and RebarHookType (End Hook) information from rebar type family, am I using the right scripts? I mean in my rebar type family already have hook type and I try to get that name in form of string and use this name to later get hook type family. For Hook Orientation only accept input is either left or right, can I just type it directly like this?
stirrup1 = Rebar.CreateFromCurvesAndShape(doc, shape, type, shook, ehook, host, norm, curve1, left, left)
no matter what I try it still show Unexpected indent error.