diff --git a/src/ifcblenderexport/blenderbim/cut_ifc.py b/src/ifcblenderexport/blenderbim/cut_ifc.py index adb7fb2258..1cc337a63c 100644 --- a/src/ifcblenderexport/blenderbim/cut_ifc.py +++ b/src/ifcblenderexport/blenderbim/cut_ifc.py @@ -138,12 +138,15 @@ class IfcCutter: if product.is_a('IfcOpeningElement') or product.is_a('IfcSite'): continue if product.Representation is not None: - if product.GlobalId in shape_map: - shape = shape_map[product.GlobalId] - else: - shape = ifcopenshell.geom.create_shape(settings, product).geometry - shape_map[product.GlobalId] = shape - self.product_shapes.append((product, shape)) + try: + if product.GlobalId in shape_map: + shape = shape_map[product.GlobalId] + else: + shape = ifcopenshell.geom.create_shape(settings, product).geometry + shape_map[product.GlobalId] = shape + self.product_shapes.append((product, shape)) + except: + print('Failed to create shape for {}'.format(product)) if not os.path.isfile(self.pickle_file): with open(self.pickle_file, 'wb') as shape_file: diff --git a/src/ifcblenderexport/blenderbim/operator.py b/src/ifcblenderexport/blenderbim/operator.py index d9aeb5449e..3ccfdea6fe 100644 --- a/src/ifcblenderexport/blenderbim/operator.py +++ b/src/ifcblenderexport/blenderbim/operator.py @@ -804,6 +804,8 @@ class CutSection(bpy.types.Operator): } ifc_cutter.pickle_file = os.path.join(ifc_cutter.data_dir, 'shapes.pickle') svg_writer = cut_ifc.SvgWriter(ifc_cutter) + numerator, denominator = bpy.context.scene.DocProperties.diagram_scale.split(':') + svg_writer.scale = float(numerator) / float(denominator) ifc_cutter.cut() svg_writer.write() return {'FINISHED'} diff --git a/src/ifcblenderexport/blenderbim/prop.py b/src/ifcblenderexport/blenderbim/prop.py index ac3d54fc80..e50800510c 100644 --- a/src/ifcblenderexport/blenderbim/prop.py +++ b/src/ifcblenderexport/blenderbim/prop.py @@ -24,6 +24,7 @@ class IfcSchema(): ifc_schema = IfcSchema() +diagram_scales_enum = [] classes_enum = [] types_enum = [] psetnames_enum = [] @@ -64,6 +65,26 @@ def refreshPredefinedTypes(self, context): getIfcPredefinedTypes(self, context) +def getDiagramScales(self, context): + global diagram_scales_enum + if len(diagram_scales_enum) < 1: + diagram_scales_enum.extend([ + ('1:5000', '1:5000', ''), + ('1:2000', '1:2000', ''), + ('1:1000', '1:1000', ''), + ('1:500', '1:500', ''), + ('1:200', '1:200', ''), + ('1:100', '1:100', ''), + ('1:50', '1:50', ''), + ('1:20', '1:20', ''), + ('1:10', '1:10', ''), + ('1:5', '1:5', ''), + ('1:2', '1:2', ''), + ('1:1', '1:1', '') + ]) + return diagram_scales_enum + + def getIfcClasses(self, context): global classes_enum if len(classes_enum) < 1: @@ -172,7 +193,7 @@ class Subcontext(PropertyGroup): class DocProperties(PropertyGroup): - blah: StringProperty(name="Blah") + diagram_scale: EnumProperty(items=getDiagramScales, name='Diagram Scale') class BIMProperties(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/ui.py b/src/ifcblenderexport/blenderbim/ui.py index f15aab8a79..a3ab69297a 100644 --- a/src/ifcblenderexport/blenderbim/ui.py +++ b/src/ifcblenderexport/blenderbim/ui.py @@ -193,7 +193,8 @@ class BIM_PT_documentation(Panel): layout = self.layout props = bpy.context.scene.DocProperties - row = layout.row() + row = layout.row(align=True) + row.prop(props, 'diagram_scale', text='') row.operator('bim.cut_section') row = layout.row()