Skip to content

Commit

Permalink
rename connection to boundary condition + minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesusbill committed Mar 23, 2021
1 parent f706adf commit 5b1cc2c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
prop.StructuralAnalysisModel,
prop.BIMStructuralProperties,
prop.BIMObjectStructuralProperties,
ui.BIM_PT_structural,
ui.BIM_PT_structural_connections,
ui.BIM_PT_structural_analysis_models,
ui.BIM_PT_structural_boundary_conditions,
ui.BIM_UL_structural_analysis_models,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Usecase:
def __init__(self, file, settings=None):
def __init__(self, file, settings={}):
self.file = file
self.settings = {
"product": None,
Expand Down
7 changes: 4 additions & 3 deletions src/ifcblenderexport/blenderbim/bim/module/structural/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
class Data:
is_loaded = False
products = {}
boundary_conditions = {}
structural_analysis_models = {}

@classmethod
def purge(cls):
cls.is_loaded = False
cls.products = {}
cls.connections = {}
cls.boundary_conditions = {}
cls.structural_analysis_models = {}

@classmethod
def load(cls, product_id=None):
if product_id:
cls.connections = {}
cls.boundary_conditions = {}
return cls.load_structural_connection(product_id)
cls.products = {}
cls.structural_analysis_models = {}
Expand Down Expand Up @@ -57,4 +58,4 @@ def load_structural_connection(cls, product_id):
data[key] = value.wrappedValue
else:
data = {}
cls.connections[connection.id()] = data
cls.boundary_conditions[connection.id()] = data
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Usecase:
def __init__(self, file, settings=None):
def __init__(self, file, settings={}):
self.file = file
self.settings = {
"structural_analysis_model": None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Usecase:
def __init__(self, file, settings=None):
def __init__(self, file, settings={}):
self.file = file
self.settings = {
"condition": None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def execute(self, context):
obj = context.active_object
oprops = obj.BIMObjectProperties
props = obj.BIMStructuralProperties
while len(props.connection_attributes) > 0:
props.connection_attributes.remove(0)
while len(props.boundary_condition_attributes) > 0:
props.boundary_condition_attributes.remove(0)

data = Data.connections[oprops.ifc_definition_id]
data = Data.boundary_conditions[oprops.ifc_definition_id]

for attribute in IfcStore.get_schema().declaration_by_name(data["type"]).all_attributes():
value = data[attribute.name()]
data_type = str(attribute.type_of_attribute)
new = props.connection_attributes.add()
new = props.boundary_condition_attributes.add()
new.name = attribute.name()
new.is_null = value is None
new.is_optional = attribute.optional()
Expand All @@ -73,7 +73,7 @@ def execute(self, context):
new.string_value = "" if new.is_null else data[attribute.name()]
new.data_type = "string"

props.is_editing_connection = True
props.is_editing_boundary_condition = True
return {"FINISHED"}


Expand All @@ -91,7 +91,7 @@ def execute(self, context):
condition = connection.AppliedCondition

attributes = {}
for attribute in props.connection_attributes:
for attribute in props.boundary_condition_attributes:
if attribute.is_null:
attributes[attribute.name] = {"value": None, "type": "null"}
elif attribute.data_type == "string":
Expand All @@ -112,7 +112,7 @@ class DisableEditingStructuralBoundaryCondition(bpy.types.Operator):
bl_label = "Disable Editing Structural Boundary Condition"

def execute(self, context):
context.active_object.BIMStructuralProperties.is_editing_connection = False
context.active_object.BIMStructuralProperties.is_editing_boundary_condition = False
return {"FINISHED"}


Expand Down
4 changes: 2 additions & 2 deletions src/ifcblenderexport/blenderbim/bim/module/structural/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class BIMStructuralProperties(PropertyGroup):


class BIMObjectStructuralProperties(PropertyGroup):
connection_attributes: CollectionProperty(name="Connection Attributes", type=Attribute)
is_editing_connection: BoolProperty(name="Is Editing Connection", default=False)
boundary_condition_attributes: CollectionProperty(name="Boundary Condition Attributes", type=Attribute)
is_editing_boundary_condition: BoolProperty(name="Is Editing Boundary Condition", default=False)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Usecase:
def __init__(self, file, settings=None):
def __init__(self, file, settings={}):
self.file = file
self.settings = {"structural_analysis_model": None}
for key, value in settings.items():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Usecase:
def __init__(self, file, settings=None):
def __init__(self, file, settings={}):
self.file = file
self.settings = {"connection": None}
for key, value in settings.items():
Expand Down
22 changes: 11 additions & 11 deletions src/ifcblenderexport/blenderbim/bim/module/structural/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from blenderbim.bim.module.structural.data import Data


class BIM_PT_structural_connections(Panel):
bl_label = "IFC Structural Connections"
bl_idname = "BIM_PT_structural_connections"
class BIM_PT_structural_boundary_conditions(Panel):
bl_label = "IFC Structural Boundary Conditions"
bl_idname = "BIM_PT_structural_boundary_conditions"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
Expand All @@ -25,25 +25,25 @@ def poll(cls, context):
def draw(self, context):
self.oprops = context.active_object.BIMObjectProperties
self.props = context.active_object.BIMStructuralProperties
if self.oprops.ifc_definition_id not in Data.connections:
if self.oprops.ifc_definition_id not in Data.boundary_conditions:
Data.load(self.oprops.ifc_definition_id)

self.data = Data.connections[self.oprops.ifc_definition_id]
self.data = Data.boundary_conditions[self.oprops.ifc_definition_id]

row = self.layout.row(align=True)
if self.data and self.props.is_editing_connection:
if self.data and self.props.is_editing_boundary_condition:
row.label(text=self.data["type"], icon="CON_TRACKTO")
row.operator("bim.edit_structural_boundary_condition", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_structural_boundary_condition", text="", icon="X")
elif self.data and not self.props.is_editing_connection:
elif self.data and not self.props.is_editing_boundary_condition:
row.label(text=self.data["type"], icon="CON_TRACKTO")
row.operator("bim.enable_editing_structural_boundary_condition", text="", icon="GREASEPENCIL")
row.operator("bim.remove_structural_boundary_condition", text="", icon="X")
else:
row.label(text="No Connection Found", icon="CON_TRACKTO")
row.label(text="No Boundary Condition Found", icon="CON_TRACKTO")
row.operator("bim.add_structural_boundary_condition", text="", icon="ADD")

if self.props.is_editing_connection:
if self.props.is_editing_boundary_condition:
self.draw_editable_ui(context)
else:
self.draw_read_only_ui(context)
Expand Down Expand Up @@ -75,9 +75,9 @@ def draw_read_only_ui(self, context):
row.label(text=str(value))


class BIM_PT_structural(Panel):
class BIM_PT_structural_analysis_models(Panel):
bl_label = "IFC Structural Analysis Models"
bl_idname = "BIM_PT_structural"
bl_idname = "BIM_PT_structural_analysis_models"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
Expand Down

0 comments on commit 5b1cc2c

Please sign in to comment.