Pset_StairFlightCommon update

Added Pset_StairFlightCommon update to stair modifier
This commit is contained in:
Andrej730
2023-02-06 18:38:33 +05:00
parent e1456533f2
commit 4c1a821922
@@ -218,6 +218,40 @@ def update_stair_modifier(context):
obj.data.update() obj.data.update()
def update_ifc_stair_props(obj, psets):
element = tool.Ifc.get_entity(obj)
props = obj.BIMStairProperties
ifc_file = tool.Ifc.get()
number_of_risers = props.number_of_treads + 1
# update IfcStairFlight properties (seems already deprecated but keep it for now)
# http://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcStairFlight.htm
if element.is_a("IfcStairFlight"):
element.NumberOfRisers = number_of_risers
element.NumberOfTreads = props.number_of_treads
element.RiserHeight = props.height / number_of_risers
element.TreadLength = props.tread_depth
# update pset with ifc properties
pset_common = psets.get("Pset_StairFlightCommon", None)
if pset_common:
pset_common = ifc_file.by_id(pset_common["id"])
else:
pset_common = ifcopenshell.api.run("pset.add_pset", ifc_file, product=element, name="Pset_StairFlightCommon")
ifcopenshell.api.run(
"pset.edit_pset",
ifc_file,
pset=pset_common,
properties={
"NumberOfRiser": number_of_risers,
"NumberOfTreads": props.number_of_treads,
"RiserHeight": props.height / number_of_risers,
"TreadLength": props.tread_depth,
},
)
class BIM_OT_add_clever_stair(Operator): class BIM_OT_add_clever_stair(Operator):
bl_idname = "mesh.add_clever_stair" bl_idname = "mesh.add_clever_stair"
bl_label = "Clever Stair" bl_label = "Clever Stair"
@@ -268,6 +302,7 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator):
obj = context.active_object obj = context.active_object
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)
props = obj.BIMStairProperties props = obj.BIMStairProperties
ifc_file = tool.Ifc.get()
if element.is_a() not in ("IfcStairFlight", "IfcStairFlightType"): if element.is_a() not in ("IfcStairFlight", "IfcStairFlightType"):
self.report({"ERROR"}, "Object has to be IfcStairFlight/IfcStairFlightType to add a stair.") self.report({"ERROR"}, "Object has to be IfcStairFlight/IfcStairFlightType to add a stair.")
@@ -285,25 +320,18 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator):
pset = psets.get("BBIM_Stair", None) pset = psets.get("BBIM_Stair", None)
if pset: if pset:
pset = tool.Ifc.get().by_id(pset["id"]) pset = ifc_file.by_id(pset["id"])
else: else:
pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="BBIM_Stair") pset = ifcopenshell.api.run("pset.add_pset", ifc_file, product=element, name="BBIM_Stair")
ifcopenshell.api.run( ifcopenshell.api.run(
"pset.edit_pset", "pset.edit_pset",
tool.Ifc.get(), ifc_file,
pset=pset, pset=pset,
properties={"Data": json.dumps(stair_data)}, properties={"Data": json.dumps(stair_data)},
) )
update_stair_modifier(context) update_stair_modifier(context)
update_ifc_stair_props(obj, psets)
# update IfcStairFlight properties
if element.is_a("IfcStairFlight"):
element.NumberOfRisers = props.number_of_treads + 1
element.NumberOfTreads = props.number_of_treads
element.RiserHeight = props.height / element.NumberOfRisers
element.TreadLength = props.tread_depth
return {"FINISHED"}
class CancelEditingStair(bpy.types.Operator, tool.Ifc.Operator): class CancelEditingStair(bpy.types.Operator, tool.Ifc.Operator):
@@ -351,11 +379,7 @@ class FinishEditingStair(bpy.types.Operator, tool.Ifc.Operator):
# update IfcStairFlight properties # update IfcStairFlight properties
element.PredefinedType = "STRAIGHT" element.PredefinedType = "STRAIGHT"
if element.is_a("IfcStairFlight"): update_ifc_stair_props(obj, psets)
element.NumberOfRisers = props.number_of_treads + 1
element.NumberOfTreads = props.number_of_treads
element.RiserHeight = props.height / element.NumberOfRisers
element.TreadLength = props.tread_depth
return {"FINISHED"} return {"FINISHED"}