Skip to content

Instantly share code, notes, and snippets.

@ibuilder
Created October 28, 2023 11:03
Show Gist options
  • Save ibuilder/57ae10a55b1561db04aed308b1ebd89b to your computer and use it in GitHub Desktop.
Save ibuilder/57ae10a55b1561db04aed308b1ebd89b to your computer and use it in GitHub Desktop.
Create floor plan with pyrevit
# pip install pyrevit
import clr
clr.AddReference('RevitAPI')
import Autodeskfrom Autodesk.Revit.DB
import *import pyrevitfrom pyrevit
import revit
revit.doc = __revit__.ActiveUIDocument.Document
level = revit.doc.GetElement(ElementId(level_id)) # Replace level_id with desired level ID
profile = Polygon.CreateRectangle(width, height, False) # Replace width and height with desired dimensions
material = revit.doc.GetElement(ElementId(material_id)) # Replace material_id with desired material ID
floor_type = revit.db.Collector(of_category='Floors', where=lambda x: x.FamilyName=='Generic - 12"').first_element
with revit.Transaction('Create Floor'):
floor = revit.doc.Create.NewFloor(profile, floor_type, level, False)
floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM).Set(height_above_level) # Replace height_above_level with desired value
floor.get_Parameter(BuiltInParameter.FLOOR_ATTR_MATERIAL_ID_PARAM).Set(material.Id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment