Reputation: 29
I start learning pyRevit and here's the trouble. I want to create a WPF where I may enter values then Revit could would automatically construct a simple rectangular building. I have already create a WPF but I'm stuck in part where I need to connect lenght's value(interface) with python code. enter image description here
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from pyrevit.forms import WPFWindow
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
class ModalForm(WPFWindow):
def __init__(self, xaml_file_name):
WPFWindow.__init__(self, xaml_file_name)
self.ShowDialog()
def start_button(self, sender, e):
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements()
for level in levels:
elevation = level.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble()
if elevation == 1000/304.8:
level_0 = level
for wall in walls:
name = wall.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()
if name == 'C25/30 - 250mm':
wall_type = wall
p_1 = XYZ(0,0,level_0.Elevation)
p_2 = XYZ(50,0,level_0.Elevation)
line_1 = Line.CreateBound(p_1, p_2)
t = Transaction(doc, 'column')
t.Start()
wall_1 = Wall.Create(doc, line, wall_type.Id, level_0.Id, 3000/304.8, 0, False, True)
t.Commit()
self.Close()
def cancel_button(self, sender, e):
self.Close()
form = ModalForm('interface.xaml')
Upvotes: 2
Views: 304
Reputation: 8294
For the programmatic creation of a super simple building, please refer to The Building Coder little house sample:
Upvotes: 1