From 280c7df79a0e9131090fc0d92acc20ca04b4506f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 2 May 2020 21:01:39 +1000 Subject: [PATCH] Don't cut rooms in documentation, fix non single material bug, and add view present for construction style documentation --- .../blenderbim/bim/__init__.py | 1 + .../blenderbim/bim/cut_ifc.py | 13 +++++--- .../blenderbim/bim/operator.py | 31 +++++++++++++++++++ src/ifcblenderexport/blenderbim/bim/ui.py | 3 +- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index d0e111aac5..86e4405ec5 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -98,6 +98,7 @@ if bpy is not None: operator.ExecuteIfcDiff, operator.AssignContext, operator.SetViewPreset1, + operator.SetViewPreset2, operator.OpenUpstream, operator.BIM_OT_CopyAttributesToSelection, operator.BIM_OT_ChangeClassificationLevel, diff --git a/src/ifcblenderexport/blenderbim/bim/cut_ifc.py b/src/ifcblenderexport/blenderbim/bim/cut_ifc.py index c085167efe..6142c97530 100644 --- a/src/ifcblenderexport/blenderbim/bim/cut_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/cut_ifc.py @@ -152,8 +152,6 @@ class IfcCutter: self.load_ifc_files() print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time)) start_time = time.time() - print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time)) - start_time = time.time() print('# Get product shapes') self.get_product_shapes() print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time)) @@ -208,7 +206,8 @@ class IfcCutter: settings.set(settings.USE_PYTHON_OPENCASCADE, True) products = [] for ifc_file in self.ifc_files: - products.extend(ifc_file.by_type('IfcProduct')) + # TODO: This should perhaps be configurable, e.g. spaces cut to show zones in the drawing + products.extend(ifc_file.by_type('IfcElement')) total_products = len(products) for i, product in enumerate(products): print('{}/{} geometry processed ...'.format(i, total_products), end='\r', flush=True) @@ -571,7 +570,6 @@ class IfcCutter: pickle.dump(self.cut_polygons, pickle_file, protocol=pickle.HIGHEST_PROTOCOL) def get_fresh_cut_polygons(self): - total_product_shapes = len(self.product_shapes) process_data = [(p.GlobalId, s, self.section_box['face'], self.transformation_data) for p, s in self.product_shapes] import multiprocessing @@ -1009,6 +1007,11 @@ class SvgWriter(): classes = [position, element.is_a()] for association in element.HasAssociations: if association.is_a('IfcRelAssociatesMaterial'): - classes.append('material-{}'.format(association.RelatingMaterial.Name)) + classes.append('material-{}'.format(self.get_material_name(association.RelatingMaterial))) classes.append('globalid-{}'.format(element.GlobalId)) return classes + + def get_material_name(self, element): + if hasattr(element, 'Name') and element.Name: + return element.Name + return element.id() diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 7404e4972c..ee928ace28 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1769,6 +1769,37 @@ class SetViewPreset1(bpy.types.Operator): return {'FINISHED'} +class SetViewPreset2(bpy.types.Operator): + bl_idname = 'bim.set_view_preset_2' + bl_label = 'Set View Preset 2' + + def execute(self, context): + bpy.data.worlds[0].color = (1, 1, 1) + bpy.context.scene.render.engine = 'BLENDER_WORKBENCH' + bpy.context.scene.display.shading.show_object_outline = True + bpy.context.scene.display.shading.show_cavity = True + bpy.context.scene.display.shading.cavity_type = 'BOTH' + bpy.context.scene.display.shading.curvature_ridge_factor = 1 + bpy.context.scene.display.shading.curvature_valley_factor = 1 + bpy.context.scene.view_settings.view_transform = 'Standard' + + bpy.context.scene.display.shading.light = 'FLAT' + bpy.context.scene.display.shading.color_type = 'SINGLE' + bpy.context.scene.display.shading.single_color = (1, 1, 1) + bpy.context.scene.use_nodes = True + rgb_curves = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeCurveRGB') + rgb_curves.mapping.curves[3].points.new(.4, 0) # Increase black contrast + rgb_curves.mapping.update() + for node in bpy.context.scene.node_tree.nodes: + if node.type == 'R_LAYERS': + render_layers = node + elif node.type == 'COMPOSITE': + composite = node + bpy.context.scene.node_tree.links.new(render_layers.outputs[0], rgb_curves.inputs[1]) + bpy.context.scene.node_tree.links.new(rgb_curves.outputs[0], composite.inputs[0]) + return {'FINISHED'} + + class OpenUpstream(bpy.types.Operator): bl_idname = 'bim.open_upstream' bl_label = 'Open Upstream Reference' diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index f496ef465b..c6e25b4e33 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -512,8 +512,9 @@ class BIM_PT_documentation(Panel): layout.use_property_split = True props = bpy.context.scene.DocProperties - row = layout.row() + row = layout.row(align=True) row.operator('bim.set_view_preset_1') + row.operator('bim.set_view_preset_2') row = layout.row() row.prop(props, 'view_name')