所以我刚刚开始涉足 pyRevit 中的 WPF。我尝试像这样实现pyrevit.forms.WPFWindow 类:
# -*- coding: UTF-8 -*-
"""
Third-Party software credits:
pyRevit: repository at https://github.com/eirannejad/pyRevit
"""
import System, clr, json, sys
clr.AddReference("System.Windows.Forms")
clr.AddReference('IronPython.Wpf')
import wpf
from Autodesk.Revit.DB import *
from pyrevit import revit, script, forms
class FactorySettings(forms.WPFWindow):
def __init__(self):
forms.WPFWindow.__init__(self, script.get_bundle_file('settings.xaml'))
def something_click(self, A, B):
plantings = FilteredElementCollector(revit.doc) \
.WhereElementIsElementType() \
.OfCategory(BuiltInCategory.OST_Planting)
ui = FactorySettings()
ui.show()
Run Code Online (Sandbox Code Playgroud)
这是我的 xaml:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Collections="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
ShowInTaskbar="False" ResizeMode="CanResize"
WindowStartupLocation="CenterScreen"
HorizontalContentAlignment="Center"
Title="Set worksets" Width="300" SizeToContent="Height"
>
<StackPanel Margin="0,0,0,0" …Run Code Online (Sandbox Code Playgroud)