mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Fix #1923. Fix bug where creating a new structural analysis model broke.
This commit is contained in:
@@ -21,6 +21,8 @@ import json
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import blenderbim.bim.helper
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.core.context
|
||||
from math import degrees
|
||||
from mathutils import Vector, Matrix
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
@@ -269,15 +271,16 @@ class AddStructuralAnalysisModel(bpy.types.Operator):
|
||||
def _execute(self, context):
|
||||
result = ifcopenshell.api.run("structural.add_structural_analysis_model", IfcStore.get_file())
|
||||
|
||||
has_context = False
|
||||
ContextData.load(IfcStore.get_file())
|
||||
for context in ContextData.contexts.values():
|
||||
if context["ContextType"] == "Model":
|
||||
for subcontext in context["HasSubContexts"].values():
|
||||
if subcontext["ContextIdentifier"] == "Reference" and subcontext["TargetView"] == "GRAPH_VIEW":
|
||||
has_context = True
|
||||
if not has_context:
|
||||
bpy.ops.bim.add_subcontext(context="Model", subcontext="Reference", target_view="GRAPH_VIEW")
|
||||
model = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model")
|
||||
if not model:
|
||||
model = blenderbim.core.context.add_context(
|
||||
tool.Ifc, context_type="Model", context_identifier="", target_view="", parent=0
|
||||
)
|
||||
graph = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Reference", "GRAPH_VIEW")
|
||||
if not graph:
|
||||
model = blenderbim.core.context.add_context(
|
||||
tool.Ifc, context_type="Model", context_identifier="Reference", target_view="GRAPH_VIEW", parent=model
|
||||
)
|
||||
|
||||
Data.load(IfcStore.get_file())
|
||||
bpy.ops.bim.load_structural_analysis_models()
|
||||
|
||||
@@ -154,7 +154,7 @@ class BIM_PT_connected_structural_members(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=f"To Member #{IfcStore.get_file().by_id(rel['RelatingStructuralMember']).Name}")
|
||||
if self.props.active_connects_structural_member and self.props.active_connects_structural_member == rel_id:
|
||||
row.operator("bim.disable_editing_structural_connection_condition", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_structural_connection_condition", text="", icon="CANCEL")
|
||||
row.enabled = self.props.active_boundary_condition != rel["AppliedCondition"]
|
||||
self.draw_editable_ui(context, self.layout, rel)
|
||||
elif self.props.active_connects_structural_member:
|
||||
@@ -294,7 +294,7 @@ class BIM_PT_structural_analysis_models(Panel):
|
||||
)
|
||||
if self.props.is_editing:
|
||||
row.operator("bim.add_structural_analysis_model", text="", icon="ADD")
|
||||
row.operator("bim.disable_structural_analysis_model_editing_ui", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_structural_analysis_model_editing_ui", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.load_structural_analysis_models", text="", icon="GREASEPENCIL")
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ markers =
|
||||
root
|
||||
sequence
|
||||
spatial
|
||||
structural
|
||||
style
|
||||
type
|
||||
unit
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@root
|
||||
Feature: Root
|
||||
Covers IFC class operations on Blender objects
|
||||
|
||||
Scenario: Reassign class
|
||||
Given an empty IFC project
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
@structural
|
||||
Feature: Structural
|
||||
|
||||
Scenario: Load structural analysis models
|
||||
Given an empty IFC project
|
||||
When I press "bim.load_structural_analysis_models"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add structural analysis model
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_structural_analysis_models"
|
||||
When I press "bim.add_structural_analysis_model"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Disable structural analysis model editing UI
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_structural_analysis_models"
|
||||
When I press "bim.disable_structural_analysis_model_editing_ui"
|
||||
Then nothing happens
|
||||
Reference in New Issue
Block a user