mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Add support for different view scales
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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'}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user