mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Deprecate mode subscriptiosn of profiles and walls
This commit is contained in:
@@ -105,16 +105,16 @@ def active_material_index_callback(obj, data):
|
|||||||
refresh_ui_data()
|
refresh_ui_data()
|
||||||
|
|
||||||
|
|
||||||
def subscribe_to(object, data_path, callback):
|
def subscribe_to(obj, data_path, callback):
|
||||||
try:
|
try:
|
||||||
subscribe_to = object.path_resolve(data_path, False)
|
subscribe_to = obj.path_resolve(data_path, False)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
bpy.msgbus.subscribe_rna(
|
bpy.msgbus.subscribe_rna(
|
||||||
key=subscribe_to,
|
key=subscribe_to,
|
||||||
owner=object,
|
owner=obj,
|
||||||
args=(
|
args=(
|
||||||
object,
|
obj,
|
||||||
data_path,
|
data_path,
|
||||||
),
|
),
|
||||||
notify=callback,
|
notify=callback,
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ def load_post(*args):
|
|||||||
product.regenerate_profile_usage,
|
product.regenerate_profile_usage,
|
||||||
)
|
)
|
||||||
|
|
||||||
IfcStore.add_element_listener(wall.element_listener)
|
|
||||||
IfcStore.add_element_listener(profile.element_listener)
|
|
||||||
|
|
||||||
ifcopenshell.api.add_post_listener(
|
ifcopenshell.api.add_post_listener(
|
||||||
"geometry.add_representation", "BlenderBIM.DumbWall.CalculateQuantities", wall.calculate_quantities
|
"geometry.add_representation", "BlenderBIM.DumbWall.CalculateQuantities", wall.calculate_quantities
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,61 +35,6 @@ from blenderbim.bim.module.model.wall import DumbWallRecalculator
|
|||||||
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
||||||
|
|
||||||
|
|
||||||
def element_listener(element, obj):
|
|
||||||
blenderbim.bim.handler.subscribe_to(obj, "mode", mode_callback)
|
|
||||||
|
|
||||||
|
|
||||||
def mode_callback(obj, data):
|
|
||||||
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
|
|
||||||
if (
|
|
||||||
not obj.data
|
|
||||||
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
|
||||||
or not obj.BIMObjectProperties.ifc_definition_id
|
|
||||||
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
|
||||||
):
|
|
||||||
return
|
|
||||||
product = tool.Ifc.get().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
|
||||||
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
|
||||||
if not parametric or parametric["Engine"] != "BlenderBIM.DumbProfile":
|
|
||||||
return
|
|
||||||
if obj.mode == "EDIT":
|
|
||||||
tool.Ifc.edit(obj)
|
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
|
||||||
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
|
||||||
bmesh.update_edit_mesh(obj.data)
|
|
||||||
else:
|
|
||||||
material_usage = ifcopenshell.util.element.get_material(product)
|
|
||||||
x, y = obj.dimensions[0:2]
|
|
||||||
if not material_usage.CardinalPoint:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, y, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 1:
|
|
||||||
new_origin = obj.matrix_world @ Vector(obj.bound_box[4])
|
|
||||||
elif material_usage.CardinalPoint == 2:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, 0, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 3:
|
|
||||||
new_origin = obj.matrix_world @ Vector(obj.bound_box[0])
|
|
||||||
elif material_usage.CardinalPoint == 4:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[4]) + (Vector((0, y, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 5:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((x, y, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 6:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[0]) + (Vector((0, y, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 7:
|
|
||||||
new_origin = obj.matrix_world @ Vector(obj.bound_box[7])
|
|
||||||
elif material_usage.CardinalPoint == 8:
|
|
||||||
new_origin = obj.matrix_world @ (Vector(obj.bound_box[3]) + (Vector((x, 0, 0)) / 2))
|
|
||||||
elif material_usage.CardinalPoint == 9:
|
|
||||||
new_origin = obj.matrix_world @ Vector(obj.bound_box[3])
|
|
||||||
if (obj.matrix_world.translation - new_origin).length < 0.001:
|
|
||||||
return
|
|
||||||
obj.data.transform(
|
|
||||||
Matrix.Translation(
|
|
||||||
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
obj.matrix_world.translation = new_origin
|
|
||||||
|
|
||||||
|
|
||||||
class DumbProfileGenerator:
|
class DumbProfileGenerator:
|
||||||
def __init__(self, relating_type):
|
def __init__(self, relating_type):
|
||||||
self.relating_type = relating_type
|
self.relating_type = relating_type
|
||||||
|
|||||||
@@ -37,38 +37,6 @@ from mathutils import Vector, Matrix
|
|||||||
from blenderbim.bim.module.model.opening import FilledOpeningGenerator
|
from blenderbim.bim.module.model.opening import FilledOpeningGenerator
|
||||||
|
|
||||||
|
|
||||||
def element_listener(element, obj):
|
|
||||||
blenderbim.bim.handler.subscribe_to(obj, "mode", mode_callback)
|
|
||||||
|
|
||||||
|
|
||||||
def mode_callback(obj, data):
|
|
||||||
for obj in set(bpy.context.selected_objects + [bpy.context.active_object]):
|
|
||||||
if (
|
|
||||||
not obj.data
|
|
||||||
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
|
|
||||||
or not obj.BIMObjectProperties.ifc_definition_id
|
|
||||||
or not bpy.context.scene.BIMProjectProperties.is_authoring
|
|
||||||
):
|
|
||||||
return
|
|
||||||
product = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
|
|
||||||
parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric")
|
|
||||||
if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer2":
|
|
||||||
return
|
|
||||||
if obj.mode == "EDIT":
|
|
||||||
tool.Ifc.edit(obj)
|
|
||||||
bm = bmesh.from_edit_mesh(obj.data)
|
|
||||||
bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges)
|
|
||||||
bmesh.update_edit_mesh(obj.data)
|
|
||||||
else:
|
|
||||||
new_origin = obj.matrix_world @ Vector(obj.bound_box[0])
|
|
||||||
obj.data.transform(
|
|
||||||
Matrix.Translation(
|
|
||||||
(obj.matrix_world.inverted().to_quaternion() @ (obj.matrix_world.translation - new_origin))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
obj.matrix_world.translation = new_origin
|
|
||||||
|
|
||||||
|
|
||||||
class JoinWall(bpy.types.Operator, tool.Ifc.Operator):
|
class JoinWall(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.join_wall"
|
bl_idname = "bim.join_wall"
|
||||||
bl_label = "Join Wall"
|
bl_label = "Join Wall"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class StylesData:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {"style_types": cls.style_types(), "total_styles": cls.total_styles()}
|
cls.data = {"style_types": cls.style_types(), "total_styles": cls.total_styles()}
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def style_types(cls):
|
def style_types(cls):
|
||||||
@@ -56,6 +57,7 @@ class StyleAttributesData:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {"attributes": cls.get_attributes()}
|
cls.data = {"attributes": cls.get_attributes()}
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_attributes(cls):
|
def get_attributes(cls):
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ from blenderbim.bim.module.style.data import StylesData, StyleAttributesData
|
|||||||
from bl_ui.properties_material import MaterialButtonsPanel
|
from bl_ui.properties_material import MaterialButtonsPanel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_styles(Panel):
|
class BIM_PT_styles(Panel):
|
||||||
bl_label = "IFC Styles"
|
bl_label = "IFC Styles"
|
||||||
bl_idname = "BIM_PT_styles"
|
bl_idname = "BIM_PT_styles"
|
||||||
@@ -93,7 +91,7 @@ class BIM_PT_style(MaterialButtonsPanel, Panel):
|
|||||||
row.operator("bim.remove_style", icon="X", text="").style = props.ifc_style_id
|
row.operator("bim.remove_style", icon="X", text="").style = props.ifc_style_id
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(mat, "diffuse_color", text="Color")
|
row.prop(mat, "diffuse_color", text="Color")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
row.operator("bim.add_style", icon="ADD")
|
row.operator("bim.add_style", icon="ADD")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user