Hi, I have a problem with creating bulding pad with python. I get all the necessary inputs, but I cannot create an IList with curve loops. So I get the following error: "…line 46, in
TypeError: expected IList[CurveLoop], got CurveLoop". Could you please help me how to write it properly. Here is my script and python code.
Pad_Creation.dyn (9.9 KB)
import clr
#Import Revit Services
clr.AddReference (“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import Revit API
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
clr.AddReference(‘RevitAPIUI’)
from Autodesk.Revit.UI import *
#Import Revit Node
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
#Import Proto Geometry
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
import System
from System.Collections.Generic import *
#inputs
level = UnwrapElement(IN[0])
padType = UnwrapElement(IN[1])
curves = IN[2]
#necessary ID’s
levelId = level.Id
typeId = padType.Id
#creating CurveLoop
loop = CurveLoop()
for c in curves:
loop.Append(c.ToRevitType())
#get the document
doc = DocumentManager.Instance.CurrentDBDocument
#use safe transaction with Revit
TransactionManager.Instance.EnsureInTransaction(doc)
#creating pad
pad = BuildingPad.Create(doc,typeId,levelId,loop)
#Finish transaction with task done
TransactionManager.Instance.TransactionTaskDone()
OUT = pad
1 Like
Tomasz
January 30, 2018, 11:48am
2
import clr
#Import Revit Services
clr.AddReference ("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
#Import Revit Node
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
#Import Proto Geometry
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import System
from System.Collections.Generic import *
#inputs
level = UnwrapElement(IN[0])
padType = UnwrapElement(IN[1])
curves = IN[2]
#necessary ID's
levelId = level.Id
typeId = padType.Id
#creating CurveLoop
loop = CurveLoop()
for c in curves:
loop.Append(c.ToRevitType())
#get the document
doc = DocumentManager.Instance.CurrentDBDocument
#use safe transaction with Revit
TransactionManager.Instance.EnsureInTransaction(doc)
#creating pad
loops = [loop]
pad = BuildingPad.Create(doc,typeId,levelId,loops)
#Finish transaction with task done
TransactionManager.Instance.TransactionTaskDone()
OUT = pad
3 Likes
Revit API states:
C#
public static BuildingPad Create(
Document document,
ElementId buildingPadTypeId,
ElementId levelId,
IList curveLoops
It’s expecting a list so just add [ ] around loop:
pad = BuildingPad.Create(doc,typeId,levelId,[loop])
1 Like
Oh, thank you very much! The answer was on the surface… I thought that IList is something different. And this is so easy)))