mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Window Modifier - support typing units in props
Example - https://i.imgur.com/C99RRs9.png
This commit is contained in:
@@ -225,21 +225,13 @@ class BIMStairProperties(PropertyGroup):
|
|||||||
if not convert_to_project_units:
|
if not convert_to_project_units:
|
||||||
return stair_kwargs
|
return stair_kwargs
|
||||||
|
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
stair_kwargs = tool.Model.convert_data_to_project_units(stair_kwargs, self.non_si_units_props)
|
||||||
for prop_name in stair_kwargs:
|
|
||||||
if prop_name in self.non_si_units_props:
|
|
||||||
continue
|
|
||||||
prop_value = stair_kwargs[prop_name]
|
|
||||||
stair_kwargs[prop_name] = prop_value / si_conversion
|
|
||||||
return stair_kwargs
|
return stair_kwargs
|
||||||
|
|
||||||
def set_props_kwargs_from_ifc_data(self, kwargs):
|
def set_props_kwargs_from_ifc_data(self, kwargs):
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
kwargs = tool.Model.convert_data_to_si_units(kwargs, self.non_si_units_props)
|
||||||
for prop_name in kwargs:
|
for prop_name in kwargs:
|
||||||
prop_value = kwargs[prop_name]
|
setattr(self, prop_name, kwargs[prop_name])
|
||||||
if prop_name not in self.non_si_units_props:
|
|
||||||
prop_value = prop_value * si_conversion
|
|
||||||
setattr(self, prop_name, prop_value)
|
|
||||||
|
|
||||||
|
|
||||||
class BIMSverchokProperties(PropertyGroup):
|
class BIMSverchokProperties(PropertyGroup):
|
||||||
@@ -248,15 +240,13 @@ class BIMSverchokProperties(PropertyGroup):
|
|||||||
|
|
||||||
def window_type_prop_update(self, context):
|
def window_type_prop_update(self, context):
|
||||||
number_of_panels, panels_data = self.window_types_panels[self.window_type]
|
number_of_panels, panels_data = self.window_types_panels[self.window_type]
|
||||||
|
|
||||||
si_coversion = 1.0 / ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
|
||||||
panels_data = [[v * si_coversion for v in data] for data in panels_data]
|
|
||||||
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
|
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
|
||||||
self.first_transom_offset, self.second_transom_offset = panels_data[1]
|
self.first_transom_offset, self.second_transom_offset = panels_data[1]
|
||||||
|
|
||||||
|
|
||||||
# default prop values are in mm and converted later
|
# default prop values are in mm and converted later
|
||||||
class BIMWindowProperties(PropertyGroup):
|
class BIMWindowProperties(PropertyGroup):
|
||||||
|
non_si_units_props = ("is_editing", "window_type", "window_added_previously")
|
||||||
window_types = (
|
window_types = (
|
||||||
("SINGLE_PANEL", "SINGLE_PANEL", ""),
|
("SINGLE_PANEL", "SINGLE_PANEL", ""),
|
||||||
("DOUBLE_PANEL_HORIZONTAL", "DOUBLE_PANEL_HORIZONTAL", ""),
|
("DOUBLE_PANEL_HORIZONTAL", "DOUBLE_PANEL_HORIZONTAL", ""),
|
||||||
@@ -289,50 +279,63 @@ class BIMWindowProperties(PropertyGroup):
|
|||||||
window_type: bpy.props.EnumProperty(
|
window_type: bpy.props.EnumProperty(
|
||||||
name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update
|
name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update
|
||||||
)
|
)
|
||||||
overall_height: bpy.props.FloatProperty(name="Overall Height", default=0.9)
|
overall_height: bpy.props.FloatProperty(name="Overall Height", default=0.9, subtype="DISTANCE")
|
||||||
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.6)
|
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.6, subtype="DISTANCE")
|
||||||
|
|
||||||
# lining properties
|
# lining properties
|
||||||
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=0.050)
|
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=0.050, subtype="DISTANCE")
|
||||||
lining_thickness: bpy.props.FloatProperty(name="Lining Thickness", default=0.050)
|
lining_thickness: bpy.props.FloatProperty(name="Lining Thickness", default=0.050, subtype="DISTANCE")
|
||||||
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=0.050)
|
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=0.050, subtype="DISTANCE")
|
||||||
lining_to_panel_offset_x: bpy.props.FloatProperty(name="Lining to Panel Offset X", default=0.025)
|
lining_to_panel_offset_x: bpy.props.FloatProperty(
|
||||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=0.025)
|
name="Lining to Panel Offset X", default=0.025, subtype="DISTANCE"
|
||||||
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=0.050)
|
)
|
||||||
|
lining_to_panel_offset_y: bpy.props.FloatProperty(
|
||||||
|
name="Lining to Panel Offset Y", default=0.025, subtype="DISTANCE"
|
||||||
|
)
|
||||||
|
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=0.050, subtype="DISTANCE")
|
||||||
first_mullion_offset: bpy.props.FloatProperty(
|
first_mullion_offset: bpy.props.FloatProperty(
|
||||||
name="First Mullion Offset",
|
name="First Mullion Offset",
|
||||||
description="Distance from the first lining to the first mullion center",
|
description="Distance from the first lining to the first mullion center",
|
||||||
default=0.3,
|
default=0.3,
|
||||||
|
subtype="DISTANCE",
|
||||||
)
|
)
|
||||||
second_mullion_offset: bpy.props.FloatProperty(
|
second_mullion_offset: bpy.props.FloatProperty(
|
||||||
name="Second Mullion Offset",
|
name="Second Mullion Offset",
|
||||||
description="Distance from the first lining to the second mullion center",
|
description="Distance from the first lining to the second mullion center",
|
||||||
default=0.45,
|
default=0.45,
|
||||||
|
subtype="DISTANCE",
|
||||||
)
|
)
|
||||||
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=0.050)
|
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=0.050, subtype="DISTANCE")
|
||||||
first_transom_offset: bpy.props.FloatProperty(
|
first_transom_offset: bpy.props.FloatProperty(
|
||||||
name="First Transom Offset",
|
name="First Transom Offset",
|
||||||
description="Distance from the first lining to the first transom center",
|
description="Distance from the first lining to the first transom center",
|
||||||
default=0.3,
|
default=0.3,
|
||||||
|
subtype="DISTANCE",
|
||||||
)
|
)
|
||||||
second_transom_offset: bpy.props.FloatProperty(
|
second_transom_offset: bpy.props.FloatProperty(
|
||||||
name="Second Transom Offset",
|
name="Second Transom Offset",
|
||||||
description="Distance from the first lining to the second transom center",
|
description="Distance from the first lining to the second transom center",
|
||||||
default=0.6,
|
default=0.6,
|
||||||
|
subtype="DISTANCE",
|
||||||
)
|
)
|
||||||
|
|
||||||
# panel properties
|
# panel properties
|
||||||
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[0.035] * 3)
|
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[0.035] * 3, subtype="TRANSLATION")
|
||||||
frame_thickness: bpy.props.FloatVectorProperty(name="Frame Thickness", size=3, default=[0.035] * 3)
|
frame_thickness: bpy.props.FloatVectorProperty(
|
||||||
|
name="Frame Thickness", size=3, default=[0.035] * 3, subtype="TRANSLATION"
|
||||||
|
)
|
||||||
|
|
||||||
def get_general_kwargs(self):
|
def get_general_kwargs(self, convert_to_project_units=False):
|
||||||
return {
|
kwargs = {
|
||||||
"window_type": self.window_type,
|
"window_type": self.window_type,
|
||||||
"overall_height": self.overall_height,
|
"overall_height": self.overall_height,
|
||||||
"overall_width": self.overall_width,
|
"overall_width": self.overall_width,
|
||||||
}
|
}
|
||||||
|
if not convert_to_project_units:
|
||||||
|
return kwargs
|
||||||
|
return tool.Model.convert_data_to_project_units(kwargs, ["window_type"])
|
||||||
|
|
||||||
def get_lining_kwargs(self):
|
def get_lining_kwargs(self, convert_to_project_units=False):
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"lining_depth": self.lining_depth,
|
"lining_depth": self.lining_depth,
|
||||||
"lining_thickness": self.lining_thickness,
|
"lining_thickness": self.lining_thickness,
|
||||||
@@ -369,13 +372,23 @@ class BIMWindowProperties(PropertyGroup):
|
|||||||
if self.window_type in ("TRIPLE_PANEL_HORIZONTAL",):
|
if self.window_type in ("TRIPLE_PANEL_HORIZONTAL",):
|
||||||
kwargs["second_transom_offset"] = self.second_transom_offset
|
kwargs["second_transom_offset"] = self.second_transom_offset
|
||||||
|
|
||||||
return kwargs
|
if not convert_to_project_units:
|
||||||
|
return kwargs
|
||||||
|
return tool.Model.convert_data_to_project_units(kwargs)
|
||||||
|
|
||||||
def get_panel_kwargs(self):
|
def get_panel_kwargs(self, convert_to_project_units=False):
|
||||||
return {
|
kwargs = {
|
||||||
"frame_depth": self.frame_depth,
|
"frame_depth": self.frame_depth,
|
||||||
"frame_thickness": self.frame_thickness,
|
"frame_thickness": self.frame_thickness,
|
||||||
}
|
}
|
||||||
|
if not convert_to_project_units:
|
||||||
|
return kwargs
|
||||||
|
return tool.Model.convert_data_to_project_units(kwargs)
|
||||||
|
|
||||||
|
def set_props_kwargs_from_ifc_data(self, kwargs):
|
||||||
|
kwargs = tool.Model.convert_data_to_si_units(kwargs, self.non_si_units_props)
|
||||||
|
for prop_name in kwargs:
|
||||||
|
setattr(self, prop_name, kwargs[prop_name])
|
||||||
|
|
||||||
|
|
||||||
class BIMDoorProperties(PropertyGroup):
|
class BIMDoorProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Operator
|
from bpy.types import Operator
|
||||||
from bpy.props import FloatProperty, IntProperty, BoolProperty
|
from bpy.props import FloatProperty, IntProperty
|
||||||
from bpy_extras.object_utils import AddObjectHelper, object_data_add
|
from bpy_extras.object_utils import AddObjectHelper, object_data_add
|
||||||
|
|
||||||
import bmesh
|
import bmesh
|
||||||
@@ -28,7 +28,6 @@ import ifcopenshell
|
|||||||
from ifcopenshell.util.shape_builder import V, ShapeBuilder
|
from ifcopenshell.util.shape_builder import V, ShapeBuilder
|
||||||
import blenderbim
|
import blenderbim
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.helper import convert_property_group_from_si
|
|
||||||
|
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ import blenderbim.core.root
|
|||||||
import blenderbim.core.geometry
|
import blenderbim.core.geometry
|
||||||
from ifcopenshell.api.geometry.add_window_representation import DEFAULT_PANEL_SCHEMAS
|
from ifcopenshell.api.geometry.add_window_representation import DEFAULT_PANEL_SCHEMAS
|
||||||
from ifcopenshell.util.shape_builder import V
|
from ifcopenshell.util.shape_builder import V
|
||||||
from bpy.types import Operator
|
|
||||||
from bpy.props import FloatProperty, IntProperty, BoolProperty
|
|
||||||
from bmesh.types import BMVert
|
from bmesh.types import BMVert
|
||||||
from blenderbim.bim.helper import convert_property_group_from_si
|
|
||||||
from blenderbim.bim.ifc import IfcStore
|
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
|
|
||||||
|
|
||||||
@@ -105,31 +101,32 @@ def update_window_modifier_representation(context):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
|
||||||
|
|
||||||
representation_data = {
|
representation_data = {
|
||||||
"partition_type": props.window_type,
|
"partition_type": props.window_type,
|
||||||
"overall_height": props.overall_height,
|
"overall_height": props.overall_height / si_conversion,
|
||||||
"overall_width": props.overall_width,
|
"overall_width": props.overall_width / si_conversion,
|
||||||
"lining_properties": {
|
"lining_properties": {
|
||||||
"LiningDepth": props.lining_depth,
|
"LiningDepth": props.lining_depth / si_conversion,
|
||||||
"LiningThickness": props.lining_thickness,
|
"LiningThickness": props.lining_thickness / si_conversion,
|
||||||
"LiningOffset": props.lining_offset,
|
"LiningOffset": props.lining_offset / si_conversion,
|
||||||
"LiningToPanelOffsetX": props.lining_to_panel_offset_x,
|
"LiningToPanelOffsetX": props.lining_to_panel_offset_x / si_conversion,
|
||||||
"LiningToPanelOffsetY": props.lining_to_panel_offset_y,
|
"LiningToPanelOffsetY": props.lining_to_panel_offset_y / si_conversion,
|
||||||
"MullionThickness": props.mullion_thickness,
|
"MullionThickness": props.mullion_thickness / si_conversion,
|
||||||
"FirstMullionOffset": props.first_mullion_offset,
|
"FirstMullionOffset": props.first_mullion_offset / si_conversion,
|
||||||
"SecondMullionOffset": props.second_mullion_offset,
|
"SecondMullionOffset": props.second_mullion_offset / si_conversion,
|
||||||
"TransomThickness": props.transom_thickness,
|
"TransomThickness": props.transom_thickness / si_conversion,
|
||||||
"FirstTransomOffset": props.first_transom_offset,
|
"FirstTransomOffset": props.first_transom_offset / si_conversion,
|
||||||
"SecondTransomOffset": props.second_transom_offset,
|
"SecondTransomOffset": props.second_transom_offset / si_conversion,
|
||||||
},
|
},
|
||||||
"panel_properties": [],
|
"panel_properties": [],
|
||||||
}
|
}
|
||||||
number_of_panels, panels_data = props.window_types_panels[props.window_type]
|
number_of_panels, panels_data = props.window_types_panels[props.window_type]
|
||||||
for panel_i in range(number_of_panels):
|
for panel_i in range(number_of_panels):
|
||||||
panel_data = {
|
panel_data = {
|
||||||
"FrameDepth": props.frame_depth[panel_i],
|
"FrameDepth": props.frame_depth[panel_i] / si_conversion,
|
||||||
"FrameThickness": props.frame_thickness[panel_i],
|
"FrameThickness": props.frame_thickness[panel_i] / si_conversion,
|
||||||
}
|
}
|
||||||
representation_data["panel_properties"].append(panel_data)
|
representation_data["panel_properties"].append(panel_data)
|
||||||
|
|
||||||
@@ -175,10 +172,10 @@ def update_window_modifier_representation(context):
|
|||||||
# occurences attributes
|
# occurences attributes
|
||||||
occurences = tool.Ifc.get_all_element_occurences(element)
|
occurences = tool.Ifc.get_all_element_occurences(element)
|
||||||
for occurence in occurences:
|
for occurence in occurences:
|
||||||
occurence.OverallWidth = props.overall_width
|
occurence.OverallWidth = props.overall_width / si_conversion
|
||||||
occurence.OverallHeight = props.overall_height
|
occurence.OverallHeight = props.overall_height / si_conversion
|
||||||
|
|
||||||
update_simple_openings(element, props.overall_width, props.overall_height)
|
update_simple_openings(element, props.overall_width / si_conversion, props.overall_height / si_conversion)
|
||||||
|
|
||||||
|
|
||||||
def create_bm_window_frame(bm, size: Vector, thickness: list, position: Vector = V(0, 0, 0).freeze()):
|
def create_bm_window_frame(bm, size: Vector, thickness: list, position: Vector = V(0, 0, 0).freeze()):
|
||||||
@@ -291,27 +288,26 @@ def create_bm_window(
|
|||||||
def update_window_modifier_bmesh(context):
|
def update_window_modifier_bmesh(context):
|
||||||
obj = context.object
|
obj = context.object
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
|
||||||
panel_schema = DEFAULT_PANEL_SCHEMAS[props.window_type]
|
panel_schema = DEFAULT_PANEL_SCHEMAS[props.window_type]
|
||||||
accumulated_height = [0] * len(panel_schema[0])
|
accumulated_height = [0] * len(panel_schema[0])
|
||||||
built_panels = []
|
built_panels = []
|
||||||
|
|
||||||
overall_width = props.overall_width * si_conversion
|
overall_width = props.overall_width
|
||||||
lining_depth = props.lining_depth * si_conversion
|
lining_depth = props.lining_depth
|
||||||
overall_height = props.overall_height * si_conversion
|
overall_height = props.overall_height
|
||||||
lining_to_panel_offset_x = props.lining_to_panel_offset_x * si_conversion
|
lining_to_panel_offset_x = props.lining_to_panel_offset_x
|
||||||
lining_to_panel_offset_y = props.lining_to_panel_offset_y * si_conversion
|
lining_to_panel_offset_y = props.lining_to_panel_offset_y
|
||||||
lining_thickness = props.lining_thickness * si_conversion
|
lining_thickness = props.lining_thickness
|
||||||
lining_offset = props.lining_offset * si_conversion
|
lining_offset = props.lining_offset
|
||||||
|
|
||||||
mullion_thickness = props.mullion_thickness * si_conversion / 2
|
mullion_thickness = props.mullion_thickness / 2
|
||||||
first_mullion_offset = props.first_mullion_offset * si_conversion
|
first_mullion_offset = props.first_mullion_offset
|
||||||
second_mullion_offset = props.second_mullion_offset * si_conversion
|
second_mullion_offset = props.second_mullion_offset
|
||||||
transom_thickness = props.transom_thickness * si_conversion / 2
|
transom_thickness = props.transom_thickness / 2
|
||||||
first_transom_offset = props.first_transom_offset * si_conversion
|
first_transom_offset = props.first_transom_offset
|
||||||
second_transom_offset = props.second_transom_offset * si_conversion
|
second_transom_offset = props.second_transom_offset
|
||||||
|
|
||||||
glass_thickness = 0.01 * si_conversion
|
glass_thickness = 0.01
|
||||||
|
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
panel_schema = list(reversed(panel_schema))
|
panel_schema = list(reversed(panel_schema))
|
||||||
@@ -349,8 +345,8 @@ def update_window_modifier_bmesh(context):
|
|||||||
accumulated_width += panel_width
|
accumulated_width += panel_width
|
||||||
continue
|
continue
|
||||||
|
|
||||||
frame_depth = props.frame_depth[panel_i] * si_conversion
|
frame_depth = props.frame_depth[panel_i]
|
||||||
frame_thickness = props.frame_thickness[panel_i] * si_conversion
|
frame_thickness = props.frame_thickness[panel_i]
|
||||||
|
|
||||||
# add window
|
# add window
|
||||||
window_lining_size = V(
|
window_lining_size = V(
|
||||||
@@ -456,13 +452,9 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a window.")
|
self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a window.")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
# need to make sure all default props will have correct units
|
window_data = props.get_general_kwargs(convert_to_project_units=True)
|
||||||
if not props.window_added_previously:
|
lining_props = props.get_lining_kwargs(convert_to_project_units=True)
|
||||||
convert_property_group_from_si(props, skip_props=("is_editing", "window_type", "window_added_previously"))
|
panel_props = props.get_panel_kwargs(convert_to_project_units=True)
|
||||||
|
|
||||||
window_data = props.get_general_kwargs()
|
|
||||||
lining_props = props.get_lining_kwargs()
|
|
||||||
panel_props = props.get_panel_kwargs()
|
|
||||||
|
|
||||||
window_data["lining_properties"] = lining_props
|
window_data["lining_properties"] = lining_props
|
||||||
window_data["panel_properties"] = panel_props
|
window_data["panel_properties"] = panel_props
|
||||||
@@ -490,8 +482,7 @@ class CancelEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Window", "Data"))
|
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Window", "Data"))
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
for prop_name in data:
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
setattr(props, prop_name, data[prop_name])
|
|
||||||
|
|
||||||
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
blenderbim.core.geometry.switch_representation(
|
blenderbim.core.geometry.switch_representation(
|
||||||
@@ -518,9 +509,9 @@ class FinishEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMWindowProperties
|
props = obj.BIMWindowProperties
|
||||||
|
|
||||||
window_data = props.get_general_kwargs()
|
window_data = props.get_general_kwargs(convert_to_project_units=True)
|
||||||
lining_props = props.get_lining_kwargs()
|
lining_props = props.get_lining_kwargs(convert_to_project_units=True)
|
||||||
panel_props = props.get_panel_kwargs()
|
panel_props = props.get_panel_kwargs(convert_to_project_units=True)
|
||||||
|
|
||||||
window_data["lining_properties"] = lining_props
|
window_data["lining_properties"] = lining_props
|
||||||
window_data["panel_properties"] = panel_props
|
window_data["panel_properties"] = panel_props
|
||||||
@@ -549,14 +540,7 @@ class EnableEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
data.update(data.pop("panel_properties"))
|
data.update(data.pop("panel_properties"))
|
||||||
|
|
||||||
# required since we could load pset from .ifc and BIMWindowProperties won't be set
|
# required since we could load pset from .ifc and BIMWindowProperties won't be set
|
||||||
for prop_name in data:
|
props.set_props_kwargs_from_ifc_data(data)
|
||||||
setattr(props, prop_name, data[prop_name])
|
|
||||||
|
|
||||||
# need to make sure all props that weren't used before
|
|
||||||
# will have correct units
|
|
||||||
skip_props = ("is_editing", "window_type", "window_added_previously")
|
|
||||||
skip_props += tuple(data.keys())
|
|
||||||
convert_property_group_from_si(props, skip_props=skip_props)
|
|
||||||
|
|
||||||
props.is_editing = 1
|
props.is_editing = 1
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import blenderbim.core.geometry as geometry
|
|||||||
from mathutils import Matrix, Vector
|
from mathutils import Matrix, Vector
|
||||||
from blenderbim.bim import import_ifc
|
from blenderbim.bim import import_ifc
|
||||||
from blenderbim.bim.module.geometry.helper import Helper
|
from blenderbim.bim.module.geometry.helper import Helper
|
||||||
|
import collections
|
||||||
|
|
||||||
|
|
||||||
class Model(blenderbim.core.tool.Model):
|
class Model(blenderbim.core.tool.Model):
|
||||||
@@ -43,6 +44,33 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
return [v * cls.unit_scale for v in value]
|
return [v * cls.unit_scale for v in value]
|
||||||
return value * cls.unit_scale
|
return value * cls.unit_scale
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert_data_to_project_units(cls, data, non_si_props=[]):
|
||||||
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
for prop_name in data:
|
||||||
|
if prop_name in non_si_props:
|
||||||
|
continue
|
||||||
|
prop_value = data[prop_name]
|
||||||
|
if isinstance(prop_value, collections.abc.Iterable):
|
||||||
|
data[prop_name] = [v / si_conversion for v in prop_value]
|
||||||
|
else:
|
||||||
|
data[prop_name] = prop_value / si_conversion
|
||||||
|
return data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert_data_to_si_units(cls, data, non_si_props=[]):
|
||||||
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
for prop_name in data:
|
||||||
|
if prop_name in non_si_props:
|
||||||
|
continue
|
||||||
|
prop_value = data[prop_name]
|
||||||
|
print(prop_name, prop_value)
|
||||||
|
if isinstance(prop_value, collections.abc.Iterable):
|
||||||
|
data[prop_name] = [v * si_conversion for v in prop_value]
|
||||||
|
else:
|
||||||
|
data[prop_name] = prop_value * si_conversion
|
||||||
|
return data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export_curve(cls, position, edge_indices, points=None):
|
def export_curve(cls, position, edge_indices, points=None):
|
||||||
position_i = position.inverted()
|
position_i = position.inverted()
|
||||||
@@ -147,11 +175,13 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
cls.bm.edges.ensure_lookup_table()
|
cls.bm.edges.ensure_lookup_table()
|
||||||
|
|
||||||
surface = tool.Ifc.get().createIfcCurveBoundedPlane()
|
surface = tool.Ifc.get().createIfcCurveBoundedPlane()
|
||||||
surface.BasisSurface = tool.Ifc.get().createIfcPlane(tool.Ifc.get().createIfcAxis2Placement3D(
|
surface.BasisSurface = tool.Ifc.get().createIfcPlane(
|
||||||
tool.Ifc.get().createIfcCartesianPoint([o / cls.unit_scale for o in p1]),
|
tool.Ifc.get().createIfcAxis2Placement3D(
|
||||||
tool.Ifc.get().createIfcDirection([float(o) for o in z_axis]),
|
tool.Ifc.get().createIfcCartesianPoint([o / cls.unit_scale for o in p1]),
|
||||||
tool.Ifc.get().createIfcDirection([float(o) for o in x_axis]),
|
tool.Ifc.get().createIfcDirection([float(o) for o in z_axis]),
|
||||||
))
|
tool.Ifc.get().createIfcDirection([float(o) for o in x_axis]),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if tool.Ifc.get().schema != "IFC2X3":
|
if tool.Ifc.get().schema != "IFC2X3":
|
||||||
cls.points = cls.export_points(position, indices["points"])
|
cls.points = cls.export_points(position, indices["points"])
|
||||||
|
|||||||
Reference in New Issue
Block a user