Improve command handling in drawing tool to skip None values

This commit is contained in:
falken10vdl
2025-12-17 12:22:58 +01:00
parent 5dab742623
commit 53115e0654
2 changed files with 11 additions and 2 deletions
@@ -2093,5 +2093,6 @@ class DecorationsHandler:
if not DecoratorData.is_loaded:
DecoratorData.load(self)
for obj, decorator in DecoratorData.data["object_decorators"]:
object_decorators = DecoratorData.data.get("object_decorators", [])
for obj, decorator in object_decorators:
decorator.decorate(context, obj)
+9 -1
View File
@@ -2123,7 +2123,15 @@ class Drawing(bonsai.core.tool.Drawing):
value = ifcopenshell.util.selector.get_element_value(product, variable[2:-2])
value = '"' + str(value).replace('"', '\\"') + '"'
command = command.replace(variable, value)
text = text.replace(original_command, ifcopenshell.util.selector.format(command[2:-2]))
# Defensive: skip if command[2:-2] is None or 'None'
command_content = command[2:-2]
if command_content is None or str(command_content).strip().lower() == 'none':
text = text.replace(original_command, "")
else:
try:
text = text.replace(original_command, ifcopenshell.util.selector.format(command_content))
except Exception:
text = text.replace(original_command, "")
for variable in re.findall("{{.*?}}", text):
value = ifcopenshell.util.selector.get_element_value(product, variable[2:-2])
if isinstance(value, (list, tuple)):