I’m trying to create sheets in Revit from sheet name and number data from an excel file that has been preformatted. Here’s the code I’m trying to use (after RiR boilerplate), but it is not working:
doc = RhinoInside.Revit.Revit.ActiveDBDocument
sheets = []
if RUN:
t = Autodesk.Revit.DB.Transaction(doc, 'Add Sheets')
t.Start()
for i in range(len(sheetNumbers)):
newSheet = Autodesk.Revit.DB.ViewSheet.Create(doc, titleblock.Id)
newSheet.SheetNumber = sheetNumbers[i]
newSheet.Name = sheetNames[i]
sheets.append(newsheet)
t.Commit()
a = sheets
The error that I am seeing is: "Runtime error (InternalException): A managed exception was thrown by Revit or by one of its external applications.
Traceback:
line 23, in script"
(line 23 is the line where the sheet is being initially created – newSheet = Autodesk.Revit.DB.ViewSheet.Create(doc, titleblock.Id))
I have confirmed multiple times that the family that I am giving the ViewSheet.Create is in fact a Titleblock Family.
Here is the full picture of what I am doing (“sheetNames” is an input to the Python component). Yes, I am still interested in this but had to leave it alone before since I couldn’t make any more headway. I don’t know if this is something that McNeel is planning to add into RiR as a native Gh component, but that would be nice.
looks like you have to cast that sheet type when it gets placed in the python node. it may be easier to pull the type then the ID . It will enter the python node as an “int” then cast it to an element ID as shown
This code does not use list but should help you get going
I would also invite other input from Devs if they have more to add thx @ehsan