Search code examples
revit-apirevitpythonshellpyrevit

Revit API: Creating a new Footprint roof


I'm having trouble creating a footprint roof using revit 2018 API. Basically, I'm calling this:

doc.Create.NewFootPrintRoof(ca, doc.GetElement(roofsInstances[0].LevelId), roofsInstances[0].RoofType)

And:

  • "ca" is a valid Autodesk.Revit.DB.CurveArray object. It's a closed loop.
  • "doc.GetElement(roofsInstances[0].LevelId)" is a valid Autodesk.Revit.DB.Level object
  • And "roofsInstances[0].RoofType" is a valid Autodesk.Revit.DB.RoofType object

When I call it, it returns: Exception: Value cannot be null.

Any idea on what could be the issue? Thanks a lot!


Solution

  • So, I found out what was wrong. First, this method needs a 4th argument, a "out attribute" (sorry, I had never seen that before..) which needs to be a ModelCurveArray. The problem was that even when I gave a ModelCurveArray object as the 4th argument, it was then complaining that it expected a StrongBox[ModelCurveArray]. Never heard of that either.

    Anyway, I used this as the 4th argument:

    footPrintToModelCurveMapping = clr.StrongBox[ModelCurveArray](ModelCurveArray())
    

    And it works.