Hi All,
I’m trying to modify the Unconnected Wall Height
parameter for the selected walls using a WPF window as shown below, but I’m encountering the following error and I don’t know how to solve it?
Here my pyrevit and xaml scripts
My_Tool
# -*- coding: UTF-8 -*-
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 select_push_button(self, sender, e):
self.hide()
sel = uidoc.Selection.PickObjects(Selection.ObjectType.Element, 'Choose elements')
self.els = [doc.GetElement(elId) for elId in sel]
self.ShowDialog()
def ok_push_button(self, sender, e):
param_name = self.Text_input.Text
param_value = self.Value_input.Text
t = Transaction(doc, 'Change parameter')
t.Start()
try:
for i in self.els:
i.LookupParameter(param_name).Set(UnitUtils.ConvertToInternalUnits(param_value, UnitTypeId.Meters))
except:
TaskDialog.Show('error', 'error message')
t.Commit()
slef.Close()
def cancel_button(self, sender, e):
self.Close()
form = ModalForm('interface.xaml')```
xaml
<?xml version="1.0" encoding="utf-8"?>
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="regard"
Height="300"
Width="300">
<Grid>
<Button
Grid.Column="0"
Grid.Row="0"
VerticalAlignment="Bottom"
Height="25"
Width="75"
HorizontalAlignment="Left"
Margin="20,0,0,15"
x:Name="ok_button"
Click="ok_push_button"
Content="ok" />
<Button
Grid.Column="0"
Grid.Row="0"
VerticalAlignment="Bottom"
Width="75"
HorizontalAlignment="Right"
Height="25"
Margin="0,0,107,15"
x:Name="Select_button"
Click="select_push_button"
Content="Select" />
<Button
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Width="75"
Margin="195,0,0,15"
Height="25"
x:Name="Cancel_button"
Click="cancel_button"
Content="Cancel" />
<Label
Content="Parameter Name"
Height="25"
Width="100"
Margin="25,40,0,0"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Grid.Row="0"
Grid.Column="0" />
<TextBox
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
RenderTransformOrigin="0.5097,0.45"
Height="25"
Margin="0,40,25,0"
x:Name="Text_input"
Width="100" />
<Label
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="25,90,0,0"
Width="100"
Height="25"
Content="Value" />
<TextBox
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Height="25"
Width="100"
Margin="0,90,25,0"
x:Name="Value_input" />
</Grid>
</Window>
Any help would be appreciated.
Thanks.