@@ -83,7 +83,6 @@ def view_changed(self, sender, e):
8383 if self .registered == 0 :
8484 new_doc = e .Document
8585 if new_doc :
86- new_uiapp = new_doc .Application
8786 if wndw :
8887 # Compare with current document from Revit context
8988 try :
@@ -166,13 +165,13 @@ def Execute(self, uiapp):
166165
167166 with revit .Transaction ("Apply colors to elements" ):
168167 get_elementid_value = get_elementid_value_func ()
168+ version = int (HOST_APP .version )
169169 if get_elementid_value (sel_cat .cat .Id ) in (
170170 int (DB .BuiltInCategory .OST_Rooms ),
171171 int (DB .BuiltInCategory .OST_MEPSpaces ),
172172 int (DB .BuiltInCategory .OST_Areas ),
173173 ):
174174 # In case of rooms, spaces and areas. Check Color scheme is applied and if not
175- version = int (HOST_APP .version )
176175 if version > 2021 :
177176 if wndw .crt_view .GetColorFillSchemeId (sel_cat .cat .Id ).ToString () == "-1" :
178177 color_schemes = (
@@ -439,7 +438,7 @@ def Execute(self, uiapp):
439438 list_y = []
440439 list_text_heights = []
441440 y_pos = 0
442- spacing = 0.1
441+ spacing = 0
443442 for index , vw_item in enumerate (wndw .list_box2 .Items ):
444443 punto = DB .XYZ (0 , y_pos , 0 )
445444 item = vw_item ["Value" ]
@@ -586,6 +585,7 @@ def Execute(self, uiapp):
586585 categories = List [DB .ElementId ]()
587586 categories .Add (sel_cat .cat .Id )
588587 solid_fill_id = solid_fill_pattern_id ()
588+ version = int (HOST_APP .version )
589589 items_listbox = wndw .list_box2 .Items
590590 for i , element in enumerate (items_listbox ):
591591 item = wndw .list_box2 .Items [i ]["Value" ]
@@ -820,10 +820,10 @@ def InitializeComponent(self):
820820 row1_y_start = 2
821821 spacing = 5
822822 section_margin = 15
823-
823+
824824 # LEFT COLUMN - Data Selection
825825 left_y_pos = row1_y_start + section_margin
826-
826+
827827 # Category label
828828 self ._txt_block2 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
829829 self ._txt_block2 .Location = Drawing .Point (left_col_x , left_y_pos )
@@ -835,10 +835,10 @@ def InitializeComponent(self):
835835 self ._txt_block2 , "Select a category to start coloring."
836836 )
837837 left_y_pos += 22
838-
838+
839839 # RIGHT COLUMN - Actions & Settings (start positioning)
840840 right_y_pos = row1_y_start + section_margin
841-
841+
842842 # Section: Manage Schemes
843843 self ._lbl_manage_schemes .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
844844 self ._lbl_manage_schemes .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -847,7 +847,7 @@ def InitializeComponent(self):
847847 self ._lbl_manage_schemes .Text = "Manage Schemes"
848848 self ._lbl_manage_schemes .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
849849 right_y_pos += 25
850-
850+
851851 # Category dropdown - align with Save/Load Color Scheme button (adjusted for button border)
852852 self ._categories .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
853853 self ._categories .Location = Drawing .Point (left_col_x , right_y_pos + 2 )
@@ -862,7 +862,7 @@ def InitializeComponent(self):
862862 self .tooltips .SetToolTip (
863863 self ._categories , "Select a category to start coloring."
864864 )
865-
865+
866866 # Save / Load Color Scheme button - align with Category dropdown
867867 self ._button_save_load_scheme .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
868868 self ._button_save_load_scheme .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -877,7 +877,7 @@ def InitializeComponent(self):
877877 "Save the current color scheme or load an existing one." ,
878878 )
879879 right_y_pos += 40
880-
880+
881881 # Parameters label - align with Generate Colors label
882882 self ._txt_block3 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
883883 self ._txt_block3 .Location = Drawing .Point (left_col_x , right_y_pos )
@@ -888,7 +888,7 @@ def InitializeComponent(self):
888888 self .tooltips .SetToolTip (
889889 self ._txt_block3 , "Select a parameter to color elements based on its value."
890890 )
891-
891+
892892 # Section: Generate Colors - align with Parameters label
893893 self ._lbl_generate_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
894894 self ._lbl_generate_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -897,7 +897,7 @@ def InitializeComponent(self):
897897 self ._lbl_generate_colors .Text = "Generate Colors"
898898 self ._lbl_generate_colors .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
899899 right_y_pos += 25
900-
900+
901901 # Search TextBox - align with Gradient Colors button (adjusted for button border)
902902 self ._search_box .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
903903 self ._search_box .Location = Drawing .Point (left_col_x , right_y_pos + 2 )
@@ -912,7 +912,7 @@ def InitializeComponent(self):
912912 self .tooltips .SetToolTip (
913913 self ._search_box , "Type to search and filter parameters."
914914 )
915-
915+
916916 # Gradient Colors button - align with Search box
917917 self ._button_gradient_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
918918 self ._button_gradient_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -927,7 +927,7 @@ def InitializeComponent(self):
927927 "Based on the color of the first and last value,\n reassign gradients colors to all values." ,
928928 )
929929 right_y_pos += 32
930-
930+
931931 # Parameters dropdown - align with Random Colors button (adjusted for button border)
932932 self ._list_box1 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
933933 self ._list_box1 .FormattingEnabled = True
@@ -941,7 +941,7 @@ def InitializeComponent(self):
941941 self .tooltips .SetToolTip (
942942 self ._list_box1 , "Select a parameter to color elements based on its value."
943943 )
944-
944+
945945 # Random Colors button - align with Parameters dropdown
946946 self ._button_random_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
947947 self ._button_random_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -955,7 +955,7 @@ def InitializeComponent(self):
955955 self ._button_random_colors , "Reassign new random colors to all values."
956956 )
957957 right_y_pos += 40
958-
958+
959959 # Values label - align with Apply Settings label
960960 self ._txt_block4 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
961961 self ._txt_block4 .Location = Drawing .Point (left_col_x , right_y_pos )
@@ -966,7 +966,7 @@ def InitializeComponent(self):
966966 self .tooltips .SetToolTip (
967967 self ._txt_block4 , "Reassign colors by clicking on their value."
968968 )
969-
969+
970970 # Section: Apply Settings - align with Values label
971971 self ._lbl_apply_settings .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
972972 self ._lbl_apply_settings .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -975,7 +975,7 @@ def InitializeComponent(self):
975975 self ._lbl_apply_settings .Text = "Apply Settings"
976976 self ._lbl_apply_settings .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
977977 right_y_pos += 25
978-
978+
979979 # Values listbox (will be sized to align with Set Colors button + margin)
980980 values_listbox_top = right_y_pos
981981 self .list_box2 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
@@ -997,7 +997,7 @@ def InitializeComponent(self):
997997 self .tooltips .SetToolTip (
998998 self .list_box2 , "Reassign colors by clicking on their value."
999999 )
1000-
1000+
10011001 # TextBlock5 - Hidden warning message
10021002 self ._txt_block5 .Anchor = Forms .AnchorStyles .Bottom | Forms .AnchorStyles .Left
10031003 self ._txt_block5 .Location = Drawing .Point (left_col_x , 600 )
@@ -1007,7 +1007,7 @@ def InitializeComponent(self):
10071007 self ._txt_block5 .ForeColor = Drawing .Color .Red
10081008 self ._txt_block5 .Font = Drawing .Font (self .Font .FontFamily , 8 , Drawing .FontStyle .Underline )
10091009 self ._txt_block5 .Visible = False
1010-
1010+
10111011 # Checkbox: Line Color
10121012 self ._chk_line_color .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10131013 self ._chk_line_color .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1022,7 +1022,7 @@ def InitializeComponent(self):
10221022 "When enabled, applies the color to projection line color." ,
10231023 )
10241024 right_y_pos += 25
1025-
1025+
10261026 # Checkbox: Foreground Pattern Color
10271027 self ._chk_foreground_pattern .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10281028 self ._chk_foreground_pattern .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1037,7 +1037,7 @@ def InitializeComponent(self):
10371037 "When enabled, applies the color to surface and cut foreground pattern colors." ,
10381038 )
10391039 right_y_pos += 25
1040-
1040+
10411041 # Checkbox: Background Pattern Color
10421042 self ._chk_background_pattern .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10431043 self ._chk_background_pattern .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1058,7 +1058,7 @@ def InitializeComponent(self):
10581058 "When enabled, applies the color to surface and cut background pattern colors. Requires Revit 2019 or newer." ,
10591059 )
10601060 right_y_pos += 40
1061-
1061+
10621062 # Create Legend button
10631063 self ._button_create_legend .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10641064 self ._button_create_legend .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1073,7 +1073,7 @@ def InitializeComponent(self):
10731073 "Create a new legend view for all the values and their colors." ,
10741074 )
10751075 right_y_pos += 32
1076-
1076+
10771077 # Create View Filters button
10781078 self ._button_create_view_filters .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10791079 self ._button_create_view_filters .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1088,11 +1088,11 @@ def InitializeComponent(self):
10881088 "Create view filters and rules for all the values and their colors." ,
10891089 )
10901090 right_y_pos += 40
1091-
1091+
10921092 # Reset and Set Colors buttons (grouped under Create View Filters)
10931093 button_width = int ((right_col_width - 15 ) / 2 )
10941094 button_spacing = 15
1095-
1095+
10961096 # Reset button
10971097 self ._button_reset_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10981098 self ._button_reset_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1106,7 +1106,7 @@ def InitializeComponent(self):
11061106 self ._button_reset_colors ,
11071107 "Reset the colors in your Revit view to its initial stage." ,
11081108 )
1109-
1109+
11101110 # Set Colors button - Blue with white text
11111111 self ._button_set_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
11121112 self ._button_set_colors .Location = Drawing .Point (right_col_x + button_width + button_spacing , right_y_pos )
@@ -1138,21 +1138,21 @@ def InitializeComponent(self):
11381138 self ._button_set_colors ,
11391139 "Replace the colors per element in the view." ,
11401140 )
1141-
1141+
11421142 # Calculate form height: Set Colors button bottom + margin + extra margin for values section
11431143 set_colors_bottom = right_y_pos + 32
11441144 bottom_margin = 25
11451145 values_section_bottom_margin = 15
11461146 form_height = set_colors_bottom + bottom_margin + values_section_bottom_margin
1147-
1147+
11481148 # Calculate values listbox height to align with Set Colors button + margin
11491149 # The listbox should end at the same level as Set Colors button + margin
11501150 values_listbox_bottom = set_colors_bottom + bottom_margin
11511151 values_listbox_height = values_listbox_bottom - values_listbox_top
11521152 if values_listbox_height < 100 :
11531153 values_listbox_height = 100 # Minimum height
11541154 self .list_box2 .Size = Drawing .Size (left_col_width , values_listbox_height )
1155-
1155+
11561156 # Form
11571157 self .TopMost = True
11581158 self .ShowInTaskbar = False
@@ -1921,11 +1921,11 @@ def get_color_shades(base_color, apply_line, apply_foreground, apply_background)
19211921 Only line color is faded when used with other types.
19221922 """
19231923 r , g , b = base_color .Red , base_color .Green , base_color .Blue
1924-
1924+
19251925 foreground_color = base_color
19261926 background_color = base_color
1927-
1928-
1927+
1928+
19291929 # Line color is faded when used with other types, otherwise uses base color
19301930 if apply_line and (apply_foreground or apply_background ):
19311931 # When line is used with pattern colors, make line color more faded
@@ -1941,7 +1941,7 @@ def get_color_shades(base_color, apply_line, apply_foreground, apply_background)
19411941 else :
19421942 # When line is used alone, use base color
19431943 line_color = base_color
1944-
1944+
19451945 return line_color , foreground_color , background_color
19461946
19471947
@@ -1951,7 +1951,7 @@ def launch_color_splasher():
19511951 doc = revit .DOCS .doc
19521952 if doc is None :
19531953 raise AttributeError ("Revit document is not available" )
1954- except (AttributeError , RuntimeError , Exception ) as e :
1954+ except (AttributeError , RuntimeError , Exception ):
19551955 error_msg = UI .TaskDialog ("Color Splasher Error" )
19561956 error_msg .MainInstruction = "Unable to access Revit document"
19571957 error_msg .MainContent = "Please ensure you have a Revit project open and try again."
@@ -1988,7 +1988,7 @@ def launch_color_splasher():
19881988 )
19891989 wndw ._categories .SelectedIndex = - 1
19901990 wndw .Show ()
1991-
1991+
19921992 # Store wndw reference for event handlers
19931993 SubscribeView ._wndw = wndw
19941994 ApplyColors ._wndw = wndw
0 commit comments