@@ -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 :
@@ -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" ]
@@ -821,10 +820,10 @@ def InitializeComponent(self):
821820 row1_y_start = 2
822821 spacing = 5
823822 section_margin = 15
824-
823+
825824 # LEFT COLUMN - Data Selection
826825 left_y_pos = row1_y_start + section_margin
827-
826+
828827 # Category label
829828 self ._txt_block2 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
830829 self ._txt_block2 .Location = Drawing .Point (left_col_x , left_y_pos )
@@ -836,10 +835,10 @@ def InitializeComponent(self):
836835 self ._txt_block2 , "Select a category to start coloring."
837836 )
838837 left_y_pos += 22
839-
838+
840839 # RIGHT COLUMN - Actions & Settings (start positioning)
841840 right_y_pos = row1_y_start + section_margin
842-
841+
843842 # Section: Manage Schemes
844843 self ._lbl_manage_schemes .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
845844 self ._lbl_manage_schemes .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -848,7 +847,7 @@ def InitializeComponent(self):
848847 self ._lbl_manage_schemes .Text = "Manage Schemes"
849848 self ._lbl_manage_schemes .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
850849 right_y_pos += 25
851-
850+
852851 # Category dropdown - align with Save/Load Color Scheme button (adjusted for button border)
853852 self ._categories .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
854853 self ._categories .Location = Drawing .Point (left_col_x , right_y_pos + 2 )
@@ -863,7 +862,7 @@ def InitializeComponent(self):
863862 self .tooltips .SetToolTip (
864863 self ._categories , "Select a category to start coloring."
865864 )
866-
865+
867866 # Save / Load Color Scheme button - align with Category dropdown
868867 self ._button_save_load_scheme .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
869868 self ._button_save_load_scheme .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -878,7 +877,7 @@ def InitializeComponent(self):
878877 "Save the current color scheme or load an existing one." ,
879878 )
880879 right_y_pos += 40
881-
880+
882881 # Parameters label - align with Generate Colors label
883882 self ._txt_block3 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
884883 self ._txt_block3 .Location = Drawing .Point (left_col_x , right_y_pos )
@@ -889,7 +888,7 @@ def InitializeComponent(self):
889888 self .tooltips .SetToolTip (
890889 self ._txt_block3 , "Select a parameter to color elements based on its value."
891890 )
892-
891+
893892 # Section: Generate Colors - align with Parameters label
894893 self ._lbl_generate_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
895894 self ._lbl_generate_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -898,7 +897,7 @@ def InitializeComponent(self):
898897 self ._lbl_generate_colors .Text = "Generate Colors"
899898 self ._lbl_generate_colors .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
900899 right_y_pos += 25
901-
900+
902901 # Search TextBox - align with Gradient Colors button (adjusted for button border)
903902 self ._search_box .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
904903 self ._search_box .Location = Drawing .Point (left_col_x , right_y_pos + 2 )
@@ -913,7 +912,7 @@ def InitializeComponent(self):
913912 self .tooltips .SetToolTip (
914913 self ._search_box , "Type to search and filter parameters."
915914 )
916-
915+
917916 # Gradient Colors button - align with Search box
918917 self ._button_gradient_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
919918 self ._button_gradient_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -928,7 +927,7 @@ def InitializeComponent(self):
928927 "Based on the color of the first and last value,\n reassign gradients colors to all values." ,
929928 )
930929 right_y_pos += 32
931-
930+
932931 # Parameters dropdown - align with Random Colors button (adjusted for button border)
933932 self ._list_box1 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
934933 self ._list_box1 .FormattingEnabled = True
@@ -942,7 +941,7 @@ def InitializeComponent(self):
942941 self .tooltips .SetToolTip (
943942 self ._list_box1 , "Select a parameter to color elements based on its value."
944943 )
945-
944+
946945 # Random Colors button - align with Parameters dropdown
947946 self ._button_random_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
948947 self ._button_random_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -956,7 +955,7 @@ def InitializeComponent(self):
956955 self ._button_random_colors , "Reassign new random colors to all values."
957956 )
958957 right_y_pos += 40
959-
958+
960959 # Values label - align with Apply Settings label
961960 self ._txt_block4 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
962961 self ._txt_block4 .Location = Drawing .Point (left_col_x , right_y_pos )
@@ -967,7 +966,7 @@ def InitializeComponent(self):
967966 self .tooltips .SetToolTip (
968967 self ._txt_block4 , "Reassign colors by clicking on their value."
969968 )
970-
969+
971970 # Section: Apply Settings - align with Values label
972971 self ._lbl_apply_settings .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
973972 self ._lbl_apply_settings .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -976,7 +975,7 @@ def InitializeComponent(self):
976975 self ._lbl_apply_settings .Text = "Apply Settings"
977976 self ._lbl_apply_settings .Font = Drawing .Font (self .Font .FontFamily , 9 , Drawing .FontStyle .Bold )
978977 right_y_pos += 25
979-
978+
980979 # Values listbox (will be sized to align with Set Colors button + margin)
981980 values_listbox_top = right_y_pos
982981 self .list_box2 .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
@@ -998,7 +997,7 @@ def InitializeComponent(self):
998997 self .tooltips .SetToolTip (
999998 self .list_box2 , "Reassign colors by clicking on their value."
1000999 )
1001-
1000+
10021001 # TextBlock5 - Hidden warning message
10031002 self ._txt_block5 .Anchor = Forms .AnchorStyles .Bottom | Forms .AnchorStyles .Left
10041003 self ._txt_block5 .Location = Drawing .Point (left_col_x , 600 )
@@ -1008,7 +1007,7 @@ def InitializeComponent(self):
10081007 self ._txt_block5 .ForeColor = Drawing .Color .Red
10091008 self ._txt_block5 .Font = Drawing .Font (self .Font .FontFamily , 8 , Drawing .FontStyle .Underline )
10101009 self ._txt_block5 .Visible = False
1011-
1010+
10121011 # Checkbox: Line Color
10131012 self ._chk_line_color .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10141013 self ._chk_line_color .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1023,7 +1022,7 @@ def InitializeComponent(self):
10231022 "When enabled, applies the color to projection line color." ,
10241023 )
10251024 right_y_pos += 25
1026-
1025+
10271026 # Checkbox: Foreground Pattern Color
10281027 self ._chk_foreground_pattern .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10291028 self ._chk_foreground_pattern .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1038,7 +1037,7 @@ def InitializeComponent(self):
10381037 "When enabled, applies the color to surface and cut foreground pattern colors." ,
10391038 )
10401039 right_y_pos += 25
1041-
1040+
10421041 # Checkbox: Background Pattern Color
10431042 self ._chk_background_pattern .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10441043 self ._chk_background_pattern .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1059,7 +1058,7 @@ def InitializeComponent(self):
10591058 "When enabled, applies the color to surface and cut background pattern colors. Requires Revit 2019 or newer." ,
10601059 )
10611060 right_y_pos += 40
1062-
1061+
10631062 # Create Legend button
10641063 self ._button_create_legend .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10651064 self ._button_create_legend .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1074,7 +1073,7 @@ def InitializeComponent(self):
10741073 "Create a new legend view for all the values and their colors." ,
10751074 )
10761075 right_y_pos += 32
1077-
1076+
10781077 # Create View Filters button
10791078 self ._button_create_view_filters .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10801079 self ._button_create_view_filters .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1089,11 +1088,11 @@ def InitializeComponent(self):
10891088 "Create view filters and rules for all the values and their colors." ,
10901089 )
10911090 right_y_pos += 40
1092-
1091+
10931092 # Reset and Set Colors buttons (grouped under Create View Filters)
10941093 button_width = int ((right_col_width - 15 ) / 2 )
10951094 button_spacing = 15
1096-
1095+
10971096 # Reset button
10981097 self ._button_reset_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
10991098 self ._button_reset_colors .Location = Drawing .Point (right_col_x , right_y_pos )
@@ -1107,7 +1106,7 @@ def InitializeComponent(self):
11071106 self ._button_reset_colors ,
11081107 "Reset the colors in your Revit view to its initial stage." ,
11091108 )
1110-
1109+
11111110 # Set Colors button - Blue with white text
11121111 self ._button_set_colors .Anchor = Forms .AnchorStyles .Top | Forms .AnchorStyles .Left
11131112 self ._button_set_colors .Location = Drawing .Point (right_col_x + button_width + button_spacing , right_y_pos )
@@ -1139,21 +1138,21 @@ def InitializeComponent(self):
11391138 self ._button_set_colors ,
11401139 "Replace the colors per element in the view." ,
11411140 )
1142-
1141+
11431142 # Calculate form height: Set Colors button bottom + margin + extra margin for values section
11441143 set_colors_bottom = right_y_pos + 32
11451144 bottom_margin = 25
11461145 values_section_bottom_margin = 15
11471146 form_height = set_colors_bottom + bottom_margin + values_section_bottom_margin
1148-
1147+
11491148 # Calculate values listbox height to align with Set Colors button + margin
11501149 # The listbox should end at the same level as Set Colors button + margin
11511150 values_listbox_bottom = set_colors_bottom + bottom_margin
11521151 values_listbox_height = values_listbox_bottom - values_listbox_top
11531152 if values_listbox_height < 100 :
11541153 values_listbox_height = 100 # Minimum height
11551154 self .list_box2 .Size = Drawing .Size (left_col_width , values_listbox_height )
1156-
1155+
11571156 # Form
11581157 self .TopMost = True
11591158 self .ShowInTaskbar = False
@@ -1922,11 +1921,11 @@ def get_color_shades(base_color, apply_line, apply_foreground, apply_background)
19221921 Only line color is faded when used with other types.
19231922 """
19241923 r , g , b = base_color .Red , base_color .Green , base_color .Blue
1925-
1924+
19261925 foreground_color = base_color
19271926 background_color = base_color
1928-
1929-
1927+
1928+
19301929 # Line color is faded when used with other types, otherwise uses base color
19311930 if apply_line and (apply_foreground or apply_background ):
19321931 # When line is used with pattern colors, make line color more faded
@@ -1942,7 +1941,7 @@ def get_color_shades(base_color, apply_line, apply_foreground, apply_background)
19421941 else :
19431942 # When line is used alone, use base color
19441943 line_color = base_color
1945-
1944+
19461945 return line_color , foreground_color , background_color
19471946
19481947
@@ -1952,7 +1951,7 @@ def launch_color_splasher():
19521951 doc = revit .DOCS .doc
19531952 if doc is None :
19541953 raise AttributeError ("Revit document is not available" )
1955- except (AttributeError , RuntimeError , Exception ) as e :
1954+ except (AttributeError , RuntimeError , Exception ):
19561955 error_msg = UI .TaskDialog ("Color Splasher Error" )
19571956 error_msg .MainInstruction = "Unable to access Revit document"
19581957 error_msg .MainContent = "Please ensure you have a Revit project open and try again."
@@ -1989,7 +1988,7 @@ def launch_color_splasher():
19891988 )
19901989 wndw ._categories .SelectedIndex = - 1
19911990 wndw .Show ()
1992-
1991+
19931992 # Store wndw reference for event handlers
19941993 SubscribeView ._wndw = wndw
19951994 ApplyColors ._wndw = wndw
0 commit comments