Creating Roof By Footprint in Dynamo

The forum is your friend, use it as such :slight_smile:

To find this post I simply searched for the method you are using: NewFootPrintRoof.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from clr import StrongBox

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument

outline = IN[0]
level = UnwrapElement(IN[1])
roofType = UnwrapElement(IN[2])

footprint = CurveArray()

for o in outline:
    footprint.Append(o.ToRevitType(True) )
    
TransactionManager.Instance.EnsureInTransaction(doc)

# A strongbox containing a modelcurvearray
roofCurves = StrongBox[ModelCurveArray](ModelCurveArray())
New_Roof = doc.Create.NewFootPrintRoof(footprint, level, roofType, roofCurves)

TransactionManager.Instance.EnsureInTransaction(doc)

OUT = New_Roof

This code takes in the curves from Dynamo, extracted from the walls. If you wanted to take the geometry directly from the walls you would have to tweak it but I’m sure you can use the forum to help you get that :).

3 Likes