mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix wrong stair length calculation when having no custom first or last tread run
This commit is contained in:
@@ -1349,6 +1349,7 @@ class Model(bonsai.core.tool.Model):
|
|||||||
first_tread_run = props.custom_first_last_tread_run[0] / si_conversion
|
first_tread_run = props.custom_first_last_tread_run[0] / si_conversion
|
||||||
last_tread_run = props.custom_first_last_tread_run[1] / si_conversion
|
last_tread_run = props.custom_first_last_tread_run[1] / si_conversion
|
||||||
nosing_length = props.nosing_length / si_conversion
|
nosing_length = props.nosing_length / si_conversion
|
||||||
|
use_custom_first_last_tread_run = not props.custom_tread_lock
|
||||||
else:
|
else:
|
||||||
assert pset_data
|
assert pset_data
|
||||||
number_of_treads: int = pset_data["number_of_treads"]
|
number_of_treads: int = pset_data["number_of_treads"]
|
||||||
@@ -1360,29 +1361,23 @@ class Model(bonsai.core.tool.Model):
|
|||||||
)
|
)
|
||||||
first_tread_run, last_tread_run = custom_first_last_tread_run
|
first_tread_run, last_tread_run = custom_first_last_tread_run
|
||||||
nosing_length = pset_data.get("nosing_length", 0)
|
nosing_length = pset_data.get("nosing_length", 0)
|
||||||
|
use_custom_first_last_tread_run = not pset_data.get("custom_tread_lock", True)
|
||||||
|
|
||||||
calculated_params: dict[str, Any] = {}
|
calculated_params: dict[str, Any] = {}
|
||||||
number_of_rises = number_of_treads + 1
|
number_of_rises = number_of_treads + 1
|
||||||
calculated_params["Number of Risers"] = number_of_rises
|
calculated_params["Number of Risers"] = number_of_rises
|
||||||
calculated_params["Tread Rise"] = round(height / number_of_rises, 5)
|
calculated_params["Tread Rise"] = round(height / number_of_rises, 5)
|
||||||
|
|
||||||
# calculate stair length
|
# Calculate total length taking into account custom first/last tread runs :
|
||||||
# Start with all treads using default tread_run
|
|
||||||
n_default_tread_runs = number_of_rises
|
|
||||||
length = 0.0
|
length = 0.0
|
||||||
|
default_rises = number_of_rises
|
||||||
# If first tread has custom width (non-None), use it instead of default.
|
if use_custom_first_last_tread_run and first_tread_run is not None:
|
||||||
if first_tread_run is not None:
|
default_rises -= 1
|
||||||
n_default_tread_runs -= 1
|
|
||||||
length += first_tread_run
|
length += first_tread_run
|
||||||
|
if use_custom_first_last_tread_run and last_tread_run is not None:
|
||||||
# If last tread has custom width (non-None), use it instead of default
|
default_rises -= 1
|
||||||
if last_tread_run is not None:
|
|
||||||
n_default_tread_runs -= 1
|
|
||||||
length += last_tread_run
|
length += last_tread_run
|
||||||
|
length += tread_run * default_rises
|
||||||
# Add remaining default tread runs
|
|
||||||
length += tread_run * n_default_tread_runs
|
|
||||||
|
|
||||||
# Handle nosing length effects on total length
|
# Handle nosing length effects on total length
|
||||||
# Nosing overlaps don't affect tread run spacing,
|
# Nosing overlaps don't affect tread run spacing,
|
||||||
|
|||||||
Reference in New Issue
Block a user