I am Trying to Sent the Selected Data from the Dropdown combobox Area01_selector or Modeless.XAML to Area Comment Parameter but when Clicking the Button it closes the Window
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Metadata
""
from pyrevit import script #
# from pyrevit import revit #
# Import standard libraries
import sys
import traceback
# Import required libraries
from Autodesk.Revit.UI import IExternalEventHandler, ExternalEvent
from Autodesk.Revit.Exceptions import InvalidOperationException
from pyrevit.forms import WPFWindow
from pyrevit import script
from Autodesk.Revit import DB, UI
# Add custom modules path
# Access the active document
uidoc = __revit__.ActiveUIDocument
doc = uidoc.Document
# Define Area names
Area01_Names = ["Market Residential", "Market Rental", "Affordable Rental", "Social Housing", "Hotel", "Office", "Commercial"]
MarketResidential_Names = ["Unit", "Common", "Services"]
MarketResidential_Unit_Names = ["Jr.Studio", "Studio", "Jr.1 Bedroom","1 Bedroom","1 Bedroom & Den","Jr. 2 Bedroom","2 Bedroom","2 Bedroom & Den","3 Bedroom","3 Bedroom & Den","Townhouse","Exclusion"]
MarketResidential_Unit_JrStudio_Names = ["M Unit - A1a", "M Unit - A2a", "M Unit - A3a","M Unit - A4a","M Unit - A5a"]
MarketResidential_Unit_Studio_Names = ["M Unit - A1a", "M Unit - A2a", "M Unit - A3a","M Unit - A4a","M Unit - A5a"]
MarketResidential_Unit_Jr1Bedroom_Names = ["M Unit - B1a", "M Unit - B2a", "M Unit - B3a","M Unit - B4a","M Unit - B5a"]
MarketResidential_Unit_1Bedroom_Names = ["M Unit - B1a", "M Unit - B2a", "M Unit - B3a","M Unit - B4a","M Unit - B5a"]
MarketResidential_Unit_1BedroomDen_Names = ["M Unit - B1a", "M Unit - B2a", "M Unit - B3a","M Unit - B4a","M Unit - B5a"]
MarketResidential_Unit_Jr2Bedroom_Names = ["M Unit - C1a", "M Unit - C2a", "M Unit - C3a","M Unit - C4a","M Unit - C5a"]
MarketResidential_Unit_2Bedroom_Names = ["M Unit - C1a", "M Unit - C2a", "M Unit - C3a","M Unit - C4a","M Unit - C5a"]
MarketResidential_Unit_2BedroomDen_Names = ["M Unit - C1a", "M Unit - C2a", "M Unit - C3a","M Unit - C4a","M Unit - C5a"]
MarketResidential_Unit_3Bedroom_Names = ["M Unit - D1a", "M Unit - D2a", "M Unit - D3a","M Unit - D4a","M Unit - D5a"]
MarketResidential_Unit_3BedroomDen_Names = ["M Unit - D1a", "M Unit - D2a", "M Unit - A3a","M Unit - A4a","M Unit - A5a"]
MarketResidential_Unit_Townhouse_Names = ["M Unit - E1a", "M Unit - E2a", "M Unit - E3a","M Unit - E4a","M Unit - E5a"]
MarketResidential_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby","Amenity"]
MarketResidential_Common_Core_Names = ["M Core-1", "M Core-2", "M Core-3","M Core-4","M Core-5"]
MarketResidential_Common_Corridor_Names = ["Cr-1", "Cr-2", "Cr-3","Cr-4","Cr-5"]
MarketResidential_Common_ExistStair_Names = ["Stair β 1", "Stair β 2", "Stair β 3","Stair β 4","Stair β 5"]
MarketResidential_Common_Lobby_Names = ["M Lobby β 1", "M Lobby β 2", "M Lobby β 3","M Lobby β 4","M Lobby β 5"]
MarketResidential_Common_Amenity_Names = ["M Amenity β 1", "M Amenity β 2", "M Amenity β 3","M Amenity β 4","M Amenity β 5"]
MarketResidential_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
MarketRental_Names = ["Unit", "Common", "Services"]
MarketRental_Unit_Names = ["Jr.Studio", "Studio", "Jr.1 Bedroom","1 Bedroom","1 Bedroom & Den","Jr. 2 Bedroom","2 Bedroom","2 Bedroom & Den","3 Bedroom","3 Bedroom & Den","Townhouse","Exclusion"]
MarketRental_Unit_JrStudio_Names = ["MR Unit - A1a", "MR Unit - A2a", "MR Unit - A3a","MR Unit - A4a","MR Unit - A5a"]
MarketRental_Unit_Studio_Names = ["MR Unit - A1a", "MR Unit - A2a", "MR Unit - A3a","MR Unit - A4a","MR Unit - A5a"]
MarketRental_Unit_Jr1Bedroom_Names = ["MR Unit - B1a", "MR Unit - B2a", "MR Unit - B3a","MR Unit - B4a","MR Unit - B5a"]
MarketRental_Unit_1Bedroom_Names = ["MR Unit - B1a", "MR Unit - B2a", "MR Unit - B3a","MR Unit - B4a","MR Unit - B5a"]
MarketRental_Unit_1BedroomDen_Names = ["MR Unit - B1a", "MR Unit - B2a", "MR Unit - B3a","MR Unit - B4a","MR Unit - B5a"]
MarketRental_Unit_Jr2Bedroom_Names = ["MR Unit - C1a", "MR Unit - C2a", "MR Unit - C3a","MR Unit - C4a","MR Unit - C5a"]
MarketRental_Unit_2Bedroom_Names = ["MR Unit - C1a", "MR Unit - C2a", "MR Unit - C3a","MR Unit - C4a","MR Unit - C5a"]
MarketRental_Unit_2BedroomDen_Names = ["MR Unit - C1a", "MR Unit - C2a", "MR Unit - C3a","MR Unit - C4a","MR Unit - C5a"]
MarketRental_Unit_3Bedroom_Names = ["MR Unit - D1a", "MR Unit - D2a", "MR Unit - D3a","MR Unit - D4a","MR Unit - D5a"]
MarketRental_Unit_3BedroomDen_Names = ["MR Unit - D1a", "MR Unit - D2a", "MR Unit - A3a","MR Unit - A4a","MR Unit - A5a"]
MarketRental_Unit_Townhouse_Names = ["MR Unit - E1a", "MR Unit - E2a", "MR Unit - E3a","MR Unit - E4a","MR Unit - E5a"]
MarketRental_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby","Amenity"]
MarketRental_Common_Core_Names = ["MR Core-1", "MR Core-2", "MR Core-3","MR Core-4","MR Core-5"]
MarketRental_Common_Corridor_Names = ["Cr-1", "Cr-2", "Cr-3","Cr-4","Cr-5"]
MarketRental_Common_ExistStair_Names = ["Stair β 1", "Stair β 2", "Stair β 3","Stair β 4","Stair β 5"]
MarketRental_Common_Lobby_Names = ["MR Lobby β 1", "MR Lobby β 2", "MR Lobby β 3","MR Lobby β 4","MR Lobby β 5"]
MarketRental_Common_Amenity_Names = ["MR Amenity β 1", "MR Amenity β 2", "MR Amenity β 3","MR Amenity β 4","MR Amenity β 5"]
MarketRental_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
AffordableRental_Names = ["Unit", "Common", "Services"]
AffordableRental_Unit_Names = ["Jr.Studio", "Studio", "Jr.1 Bedroom","1 Bedroom","1 Bedroom & Den","Jr. 2 Bedroom","2 Bedroom","2 Bedroom & Den","3 Bedroom","3 Bedroom & Den","Townhouse","Exclusion"]
AffordableRental_Unit_JrStudio_Names = ["AR Unit - A1a", "AR Unit - A2a", "AR Unit - A3a","AR Unit - A4a","AR Unit - A5a"]
AffordableRental_Unit_Studio_Names = ["AR Unit - A1a", "AR Unit - A2a", "AR Unit - A3a","AR Unit - A4a","AR Unit - A5a"]
AffordableRental_Unit_Jr1Bedroom_Names = ["AR Unit - B1a", "AR Unit - B2a", "AR Unit - B3a","AR Unit - B4a","AR Unit - B5a"]
AffordableRental_Unit_1Bedroom_Names = ["AR Unit - B1a", "AR Unit - B2a", "AR Unit - B3a","AR Unit - B4a","AR Unit - B5a"]
AffordableRental_Unit_1BedroomDen_Names = ["AR Unit - B1a", "AR Unit - B2a", "AR Unit - B3a","AR Unit - B4a","AR Unit - B5a"]
AffordableRental_Unit_Jr2Bedroom_Names = ["AR Unit - C1a", "AR Unit - C2a", "AR Unit - C3a","AR Unit - C4a","AR Unit - C5a"]
AffordableRental_Unit_2Bedroom_Names = ["AR Unit - C1a", "AR Unit - C2a", "AR Unit - C3a","AR Unit - C4a","AR Unit - C5a"]
AffordableRental_Unit_2BedroomDen_Names = ["AR Unit - C1a", "AR Unit - C2a", "AR Unit - C3a","AR Unit - C4a","AR Unit - C5a"]
AffordableRental_Unit_3Bedroom_Names = ["AR Unit - D1a", "AR Unit - D2a", "AR Unit - D3a","AR Unit - D4a","AR Unit - D5a"]
AffordableRental_Unit_3BedroomDen_Names = ["AR Unit - D1a", "AR Unit - D2a", "AR Unit - A3a","AR Unit - A4a","AR Unit - A5a"]
AffordableRental_Unit_Townhouse_Names = ["AR Unit - E1a", "AR Unit - E2a", "AR Unit - E3a","AR Unit - E4a","AR Unit - E5a"]
AffordableRental_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby","Amenity"]
AffordableRental_Common_Core_Names = ["AR Core-1", "AR Core-2", "AR Core-3","AR Core-4","AR Core-5"]
AffordableRental_Common_Corridor_Names = ["Cr-1", "Cr-2", "Cr-3","Cr-4","Cr-5"]
AffordableRental_Common_ExistStair_Names = ["Stair β 1", "Stair β 2", "Stair β 3","Stair β 4","Stair β 5"]
AffordableRental_Common_Lobby_Names = ["AR Lobby β 1", "AR Lobby β 2", "AR Lobby β 3","AR Lobby β 4","AR Lobby β 5"]
AffordableRental_Common_Amenity_Names = ["AR Amenity β 1", "AR Amenity β 2", "AR Amenity β 3","AR Amenity β 4","AR Amenity β 5"]
AffordableRental_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
SocialHousing_Names = ["Unit", "Common", "Services"]
SocialHousing_Unit_Names = ["Jr.Studio", "Studio", "Jr.1 Bedroom","1 Bedroom","1 Bedroom & Den","Jr. 2 Bedroom","2 Bedroom","2 Bedroom & Den","3 Bedroom","3 Bedroom & Den","Townhouse","Exclusion"]
SocialHousing_Unit_JrStudio_Names = ["SH Unit - A1a", "SH Unit - A2a", "SH Unit - A3a","SH Unit - A4a","SH Unit - A5a"]
SocialHousing_Unit_Studio_Names = ["SH Unit - A1a", "SH Unit - A2a", "SH Unit - A3a","SH Unit - A4a","SH Unit - A5a"]
SocialHousing_Unit_Jr1Bedroom_Names = ["SH Unit - B1a", "SH Unit - B2a", "SH Unit - B3a","SH Unit - B4a","SH Unit - B5a"]
SocialHousing_Unit_1Bedroom_Names = ["SH Unit - B1a", "SH Unit - B2a", "SH Unit - B3a","SH Unit - B4a","SH Unit - B5a"]
SocialHousing_Unit_1BedroomDen_Names = ["SH Unit - B1a", "SH Unit - B2a", "SH Unit - B3a","SH Unit - B4a","SH Unit - B5a"]
SocialHousing_Unit_Jr2Bedroom_Names = ["SH Unit - C1a", "SH Unit - C2a", "SH Unit - C3a","SH Unit - C4a","SH Unit - C5a"]
SocialHousing_Unit_2Bedroom_Names = ["SH Unit - C1a", "SH Unit - C2a", "SH Unit - C3a","SH Unit - C4a","SH Unit - C5a"]
SocialHousing_Unit_2BedroomDen_Names = ["SH Unit - C1a", "SH Unit - C2a", "SH Unit - C3a","SH Unit - C4a","SH Unit - C5a"]
SocialHousing_Unit_3Bedroom_Names = ["SH Unit - D1a", "SH Unit - D2a", "SH Unit - D3a","SH Unit - D4a","SH Unit - D5a"]
SocialHousing_Unit_3BedroomDen_Names = ["SH Unit - D1a", "SH Unit - D2a", "SH Unit - A3a","SH Unit - A4a","SH Unit - A5a"]
SocialHousing_Unit_Townhouse_Names = ["SH Unit - E1a", "SH Unit - E2a", "SH Unit - E3a","SH Unit - E4a","SH Unit - E5a"]
SocialHousing_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby","Amenity"]
SocialHousing_Common_Core_Names = ["SH Core-1", "SH Core-2", "SH Core-3","SH Core-4","SH Core-5"]
SocialHousing_Common_Corridor_Names = ["Cr-1", "Cr-2", "Cr-3","Cr-4","Cr-5"]
SocialHousing_Common_ExistStair_Names = ["Stair β 1", "Stair β 2", "Stair β 3","Stair β 4","Stair β 5"]
SocialHousing_Common_Lobby_Names = ["SH Lobby β 1", "SH Lobby β 2", "SH Lobby β 3","SH Lobby β 4","SH Lobby β 5"]
SocialHousing_Common_Amenity_Names = ["SH Amenity β 1", "SH Amenity β 2", "SH Amenity β 3","SH Amenity β 4","SH Amenity β 5"]
SocialHousing_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
Hotel_Names = ["Unit", "Common", "Services"]
Hotel_Unit_Names = ["Suite King", "Standard King", "Accessible King","Suite Queen","Standard Queen","Accessible Queen","Standard King/Queen","Accessible King/Queen","Standard Queen/Queen","Accessible Queen/Queen","Standard Double/Double","Accessible Double/Double"]
Hotel_Unit_SuiteKing_Names = ["H Unit - A1a", "H Unit - A2a", "H Unit - A3a","H Unit - A4a","H Unit - A5a"]
Hotel_Unit_StandardKing_Names = ["H Unit - A1a", "H Unit - A2a", "H Unit - A3a","H Unit - A4a","H Unit - A5a"]
Hotel_Unit_AccessibleKing_Names = ["H Unit - B1a", "H Unit - B2a", "H Unit - B3a","H Unit - B4a","H Unit - B5a"]
Hotel_Unit_SuiteQueen_Names = ["H Unit - B1a", "H Unit - B2a", "H Unit - B3a","H Unit - B4a","H Unit - B5a"]
Hotel_Unit_StandardQueen_Names = ["H Unit - B1a", "H Unit - B2a", "H Unit - B3a","H Unit - B4a","H Unit - B5a"]
Hotel_Unit_AccessibleQueen_Names = ["H Unit - C1a", "H Unit - C2a", "H Unit - C3a","H Unit - C4a","H Unit - C5a"]
Hotel_Unit_StandardKingQueen_Names = ["H Unit - C1a", "H Unit - C2a", "H Unit - C3a","H Unit - C4a","H Unit - C5a"]
Hotel_Unit_AccessibleKingQueen_Names = ["H Unit - C1a", "H Unit - C2a", "H Unit - C3a","H Unit - C4a","H Unit - C5a"]
Hotel_Unit_StandardQueenQueen_Names = ["H Unit - D1a", "H Unit - D2a", "H Unit - D3a","H Unit - D4a","H Unit - D5a"]
Hotel_Unit_AccessibleQueenQueen_Names = ["H Unit - D1a", "H Unit - D2a", "H Unit - A3a","H Unit - A4a","H Unit - A5a"]
Hotel_Unit_StandardDoubleDouble_Names = ["H Unit - E1a", "H Unit - E2a", "H Unit - E3a","H Unit - E4a","H Unit - E5a"]
Hotel_Unit_AccessibleDoubleDouble_Names = ["H Unit - E1a", "H Unit - E2a", "H Unit - E3a","H Unit - E4a","H Unit - E5a"]
Hotel_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby","Amenity"]
Hotel_Common_Core_Names = ["H Core-1", "H Core-2", "H Core-3","H Core-4","H Core-5"]
Hotel_Common_Corridor_Names = ["Cr-1", "Cr-2", "Cr-3","Cr-4","Cr-5"]
Hotel_Common_ExistStair_Names = ["Stair β 1", "Stair β 2", "Stair β 3","Stair β 4","Stair β 5"]
Hotel_Common_Lobby_Names = ["H Lobby β 1", "H Lobby β 2", "H Lobby β 3","H Lobby β 4","H Lobby β 5"]
Hotel_Common_Amenity_Names = ["H Amenity β 1", "H Amenity β 2", "H Amenity β 3","H Amenity β 4","H Amenity β 5"]
Hotel_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
Hotel_Common_Names = ["Core", "Corridor", "Exit Stair", "Lobby", "Amenity"]
Hotel_Services_Names = ["Mechanical", "Electrical", "Garbage","Storage","Loading"]
Office_Names = ["Unit", "Common", "Services"]
Office_Unit_Names = ["CRU1", "CRU2", "CRU3", "CRU4", "CRU5"]
Office_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby", "Amenity", "Washroom"]
Office_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
Commercial_Names = ["CRU", "Common", "Services"]
Commercial_CRU_Names = ["Restaurant", "Retail"]
Commercial_Common_Names = ["Core", "Corridor", "Exit Stair","Lobby", "Amenity", "Washroom"]
Commercial_Services_Names = ["Mechanical", "Electrical", "Garbage", "Storage", "Loading"]
# Function to mark Area parameter
def mark_Area_parameter(area_type_01, area_type_02):
selection_ids = uidoc.Selection.GetElementIds()
if len(selection_ids) == 0:
return "Nothing selected."
# Filter selected elements by category "Area"
selection = [doc.GetElement(x) for x in selection_ids]
selection = filter(lambda x: x.Category.Name == "Area", selection)
t = DB.Transaction(doc, "Area Parameter")
t.Start()
count = 0
for area in selection:
# Set "AREA TYPE 01" and "AREA TYPE 02" parameters
area.LookupParameter("Area Type 01").Set(area_type_01)
area.LookupParameter("Area Type 02").Set(area_type_02)
count += 1
t.Commit()
return "{} Parameter text added.".format(count)
def populate_comments_parameter(area_type_01):
selection_ids = uidoc.Selection.GetElementIds()
if len(selection_ids) == 0:
return "Nothing selected."
# Filter selected elements by category "Area"
selection = [doc.GetElement(x) for x in selection_ids]
selection = filter(lambda x: x.Category.Name == "Area", selection)
t = DB.Transaction(doc, "Area Parameter")
t.Start()
count = 0
for area in selection:
# Set "Comments" parameter
area.LookupParameter("Comments").Set(area_type_01)
count += 1
t.Commit()
return "{} Comments parameter populated.".format(count)
# Create a subclass of IExternalEventHandler for event handling
class area_text_SimpleEventHandler(IExternalEventHandler):
def __init__(self, do_this):
self.do_this = do_this
self.kwargs = None
self.OUT = None
def Execute(self, uiapp):
try:
try:
self.OUT = self.do_this(*self.kwargs)
except:
print("Failed")
print(traceback.format_exc())
except InvalidOperationException:
print("InvalidOperationException caught")
def GetName(self):
return "Simple function executed by an IExternalEventHandler in a Form"
# Define a modeless WPF form
class Areatool_ModelessForm(WPFWindow):
def pre_actions(self):
self.simple_event_handler = area_text_SimpleEventHandler(mark_Area_parameter)
def __init__(self):
self.pre_actions()
xaml_file_name = "Areatool_ModelessForm.xaml"
WPFWindow.__init__(self, xaml_file_name)
# Add an event handler for the Area01_selector
self.Area01_selector.SelectionChanged += self.Area01_selector_SelectionChanged
self.Area02_selector.SelectionChanged += self.Area02_selector_SelectionChanged
self.Area03_selector.SelectionChanged += self.Area03_selector_SelectionChanged
self.ext_event = ExternalEvent.Create(self.simple_event_handler)
self.Show()
Area01_Names_selector = self.Area01_selector
Area01_Names_selector.Items.Clear()
for name in Area01_Names:
Area01_Names_selector.Items.Add(name)
self.ext_event = ExternalEvent.Create(self.simple_event_handler)
self.Show()
def close_Click(self, sender, e):
self.Close()
def sent_Revit(self, sender, e):
# Handle the "Sent to Revit" button click event
self.populate_comments_parameter(Area01_selector)
def Area01_selector_SelectionChanged(self, sender, e):
# Handle the selection changed event for Area01_selector
selected_area = self.Area01_selector.SelectedItem
if selected_area == "Market Residential":
# If "Market Residential" is selected, populate Area02_selector with MarketResidential_Names
self.Area02_selector.Items.Clear()
for name in MarketResidential_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Market Rental":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in MarketRental_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Affordable Rental":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in MarketRental_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Social Housing":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in SocialHousing_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Hotel":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in Hotel_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Office":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in Office_Names:
self.Area02_selector.Items.Add(name)
elif selected_area == "Commercial":
# If "Market Rental" is selected, populate Area02_selector with MarketRental_Names
self.Area02_selector.Items.Clear()
for name in Commercial_Names:
self.Area02_selector.Items.Add(name)
# Add more conditions for other area types as needed
def Area02_selector_SelectionChanged(self, sender, e):
# Handle the selection changed event for Area02_selector
selected_area = self.Area02_selector.SelectedItem
self.Area03_selector.Items.Clear()
if selected_area == "Unit":
# If "Unit" is selected in Area02_selector, populate Area03_selector with MarketResidential_Unit_Names
for name in MarketResidential_Unit_Names:
self.Area03_selector.Items.Add(name)
elif selected_area == "Common":
# If "Common" is selected in Area02_selector, populate Area03_selector with MarketResidential_Common_Names
for name in MarketResidential_Common_Names:
self.Area03_selector.Items.Add(name)
elif selected_area == "Services":
# If "Common" is selected in Area02_selector, populate Area03_selector with MarketResidential_Common_Names
for name in MarketResidential_Services_Names:
self.Area03_selector.Items.Add(name)
def Area03_selector_SelectionChanged(self, sender, e):
# Handle the selection changed event for Area02_selector
selected_area = self.Area03_selector.SelectedItem
self.Area04_selector.Items.Clear()
if selected_area == "Jr.Studio":
# If "Jr.Studio" is selected in Area03_selector, populate Area04_selector with MarketResidential_Unit_JrStudio_Names
for name in MarketResidential_Unit_JrStudio_Names:
self.Area04_selector.Items.Add(name)
elif selected_area == "Studio":
# If "Common" is selected in Area02_selector, populate Area03_selector with MarketResidential_Unit_Studio_Names
for name in MarketResidential_Unit_Studio_Names:
self.Area04_selector.Items.Add(name)
elif selected_area == "Services":
# If "Common" is selected in Area02_selector, populate Area03_selector with MarketResidential_Common_Names
for name in MarketResidential_Services_Names:
self.Area04_selector.Items.Add(name)
# Customizable event handling classes
class CustomizableEvent:
def __init__(self):
custom_handler = _CustomHandler()
custom_handler.customizable_event = self
self.custom_event = UI.ExternalEvent.Create(custom_handler)
self.function_or_method = None
self.args = ()
self.kwargs = {}
def _raised_method(self):
self.function_or_method(*self.args, **self.kwargs)
def raise_event(self, function_or_method, *args, **kwargs):
self.args = args
self.kwargs = kwargs
self.function_or_method = function_or_method
self.custom_event.Raise()
class _CustomHandler(UI.IExternalEventHandler):
def __init__(self):
self.customizable_event = None
def Execute(self, application):
try:
self.customizable_event._raised_method()
except InvalidOperationException:
print("InvalidOperationException caught")
def GetName(self):
return "Execute a function or method in a IExternalHandler"
# Main function
def main():
modeless_form = Areatool_ModelessForm()
# Run the main function if this script is executed
if __name__ == "__main__":
main()