@@ -1399,7 +1399,6 @@ def generate_stair_2d_profile(
13991399
14001400 number_of_risers = number_of_treads + 1
14011401 tread_rise = height / number_of_risers
1402- custom_tread_run = any (run != 0 for run in custom_first_last_tread_run )
14031402 nosing_overlap = max (nosing_length , 0 )
14041403 nosing_tread_gap = - min (nosing_length , 0 )
14051404 nosing_overlap_offset = - V_ (nosing_overlap , 0 )
@@ -1430,29 +1429,40 @@ def define_generic_stair_treads():
14301429 default_tread_offset = Vector ([tread_run , tread_rise ])
14311430
14321431 def get_tread_data (i ):
1433- if custom_tread_run :
1434- current_tread_run = None
1435- if i == 0 :
1436- current_tread_run = custom_first_last_tread_run [0 ]
1437- elif i == number_of_risers - 1 :
1438- current_tread_run = custom_first_last_tread_run [1 ]
1439-
1440- if current_tread_run :
1441- tread_offset = default_tread_offset .copy ()
1442- tread_offset .x = current_tread_run
1443- tread_verts = deepcopy (default_tread_verts )
1444- tread_verts [- 1 ].x = current_tread_run
1445- return tread_offset , tread_verts
1432+ # Check if this is first or last tread with custom run
1433+ current_tread_run = None
1434+ if i == 0 and custom_first_last_tread_run [0 ] is not None :
1435+ current_tread_run = custom_first_last_tread_run [0 ]
1436+ elif i == number_of_risers - 1 and custom_first_last_tread_run [1 ] is not None :
1437+ current_tread_run = custom_first_last_tread_run [1 ]
1438+
1439+ if current_tread_run is not None :
1440+ tread_offset = default_tread_offset .copy ()
1441+ tread_offset .x = current_tread_run
1442+
1443+ # Handle zero-width treads
1444+ if current_tread_run == 0 :
1445+ # For zero width, just return vertical offset with no horizontal tread
1446+ return tread_offset , ()
1447+
1448+ tread_verts = deepcopy (default_tread_verts )
1449+ tread_verts [- 1 ].x = current_tread_run
1450+ return tread_offset , tread_verts
1451+
14461452 return default_tread_offset , default_tread_verts
14471453
14481454 # treads
14491455 current_offset = V_ (0 , 0 )
14501456 for i in range (number_of_risers ):
14511457 last_vert_i = len (vertices ) - 1
14521458 tread_offset , tread_verts = get_tread_data (i )
1453- current_tread_verts = [v + current_offset for v in tread_verts ]
1454- edges .extend (default_tread_edges + last_vert_i )
1455- vertices .extend (current_tread_verts )
1459+
1460+ # Skip adding vertices/edges for zero-width treads
1461+ if tread_verts :
1462+ current_tread_verts = [v + current_offset for v in tread_verts ]
1463+ edges .extend (default_tread_edges + last_vert_i )
1464+ vertices .extend (current_tread_verts )
1465+
14561466 current_offset += tread_offset
14571467
14581468 if stair_type == "WOOD/STEEL" :
@@ -1467,35 +1477,47 @@ def get_tread_verts(*args, **kwargs):
14671477 default_tread_offset = V_ (tread_run + nosing_tread_gap , tread_rise )
14681478
14691479 def get_tread_data (i ):
1470- if custom_tread_run :
1471- current_tread_run = None
1472- if i == 0 and custom_first_last_tread_run [0 ] != 0 :
1473- current_tread_run = custom_first_last_tread_run [0 ]
1474- elif i == number_of_risers - 1 and custom_first_last_tread_run [1 ] != 0 :
1475- current_tread_run = custom_first_last_tread_run [1 ]
1476-
1477- if current_tread_run :
1478- tread_offset = default_tread_offset .copy ()
1479- tread_offset .x = current_tread_run + nosing_tread_gap
1480- tread_verts = get_tread_verts (size = V_ (current_tread_run + nosing_overlap , tread_depth ))
1481- return tread_offset , tread_verts
1480+ # Check if this is first or last tread with custom run
1481+ current_tread_run = None
1482+ if i == 0 and custom_first_last_tread_run [0 ] is not None :
1483+ current_tread_run = custom_first_last_tread_run [0 ]
1484+ elif i == number_of_risers - 1 and custom_first_last_tread_run [1 ] is not None :
1485+ current_tread_run = custom_first_last_tread_run [1 ]
1486+
1487+ if current_tread_run is not None :
1488+ tread_offset = default_tread_offset .copy ()
1489+ tread_offset .x = current_tread_run + nosing_tread_gap
1490+
1491+ # Handle zero-width treads
1492+ if current_tread_run == 0 :
1493+ return tread_offset , ()
1494+
1495+ tread_verts = get_tread_verts (size = V_ (current_tread_run + nosing_overlap , tread_depth ))
1496+ return tread_offset , tread_verts
1497+
14821498 return default_tread_offset , default_tread_verts
14831499
14841500 # each tread is a separate shape
14851501 cur_offset = V_ (0 , 0 )
1502+ tread_index = 0
14861503 for i in range (number_of_risers ):
14871504 tread_offset , tread_verts = get_tread_data (i )
1488- cur_trade_shape = [v + cur_offset + nosing_overlap_offset for v in tread_verts ]
1489- vertices .extend (cur_trade_shape )
1490-
1491- cur_vertex = i * 4
1492- verts_to_add = (
1493- (cur_vertex , cur_vertex + 1 ),
1494- (cur_vertex + 1 , cur_vertex + 2 ),
1495- (cur_vertex + 2 , cur_vertex + 3 ),
1496- (cur_vertex + 3 , cur_vertex ),
1497- )
1498- edges .extend (verts_to_add )
1505+
1506+ # Skip adding vertices/edges for zero-width treads
1507+ if tread_verts :
1508+ cur_trade_shape = [v + cur_offset + nosing_overlap_offset for v in tread_verts ]
1509+ vertices .extend (cur_trade_shape )
1510+
1511+ cur_vertex = tread_index * 4
1512+ verts_to_add = (
1513+ (cur_vertex , cur_vertex + 1 ),
1514+ (cur_vertex + 1 , cur_vertex + 2 ),
1515+ (cur_vertex + 2 , cur_vertex + 3 ),
1516+ (cur_vertex + 3 , cur_vertex ),
1517+ )
1518+ edges .extend (verts_to_add )
1519+ tread_index += 1
1520+
14991521 cur_offset += tread_offset
15001522
15011523 elif stair_type == "GENERIC" :
0 commit comments