mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Black formatting window modifier
This commit is contained in:
@@ -120,7 +120,7 @@ class EnableEditingArray(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props.y = data["y"]
|
||||
props.z = data["z"]
|
||||
props.is_editing = self.item
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveArray(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -425,4 +425,4 @@ class WindowData:
|
||||
parameters = psets.get("BBIM_Window", None)
|
||||
if parameters:
|
||||
parameters["data"] = json.loads(parameters.get("Data", "[]") or "[]")
|
||||
return parameters
|
||||
return parameters
|
||||
|
||||
@@ -303,7 +303,7 @@ class BIMSverchokProperties(PropertyGroup):
|
||||
def window_type_prop_update(self, context):
|
||||
panels_data = self.window_types_panels[self.window_type]
|
||||
for i in range(3):
|
||||
try:
|
||||
try:
|
||||
width, height = panels_data[i]
|
||||
except IndexError:
|
||||
width, height = (0.0, 0.0)
|
||||
@@ -311,51 +311,54 @@ def window_type_prop_update(self, context):
|
||||
self.relative_width[i] = width
|
||||
self.relative_height[i] = height
|
||||
|
||||
|
||||
class BIMWindowProperties(PropertyGroup):
|
||||
window_types = (
|
||||
('SINGLE_PANEL', 'SINGLE_PANEL', ''),
|
||||
('DOUBLE_PANEL_HORIZONTAL', 'DOUBLE_PANEL_HORIZONTAL', ''),
|
||||
('DOUBLE_PANEL_VERTICAL', 'DOUBLE_PANEL_VERTICAL', ''),
|
||||
('TRIPLE_PANEL_BOTTOM', 'TRIPLE_PANEL_BOTTOM', ''),
|
||||
('TRIPLE_PANEL_TOP', 'TRIPLE_PANEL_TOP', ''),
|
||||
('TRIPLE_PANEL_LEFT', 'TRIPLE_PANEL_LEFT', ''),
|
||||
('TRIPLE_PANEL_RIGHT', 'TRIPLE_PANEL_RIGHT', ''),
|
||||
('TRIPLE_PANEL_HORIZONTAL', 'TRIPLE_PANEL_HORIZONTAL', ''),
|
||||
('TRIPLE_PANEL_VERTICAL', 'TRIPLE_PANEL_VERTICAL', ''),
|
||||
("SINGLE_PANEL", "SINGLE_PANEL", ""),
|
||||
("DOUBLE_PANEL_HORIZONTAL", "DOUBLE_PANEL_HORIZONTAL", ""),
|
||||
("DOUBLE_PANEL_VERTICAL", "DOUBLE_PANEL_VERTICAL", ""),
|
||||
("TRIPLE_PANEL_BOTTOM", "TRIPLE_PANEL_BOTTOM", ""),
|
||||
("TRIPLE_PANEL_TOP", "TRIPLE_PANEL_TOP", ""),
|
||||
("TRIPLE_PANEL_LEFT", "TRIPLE_PANEL_LEFT", ""),
|
||||
("TRIPLE_PANEL_RIGHT", "TRIPLE_PANEL_RIGHT", ""),
|
||||
("TRIPLE_PANEL_HORIZONTAL", "TRIPLE_PANEL_HORIZONTAL", ""),
|
||||
("TRIPLE_PANEL_VERTICAL", "TRIPLE_PANEL_VERTICAL", ""),
|
||||
)
|
||||
|
||||
# default panel relative dimensions
|
||||
window_types_panels = {
|
||||
'SINGLE_PANEL': ((1.0, 1.0), ),
|
||||
'DOUBLE_PANEL_HORIZONTAL': ((1.0, 0.5), (1.0, 0.5), ),
|
||||
'DOUBLE_PANEL_VERTICAL': ((0.5, 1.0), (0.5, 1.0), ),
|
||||
'TRIPLE_PANEL_BOTTOM': ((0.5, 0.5), (0.5, 0.5), (1.0, 0.5), ),
|
||||
'TRIPLE_PANEL_TOP': ((1.0, 0.5), (0.5, 0.5), (0.5, 0.5), ),
|
||||
'TRIPLE_PANEL_LEFT': ((0.5, 1.0), (0.5, 0.5), (0.5, 0.5), ),
|
||||
'TRIPLE_PANEL_RIGHT': ((0.5, 0.5), (0.5, 1.0), (0.5, 0.5), ),
|
||||
'TRIPLE_PANEL_HORIZONTAL': ((1.0, 1/3), (1.0, 1/3), (1.0, 1/3),),
|
||||
'TRIPLE_PANEL_VERTICAL': ((1/3, 1.0), (1/3, 1.0), (1/3, 1.0),),
|
||||
"SINGLE_PANEL": ((1.0, 1.0), ),
|
||||
"DOUBLE_PANEL_HORIZONTAL": ((1.0, 0.5), (1.0, 0.5), ),
|
||||
"DOUBLE_PANEL_VERTICAL": ((0.5, 1.0), (0.5, 1.0), ),
|
||||
"TRIPLE_PANEL_BOTTOM": ((0.5, 0.5), (0.5, 0.5), (1.0, 0.5), ),
|
||||
"TRIPLE_PANEL_TOP": ((1.0, 0.5), (0.5, 0.5), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_LEFT": ((0.5, 1.0), (0.5, 0.5), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_RIGHT": ((0.5, 0.5), (0.5, 1.0), (0.5, 0.5), ),
|
||||
"TRIPLE_PANEL_HORIZONTAL": ((1.0, 1/3), (1.0, 1/3), (1.0, 1/3),),
|
||||
"TRIPLE_PANEL_VERTICAL": ((1/3, 1.0), (1/3, 1.0), (1/3, 1.0),),
|
||||
}
|
||||
|
||||
is_editing: bpy.props.IntProperty(default=-1)
|
||||
window_type: bpy.props.EnumProperty(name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update)
|
||||
overall_height: bpy.props.FloatProperty(name='Overall Height', default=900)
|
||||
overall_width: bpy.props.FloatProperty(name='Overall Width', default=600)
|
||||
window_type: bpy.props.EnumProperty(
|
||||
name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update
|
||||
)
|
||||
overall_height: bpy.props.FloatProperty(name="Overall Height", default=900)
|
||||
overall_width: bpy.props.FloatProperty(name="Overall Width", default=600)
|
||||
|
||||
# lining properties
|
||||
lining_depth: bpy.props.FloatProperty(name='Lining Depth', default=50)
|
||||
lining_thickness: bpy.props.FloatProperty(name='Lining Thickness', default=50)
|
||||
lining_offset: bpy.props.FloatProperty(name='Lining Offset', default=50)
|
||||
lining_to_panel_offset_x: bpy.props.FloatProperty(name='Lining to Panel Offset X', default=25)
|
||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name='Lining to Panel Offset Y', default=25)
|
||||
mullion_thickness: bpy.props.FloatProperty(name='(not used) Mullion Thickness')
|
||||
transom_thickness: bpy.props.FloatProperty(name='(not used) Transom Thickness')
|
||||
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=50)
|
||||
lining_thickness: bpy.props.FloatProperty(name="Lining Thickness", default=50)
|
||||
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=50)
|
||||
lining_to_panel_offset_x: bpy.props.FloatProperty(name="Lining to Panel Offset X", default=25)
|
||||
lining_to_panel_offset_y: bpy.props.FloatProperty(name="Lining to Panel Offset Y", default=25)
|
||||
mullion_thickness: bpy.props.FloatProperty(name="(not used) Mullion Thickness")
|
||||
transom_thickness: bpy.props.FloatProperty(name="(not used) Transom Thickness")
|
||||
|
||||
# panel_properties
|
||||
frame_depth: bpy.props.FloatVectorProperty(name='Frame Depth', size=3, default=[35]*3)
|
||||
frame_thickness: bpy.props.FloatVectorProperty(name='Frame Thickness', size=3, default=[35]*3)
|
||||
relative_width: bpy.props.FloatVectorProperty(name='Relative Width', size=3, default=[1,0,0])
|
||||
relative_height: bpy.props.FloatVectorProperty(name='Relative Height', size=3, default=[1,0,0])
|
||||
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[35] * 3)
|
||||
frame_thickness: bpy.props.FloatVectorProperty(name="Frame Thickness", size=3, default=[35] * 3)
|
||||
relative_width: bpy.props.FloatVectorProperty(name="Relative Width", size=3, default=[1, 0, 0])
|
||||
relative_height: bpy.props.FloatVectorProperty(name="Relative Height", size=3, default=[1, 0, 0])
|
||||
|
||||
def get_general_kwargs(self):
|
||||
return {
|
||||
@@ -381,4 +384,4 @@ class BIMWindowProperties(PropertyGroup):
|
||||
"frame_thickness": self.frame_thickness,
|
||||
"relative_width": self.relative_width,
|
||||
"relative_height": self.relative_height,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ class EnableEditingStair(bpy.types.Operator, tool.Ifc.Operator):
|
||||
setattr(props, prop_name, data[prop_name])
|
||||
|
||||
props.is_editing = 1
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveStair(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -424,13 +424,13 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
|
||||
props = context.active_object.BIMWindowProperties
|
||||
|
||||
if WindowData.data['parameters']:
|
||||
if WindowData.data["parameters"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Window parameters", icon="OUTLINER_OB_LATTICE")
|
||||
|
||||
window_data = WindowData.data['parameters']['data']
|
||||
window_data = WindowData.data["parameters"]["data"]
|
||||
|
||||
if props.is_editing != - 1:
|
||||
if props.is_editing != -1:
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.finish_editing_window", icon="CHECKMARK", text="Finish editing")
|
||||
row.operator("bim.cancel_editing_window", icon="CANCEL", text="")
|
||||
@@ -440,30 +440,30 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
self.layout.prop(props, prop)
|
||||
|
||||
lining_props = props.get_lining_kwargs()
|
||||
self.layout.label(text='Lining properties')
|
||||
self.layout.label(text="Lining properties")
|
||||
for prop in lining_props:
|
||||
self.layout.prop(props, prop)
|
||||
|
||||
panel_props = props.get_panel_kwargs()
|
||||
self.layout.label(text='Panel properties')
|
||||
self.layout.label(text="Panel properties")
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
|
||||
panel_box = self.layout.box()
|
||||
row = panel_box.row()
|
||||
cols = [row.column(align=True) for i in range(number_of_panels+1)]
|
||||
cols = [row.column(align=True) for i in range(number_of_panels + 1)]
|
||||
|
||||
cols[0].label(text="")
|
||||
|
||||
cols[0].label(text='')
|
||||
|
||||
for panel_i in range(number_of_panels):
|
||||
r = cols[panel_i+1].row()
|
||||
r.alignment = 'CENTER'
|
||||
r.label(text=f'#{panel_i}')
|
||||
r = cols[panel_i+1].row()
|
||||
r = cols[panel_i + 1].row()
|
||||
r.alignment = "CENTER"
|
||||
r.label(text=f"#{panel_i}")
|
||||
r = cols[panel_i + 1].row()
|
||||
|
||||
for prop in panel_props:
|
||||
cols[0].label(text=f"{props.bl_rna.properties[prop].name}")
|
||||
for panel_i in range(number_of_panels):
|
||||
cols[panel_i+1].prop(props, prop, index=panel_i, text='')
|
||||
cols[panel_i + 1].prop(props, prop, index=panel_i, text="")
|
||||
|
||||
update_window_modifier_bmesh(context)
|
||||
|
||||
@@ -481,46 +481,47 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
row.label(text=str(prop_value))
|
||||
|
||||
lining_props = props.get_lining_kwargs()
|
||||
self.layout.label(text='Lining properties')
|
||||
self.layout.label(text="Lining properties")
|
||||
lining_box = self.layout.box()
|
||||
for prop in lining_props:
|
||||
prop_value = window_data['lining_properties'][prop]
|
||||
prop_value = window_data["lining_properties"][prop]
|
||||
prop_value = round(prop_value, 5) if type(prop_value) is float else prop_value
|
||||
row = lining_box.row(align=True)
|
||||
row.label(text=f"{props.bl_rna.properties[prop].name}")
|
||||
row.label(text=str(prop_value))
|
||||
|
||||
panel_props = props.get_panel_kwargs()
|
||||
self.layout.label(text='Panel properties')
|
||||
self.layout.label(text="Panel properties")
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
|
||||
panel_box = self.layout.box()
|
||||
row = panel_box.row()
|
||||
cols = [row.column(align=True) for i in range(number_of_panels+1)]
|
||||
cols[0].label(text='')
|
||||
|
||||
cols = [row.column(align=True) for i in range(number_of_panels + 1)]
|
||||
cols[0].label(text="")
|
||||
|
||||
for panel_i in range(number_of_panels):
|
||||
r = cols[panel_i+1].row()
|
||||
r.alignment = 'CENTER'
|
||||
r.label(text=f'#{panel_i}')
|
||||
r = cols[panel_i+1].row()
|
||||
r = cols[panel_i + 1].row()
|
||||
r.alignment = "CENTER"
|
||||
r.label(text=f"#{panel_i}")
|
||||
r = cols[panel_i + 1].row()
|
||||
|
||||
# TODO: align property values more evenly
|
||||
for prop in panel_props:
|
||||
cols[0].row().label(text=f"{props.bl_rna.properties[prop].name}")
|
||||
for panel_i in range(number_of_panels):
|
||||
r = cols[panel_i+1].row()
|
||||
r.alignment = 'CENTER'
|
||||
prop_value = window_data['panel_properties'][prop][panel_i]
|
||||
r = cols[panel_i + 1].row()
|
||||
r.alignment = "CENTER"
|
||||
prop_value = window_data["panel_properties"][prop][panel_i]
|
||||
prop_value = round(prop_value, 5) if type(prop_value) is float else prop_value
|
||||
r.label(text=str(prop_value))
|
||||
r = cols[panel_i+1].row()
|
||||
r = cols[panel_i + 1].row()
|
||||
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.label(text="No Window Found")
|
||||
row.operator("bim.add_window", icon="ADD", text="")
|
||||
|
||||
|
||||
class BIM_MT_model(Menu):
|
||||
bl_idname = "BIM_MT_model"
|
||||
bl_label = "IFC Objects"
|
||||
|
||||
@@ -40,54 +40,59 @@ import json
|
||||
|
||||
V = lambda *x: Vector([float(i) for i in x])
|
||||
|
||||
|
||||
def update_window_modifier_representation(context):
|
||||
obj = context.active_object
|
||||
props = obj.BIMWindowProperties
|
||||
ifc_file = tool.Ifc.get()
|
||||
representation_data = {
|
||||
'partition_type': props.window_type,
|
||||
'overall_height': props.overall_height,
|
||||
'overall_width': props.overall_width,
|
||||
'lining_properties': {
|
||||
'LiningDepth': props.lining_depth,
|
||||
'LiningThickness': props.lining_thickness,
|
||||
'LiningOffset': props.lining_offset,
|
||||
'LiningToPanelOffsetX': props.lining_to_panel_offset_x,
|
||||
'LiningToPanelOffsetY': props.lining_to_panel_offset_y,
|
||||
"partition_type": props.window_type,
|
||||
"overall_height": props.overall_height,
|
||||
"overall_width": props.overall_width,
|
||||
"lining_properties": {
|
||||
"LiningDepth": props.lining_depth,
|
||||
"LiningThickness": props.lining_thickness,
|
||||
"LiningOffset": props.lining_offset,
|
||||
"LiningToPanelOffsetX": props.lining_to_panel_offset_x,
|
||||
"LiningToPanelOffsetY": props.lining_to_panel_offset_y,
|
||||
},
|
||||
'panel_properties': []
|
||||
"panel_properties": [],
|
||||
}
|
||||
number_of_panels = len(props.window_types_panels[props.window_type])
|
||||
for panel_i in range(number_of_panels):
|
||||
panel_data = {
|
||||
'FrameDepth': props.frame_depth[panel_i],
|
||||
'FrameThickness': props.frame_thickness[panel_i],
|
||||
'RelativeWidth': props.relative_width[panel_i],
|
||||
'RelativeHeight': props.relative_height[panel_i],
|
||||
"FrameDepth": props.frame_depth[panel_i],
|
||||
"FrameThickness": props.frame_thickness[panel_i],
|
||||
"RelativeWidth": props.relative_width[panel_i],
|
||||
"RelativeHeight": props.relative_height[panel_i],
|
||||
}
|
||||
representation_data['panel_properties'].append(panel_data)
|
||||
representation_data["panel_properties"].append(panel_data)
|
||||
|
||||
# ELEVATION_VIEW representation
|
||||
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Profile", "ELEVATION_VIEW")
|
||||
if not ifc_context:
|
||||
model_context = ifcopenshell.util.representation.get_context(ifc_file, 'Model')
|
||||
model_context = ifcopenshell.util.representation.get_context(ifc_file, "Model")
|
||||
ifc_context = ifcopenshell.api.run(
|
||||
'context.add_context',
|
||||
ifc_file,
|
||||
context_type='Model',
|
||||
context_identifier='Profile',
|
||||
target_view='ELEVATION_VIEW',
|
||||
parent=model_context)
|
||||
"context.add_context",
|
||||
ifc_file,
|
||||
context_type="Model",
|
||||
context_identifier="Profile",
|
||||
target_view="ELEVATION_VIEW",
|
||||
parent=model_context,
|
||||
)
|
||||
|
||||
representation_data['context'] = ifc_context
|
||||
elevation_representation = ifcopenshell.api.run("geometry.add_window_representation", ifc_file, **representation_data)
|
||||
representation_data["context"] = ifc_context
|
||||
elevation_representation = ifcopenshell.api.run(
|
||||
"geometry.add_window_representation", ifc_file, **representation_data
|
||||
)
|
||||
replace_representation_for_object(ifc_file, ifc_context, obj, elevation_representation)
|
||||
|
||||
# MODEL_VIEW representation
|
||||
ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
representation_data['context'] = ifc_context
|
||||
representation_data["context"] = ifc_context
|
||||
model_representation = ifcopenshell.api.run("geometry.add_window_representation", ifc_file, **representation_data)
|
||||
replace_representation_for_object(ifc_file, ifc_context, obj, model_representation)
|
||||
replace_representation_for_object(ifc_file, ifc_context, obj, model_representation)
|
||||
|
||||
|
||||
def replace_representation_for_object(ifc_file, ifc_context, obj, new_representation):
|
||||
ifc_element = tool.Ifc.get_entity(obj)
|
||||
@@ -106,24 +111,27 @@ def replace_representation_for_object(ifc_file, ifc_context, obj, new_representa
|
||||
representation=new_representation,
|
||||
should_reload=True,
|
||||
is_global=False,
|
||||
should_sync_changes_first=True
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
core.remove_representation(tool.Ifc, tool.Geometry, obj=obj, representation=old_representation)
|
||||
else:
|
||||
ifcopenshell.api.run("geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation
|
||||
)
|
||||
|
||||
def create_bm_window_closed_profile(bm, size: Vector, thickness:float, position:Vector):
|
||||
|
||||
def create_bm_window_closed_profile(bm, size: Vector, thickness: float, position: Vector):
|
||||
width, depth, height = size
|
||||
|
||||
verts = [
|
||||
(0, [thickness, 0.0, thickness]),
|
||||
(1, [width-thickness, 0.0, thickness]),
|
||||
(2, [thickness, 0.0, height-thickness]),
|
||||
(3, [width-thickness, 0.0, height-thickness]),
|
||||
(4, [0.0, 0.0, 0.0]),
|
||||
(5, [0.0, 0.0, height]),
|
||||
(6, [width, 0.0, 0.0]),
|
||||
(7, [width, 0.0, height]),
|
||||
(0, [thickness, 0.0, thickness]),
|
||||
(1, [width - thickness, 0.0, thickness]),
|
||||
(2, [thickness, 0.0, height - thickness]),
|
||||
(3, [width - thickness, 0.0, height - thickness]),
|
||||
(4, [0.0, 0.0, 0.0]),
|
||||
(5, [0.0, 0.0, height]),
|
||||
(6, [width, 0.0, 0.0]),
|
||||
(7, [width, 0.0, height]),
|
||||
]
|
||||
|
||||
edges = [
|
||||
@@ -142,10 +150,10 @@ def create_bm_window_closed_profile(bm, size: Vector, thickness:float, position:
|
||||
]
|
||||
|
||||
faces = [
|
||||
(0, (2, 3, 7, 5)),
|
||||
(1, (5, 4, 0, 2)),
|
||||
(2, (1, 0, 4, 6)),
|
||||
(3, (7, 3, 1, 6)),
|
||||
(0, (2, 3, 7, 5)),
|
||||
(1, (5, 4, 0, 2)),
|
||||
(2, (1, 0, 4, 6)),
|
||||
(3, (7, 3, 1, 6)),
|
||||
]
|
||||
|
||||
bm.verts.index_update()
|
||||
@@ -161,7 +169,7 @@ def create_bm_window_closed_profile(bm, size: Vector, thickness:float, position:
|
||||
translate_verts = [v for v in extruded["geom"] if isinstance(v, BMVert)]
|
||||
bmesh.ops.translate(bm, vec=extrusion_vector, verts=translate_verts)
|
||||
|
||||
bmesh.ops.translate(bm, vec=position, verts=new_verts+translate_verts)
|
||||
bmesh.ops.translate(bm, vec=position, verts=new_verts + translate_verts)
|
||||
|
||||
return new_verts
|
||||
|
||||
@@ -195,53 +203,52 @@ def update_window_modifier_bmesh(context):
|
||||
|
||||
# create lining
|
||||
lining_size = V(
|
||||
overall_width * props.relative_width[panel_i],
|
||||
lining_depth,
|
||||
overall_height* props.relative_height[panel_i])
|
||||
overall_width * props.relative_width[panel_i],
|
||||
lining_depth,
|
||||
overall_height * props.relative_height[panel_i],
|
||||
)
|
||||
thickness = props.lining_thickness * si_conversion
|
||||
lining_verts = create_bm_window_closed_profile(bm, lining_size, thickness, V(0, 0, 0))
|
||||
|
||||
# add panel
|
||||
panel_size = lining_size.copy()
|
||||
panel_size.y = frame_depth
|
||||
panel_size = panel_size - V(lining_to_panel_offset_x*2, 0, lining_to_panel_offset_x*2)
|
||||
panel_size = panel_size - V(lining_to_panel_offset_x * 2, 0, lining_to_panel_offset_x * 2)
|
||||
|
||||
panel_position = V(
|
||||
props.lining_to_panel_offset_x * si_conversion,
|
||||
((props.lining_depth-props.frame_depth[panel_i]) + props.lining_to_panel_offset_y) * si_conversion,
|
||||
((props.lining_depth - props.frame_depth[panel_i]) + props.lining_to_panel_offset_y) * si_conversion,
|
||||
props.lining_to_panel_offset_x * si_conversion,
|
||||
)
|
||||
thickness = props.frame_thickness[panel_i] * si_conversion
|
||||
panel_verts = create_bm_window_closed_profile(bm, panel_size, thickness, panel_position)
|
||||
|
||||
# add glass
|
||||
glass_verts = bmesh.ops.create_cube(bm, size=1)['verts']
|
||||
glass_verts = bmesh.ops.create_cube(bm, size=1)["verts"]
|
||||
bmesh.ops.translate(bm, vec=-glass_verts[0].co, verts=glass_verts)
|
||||
glass_size = panel_size
|
||||
glass_size.y = glass_thickness
|
||||
glass_size = glass_size - V(frame_thickness*2, 0, frame_thickness)
|
||||
glass_size = glass_size - V(frame_thickness * 2, 0, frame_thickness)
|
||||
glass_position = panel_position + V(
|
||||
frame_thickness,
|
||||
frame_depth/2-glass_thickness/2,
|
||||
frame_depth / 2 - glass_thickness / 2,
|
||||
frame_thickness,
|
||||
)
|
||||
bmesh.ops.scale(bm, vec=glass_size, verts=glass_verts)
|
||||
bmesh.ops.translate(bm, vec=glass_position, verts=glass_verts)
|
||||
|
||||
# translate panel
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i]) * V(overall_width, 0, overall_height)
|
||||
bmesh.ops.translate(bm,
|
||||
vec=accumulated_offset,
|
||||
verts=lining_verts + panel_verts + glass_verts)
|
||||
accumulated_offset = V(accumulated_width, 0, accumulated_height[column_i]) * V(
|
||||
overall_width, 0, overall_height
|
||||
)
|
||||
bmesh.ops.translate(bm, vec=accumulated_offset, verts=lining_verts + panel_verts + glass_verts)
|
||||
|
||||
built_panels.append(panel_i)
|
||||
|
||||
accumulated_height[column_i] += props.relative_height[panel_i]
|
||||
accumulated_width += props.relative_width[panel_i]
|
||||
|
||||
bmesh.ops.translate(bm,
|
||||
vec=V(0, props.lining_offset * si_conversion, 0),
|
||||
verts=bm.verts)
|
||||
|
||||
bmesh.ops.translate(bm, vec=V(0, props.lining_offset * si_conversion, 0), verts=bm.verts)
|
||||
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
|
||||
|
||||
if bpy.context.object.mode == "EDIT":
|
||||
@@ -267,8 +274,8 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
lining_props = props.get_lining_kwargs()
|
||||
panel_props = props.get_panel_kwargs()
|
||||
|
||||
window_data['lining_properties'] = lining_props
|
||||
window_data['panel_properties'] = panel_props
|
||||
window_data["lining_properties"] = lining_props
|
||||
window_data["panel_properties"] = panel_props
|
||||
psets = ifcopenshell.util.element.get_psets(element)
|
||||
pset = psets.get("BBIM_Window", None)
|
||||
|
||||
@@ -286,7 +293,7 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
update_window_modifier_representation(context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
class CancelEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.cancel_editing_window"
|
||||
bl_label = "Cancel editing Window"
|
||||
@@ -324,8 +331,8 @@ class FinishEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
lining_props = props.get_lining_kwargs()
|
||||
panel_props = props.get_panel_kwargs()
|
||||
|
||||
window_data['lining_properties'] = lining_props
|
||||
window_data['panel_properties'] = panel_props
|
||||
window_data["lining_properties"] = lining_props
|
||||
window_data["panel_properties"] = panel_props
|
||||
|
||||
props.is_editing = -1
|
||||
|
||||
@@ -357,7 +364,7 @@ class EnableEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
setattr(props, prop_name, data[prop_name])
|
||||
|
||||
props.is_editing = 1
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveWindow(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -66,6 +66,7 @@ def simple_uses():
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
|
||||
def generate_desk_test():
|
||||
ifc_file = ifcopenshell.file()
|
||||
desks = [
|
||||
@@ -80,6 +81,7 @@ def generate_desk_test():
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
|
||||
def mirror_placement_test():
|
||||
ifc_file = ifcopenshell.api.run("project.create_file")
|
||||
project = ifcopenshell.api.run(
|
||||
@@ -153,6 +155,7 @@ def mirror_placement_test():
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
|
||||
def curve_between_two_points_test():
|
||||
ifc_file = ifcopenshell.api.run("project.create_file")
|
||||
project = ifcopenshell.api.run(
|
||||
@@ -217,6 +220,7 @@ def curve_between_two_points_test():
|
||||
|
||||
ifc_file.write("tmp.ifc")
|
||||
|
||||
|
||||
def generate_simple_desk(ifc_file, width, depth, height):
|
||||
# > width, depth, height in mm
|
||||
width, depth, height = [i / 1000 for i in (width, depth, height)]
|
||||
@@ -226,6 +230,7 @@ def generate_simple_desk(ifc_file, width, depth, height):
|
||||
extruded_area = builder.extrude(profile, height)
|
||||
return extruded_area
|
||||
|
||||
|
||||
def generate_table(ifc_file, width, depth, height, countertop_thickness=20, leg_size=40, leg_offset=50):
|
||||
# > width, depth, height in mm
|
||||
width, depth, height, countertop_thickness, leg_size, leg_offset = [
|
||||
|
||||
Reference in New Issue
Block a user