mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #956. Add support for imperial and custom drawing scales.
This commit is contained in:
@@ -2193,11 +2193,15 @@ class CutSection(bpy.types.Operator):
|
||||
ifc_cutter.selected_global_ids = selected_global_ids
|
||||
ifc_cutter.should_extract = bpy.context.scene.DocProperties.should_extract
|
||||
svg_writer = svgwriter.SvgWriter(ifc_cutter)
|
||||
numerator, denominator = camera.data.BIMCameraProperties.diagram_scale.split(':')
|
||||
if camera.data.BIMCameraProperties.diagram_scale == 'CUSTOM':
|
||||
human_scale, fraction = camera.data.BIMCameraProperties.custom_diagram_scale.split('|')
|
||||
else:
|
||||
human_scale, fraction = camera.data.BIMCameraProperties.diagram_scale.split('|')
|
||||
numerator, denominator = fraction.split('/')
|
||||
if camera.data.BIMCameraProperties.is_nts:
|
||||
svg_writer.human_scale = 'NTS'
|
||||
else:
|
||||
svg_writer.human_scale = camera.data.BIMCameraProperties.diagram_scale
|
||||
svg_writer.human_scale = human_scale
|
||||
svg_writer.scale = float(numerator) / float(denominator)
|
||||
ifc_cutter.cut()
|
||||
svg_writer.write()
|
||||
@@ -3591,7 +3595,10 @@ class AddDrawing(bpy.types.Operator):
|
||||
camera.location = (0, 0, 1.7) # The view shall be 1.7m above the origin
|
||||
camera.data.type = 'ORTHO'
|
||||
camera.data.ortho_scale = 50 # The default of 6m is too small
|
||||
camera.data.BIMCameraProperties.diagram_scale = '1:100'
|
||||
if bpy.context.scene.unit_settings.system == 'IMPERIAL':
|
||||
camera.data.BIMCameraProperties.diagram_scale = '1/8"=1\'-0"|1/96'
|
||||
else:
|
||||
camera.data.BIMCameraProperties.diagram_scale = '1:100|1/100'
|
||||
bpy.context.scene.camera = camera
|
||||
view_collection.objects.link(camera)
|
||||
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
|
||||
|
||||
@@ -131,21 +131,59 @@ def refreshPredefinedTypes(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', '')
|
||||
])
|
||||
if len(diagram_scales_enum) < 1 \
|
||||
or (bpy.context.scene.unit_settings.system == 'IMPERIAL' and len(diagram_scales_enum) == 13) \
|
||||
or (bpy.context.scene.unit_settings.system == 'METRIC' and len(diagram_scales_enum) == 31) :
|
||||
if bpy.context.scene.unit_settings.system == 'IMPERIAL':
|
||||
diagram_scales_enum = [
|
||||
('CUSTOM', 'Custom', ''),
|
||||
('1\'=1\'-0"|1/1', '1\'=1\'-0"', ''),
|
||||
('6"=1\'-0"|1/6', '6"=1\'-0"', ''),
|
||||
('1-1/2"=1\'-0"|1/8', '1-1/2"=1\'-0"', ''),
|
||||
('1"=1\'-0"|1/12', '1"=1\'-0"', ''),
|
||||
('3/4"=1\'-0"|1/16', '3/4"=1\'-0"', ''),
|
||||
('1/2"=1\'-0"|1/24', '1/2"=1\'-0"', ''),
|
||||
('3/8"=1\'-0"|1/32', '3/8"=1\'-0"', ''),
|
||||
('1/4"=1\'-0"|1/48', '1/4"=1\'-0"', ''),
|
||||
('3/16"=1\'-0"|1/64', '3/16"=1\'-0"', ''),
|
||||
('1/8"=1\'-0"|1/96', '1/8"=1\'-0"', ''),
|
||||
('3/32"=1\'-0"|1/128', '3/32"=1\'-0"', ''),
|
||||
('1/16"=1\'-0"|1/192', '1/16"=1\'-0"', ''),
|
||||
('1/32"=1\'-0"|1/384', '1/32"=1\'-0"', ''),
|
||||
('1/64"=1\'-0"|1/768', '1/64"=1\'-0"', ''),
|
||||
('1/128"=1\'-0"|1/1536', '1/128"=1\'-0"', ''),
|
||||
('1"=10\'|1/120', '1"=10\'', ''),
|
||||
('1"=20\'|1/240', '1"=20\'', ''),
|
||||
('1"=30\'|1/360', '1"=30\'', ''),
|
||||
('1"=40\'|1/480', '1"=40\'', ''),
|
||||
('1"=50\'|1/600', '1"=50\'', ''),
|
||||
('1"=60\'|1/720', '1"=60\'', ''),
|
||||
('1"=70\'|1/840', '1"=70\'', ''),
|
||||
('1"=80\'|1/960', '1"=80\'', ''),
|
||||
('1"=90\'|1/1080', '1"=90\'', ''),
|
||||
('1"=100\'|1/1200', '1"=100\'', ''),
|
||||
('1"=150\'|1/1800', '1"=150\'', ''),
|
||||
('1"=200\'|1/2400', '1"=200\'', ''),
|
||||
('1"=300\'|1/3600', '1"=300\'', ''),
|
||||
('1"=400\'|1/4800', '1"=400\'', ''),
|
||||
('1"=500\'|1/6000', '1"=500\'', ''),
|
||||
]
|
||||
else:
|
||||
diagram_scales_enum = [
|
||||
('CUSTOM', 'Custom', ''),
|
||||
('1:5000|1/5000', '1:5000', ''),
|
||||
('1:2000|1/2000', '1:2000', ''),
|
||||
('1:1000|1/1000', '1:1000', ''),
|
||||
('1:500|1/500', '1:500', ''),
|
||||
('1:200|1/200', '1:200', ''),
|
||||
('1:100|1/100', '1:100', ''),
|
||||
('1:50|1/50', '1:50', ''),
|
||||
('1:20|1/20', '1:20', ''),
|
||||
('1:10|1/10', '1:10', ''),
|
||||
('1:5|1/5', '1:5', ''),
|
||||
('1:2|1/2', '1:2', ''),
|
||||
('1:1|1/1', '1:1', '')
|
||||
]
|
||||
return diagram_scales_enum
|
||||
|
||||
|
||||
@@ -485,7 +523,8 @@ class DocProperties(PropertyGroup):
|
||||
|
||||
class BIMCameraProperties(PropertyGroup):
|
||||
view_name: StringProperty(name="View Name")
|
||||
diagram_scale: EnumProperty(items=getDiagramScales, name='Diagram Scale')
|
||||
diagram_scale: EnumProperty(items=getDiagramScales, name='Drawing Scale')
|
||||
custom_diagram_scale: StringProperty(name='Custom Scale')
|
||||
is_nts: BoolProperty(name='Is NTS')
|
||||
cut_objects: EnumProperty(items=[
|
||||
('.IfcWall|.IfcSlab|.IfcCurtainWall|.IfcStair|.IfcStairFlight|.IfcColumn|.IfcBeam|.IfcMember|.IfcCovering',
|
||||
|
||||
@@ -908,6 +908,9 @@ class BIM_PT_camera(Panel):
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'diagram_scale')
|
||||
if props.diagram_scale == 'CUSTOM':
|
||||
row = layout.row()
|
||||
row.prop(props, 'custom_diagram_scale')
|
||||
|
||||
layout.label(text="Drawing Styles:")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user