mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
New drawing width / height / depth / raster DPI controls
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import blenderbim.bim.module.drawing.decoration as decoration
|
import blenderbim.bim.module.drawing.decoration as decoration
|
||||||
|
import blenderbim.tool as tool
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
|
||||||
@@ -37,10 +38,28 @@ def depsgraph_update_pre_handler(scene):
|
|||||||
def set_active_camera_resolution(scene):
|
def set_active_camera_resolution(scene):
|
||||||
if not scene.camera or "/" not in scene.camera.name or not scene.DocProperties.drawings:
|
if not scene.camera or "/" not in scene.camera.name or not scene.DocProperties.drawings:
|
||||||
return
|
return
|
||||||
|
props = scene.camera.data.BIMCameraProperties
|
||||||
|
ortho_scale = max((props.width, props.height))
|
||||||
|
aspect_ratio = props.width / props.height
|
||||||
if (
|
if (
|
||||||
scene.render.resolution_x != scene.camera.data.BIMCameraProperties.raster_x
|
(scene.camera.data.ortho_scale != ortho_scale)
|
||||||
or scene.render.resolution_y != scene.camera.data.BIMCameraProperties.raster_y
|
or (scene.render.resolution_x / scene.render.resolution_y != aspect_ratio)
|
||||||
):
|
):
|
||||||
scene.render.resolution_x = scene.camera.data.BIMCameraProperties.raster_x
|
scene.camera.data.ortho_scale = ortho_scale
|
||||||
scene.render.resolution_y = scene.camera.data.BIMCameraProperties.raster_y
|
|
||||||
|
diagram_scale = tool.Drawing.get_diagram_scale(scene.camera)
|
||||||
|
scale_ratio = tool.Drawing.get_scale_ratio(diagram_scale["Scale"])
|
||||||
|
|
||||||
|
if props.width > props.height:
|
||||||
|
aspect_ratio = props.height / props.width
|
||||||
|
raster_x = ortho_scale * scale_ratio * props.dpi / 0.0254
|
||||||
|
raster_y = ortho_scale * aspect_ratio * scale_ratio * props.dpi / 0.0254
|
||||||
|
else:
|
||||||
|
aspect_ratio = props.width / props.height
|
||||||
|
raster_x = ortho_scale * aspect_ratio * scale_ratio * props.dpi / 0.0254
|
||||||
|
raster_y = ortho_scale * scale_ratio * props.dpi / 0.0254
|
||||||
|
|
||||||
|
scene.render.resolution_x = scene.camera.data.BIMCameraProperties.raster_x = int(raster_x)
|
||||||
|
scene.render.resolution_y = scene.camera.data.BIMCameraProperties.raster_y = int(raster_y)
|
||||||
|
|
||||||
current_drawing = scene.DocProperties.drawings[scene.DocProperties.current_drawing_index]
|
current_drawing = scene.DocProperties.drawings[scene.DocProperties.current_drawing_index]
|
||||||
|
|||||||
@@ -312,7 +312,6 @@ class DocProperties(PropertyGroup):
|
|||||||
should_use_underlay_cache: BoolProperty(name="Use Underlay Cache", default=False)
|
should_use_underlay_cache: BoolProperty(name="Use Underlay Cache", default=False)
|
||||||
should_use_linework_cache: BoolProperty(name="Use Linework Cache", default=False)
|
should_use_linework_cache: BoolProperty(name="Use Linework Cache", default=False)
|
||||||
should_use_annotation_cache: BoolProperty(name="Use Annotation Cache", default=False)
|
should_use_annotation_cache: BoolProperty(name="Use Annotation Cache", default=False)
|
||||||
should_extract: BoolProperty(name="Should Extract", default=True)
|
|
||||||
is_editing_drawings: BoolProperty(name="Is Editing Drawings", default=False)
|
is_editing_drawings: BoolProperty(name="Is Editing Drawings", default=False)
|
||||||
is_editing_schedules: BoolProperty(name="Is Editing Schedules", default=False)
|
is_editing_schedules: BoolProperty(name="Is Editing Schedules", default=False)
|
||||||
is_editing_references: BoolProperty(name="Is Editing References", default=False)
|
is_editing_references: BoolProperty(name="Is Editing References", default=False)
|
||||||
@@ -375,6 +374,9 @@ class BIMCameraProperties(PropertyGroup):
|
|||||||
custom_scale_denominator: bpy.props.StringProperty(default="100", update=update_diagram_scale)
|
custom_scale_denominator: bpy.props.StringProperty(default="100", update=update_diagram_scale)
|
||||||
raster_x: IntProperty(name="Raster X", default=1000)
|
raster_x: IntProperty(name="Raster X", default=1000)
|
||||||
raster_y: IntProperty(name="Raster Y", default=1000)
|
raster_y: IntProperty(name="Raster Y", default=1000)
|
||||||
|
dpi: IntProperty(name="DPI", default=75)
|
||||||
|
width: FloatProperty(name="Width", default=50, subtype="DISTANCE")
|
||||||
|
height: FloatProperty(name="Height", default=50, subtype="DISTANCE")
|
||||||
is_nts: BoolProperty(name="Is NTS", update=update_is_nts)
|
is_nts: BoolProperty(name="Is NTS", update=update_is_nts)
|
||||||
active_drawing_style_index: IntProperty(name="Active Drawing Style Index")
|
active_drawing_style_index: IntProperty(name="Active Drawing Style Index")
|
||||||
|
|
||||||
|
|||||||
@@ -39,21 +39,20 @@ class BIM_PT_camera(Panel):
|
|||||||
bl_parent_id = "BIM_PT_tab_drawings"
|
bl_parent_id = "BIM_PT_tab_drawings"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
if not (context.scene.camera and hasattr(context.active_object.data, "BIMCameraProperties")):
|
if not (context.scene.camera and hasattr(context.scene.camera.data, "BIMCameraProperties")):
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.label(text="No Active Drawing", icon="ERROR")
|
row.label(text="No Active Drawing", icon="ERROR")
|
||||||
|
|
||||||
layout = self.layout
|
|
||||||
|
|
||||||
if "/" not in context.active_object.name:
|
|
||||||
layout.label(text="This is not a BIM camera.")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.use_property_split = True
|
if "/" not in context.scene.camera.name:
|
||||||
dprops = context.scene.DocProperties
|
self.layout.label(text="This is not a BIM camera.")
|
||||||
props = context.active_object.data.BIMCameraProperties
|
return
|
||||||
|
|
||||||
col = layout.column(align=True)
|
self.layout.use_property_split = True
|
||||||
|
dprops = context.scene.DocProperties
|
||||||
|
props = context.scene.camera.data.BIMCameraProperties
|
||||||
|
|
||||||
|
col = self.layout.column(align=True)
|
||||||
row = col.row(align=True)
|
row = col.row(align=True)
|
||||||
row.prop(props, "has_underlay", icon="OUTLINER_OB_IMAGE")
|
row.prop(props, "has_underlay", icon="OUTLINER_OB_IMAGE")
|
||||||
row.prop(dprops, "should_use_underlay_cache", text="", icon="FILE_REFRESH")
|
row.prop(dprops, "should_use_underlay_cache", text="", icon="FILE_REFRESH")
|
||||||
@@ -64,32 +63,36 @@ class BIM_PT_camera(Panel):
|
|||||||
row.prop(props, "has_annotation", icon="MOD_EDGESPLIT")
|
row.prop(props, "has_annotation", icon="MOD_EDGESPLIT")
|
||||||
row.prop(dprops, "should_use_annotation_cache", text="", icon="FILE_REFRESH")
|
row.prop(dprops, "should_use_annotation_cache", text="", icon="FILE_REFRESH")
|
||||||
|
|
||||||
row = layout.row()
|
row = self.layout.row()
|
||||||
row.prop(props, "calculate_shapely_surfaces")
|
row.prop(props, "calculate_shapely_surfaces")
|
||||||
row = layout.row()
|
row = self.layout.row()
|
||||||
row.prop(props, "calculate_svgfill_surfaces")
|
row.prop(props, "calculate_svgfill_surfaces")
|
||||||
|
|
||||||
row = layout.row()
|
row = self.layout.row()
|
||||||
row.prop(dprops, "should_extract")
|
row.prop(props, "width")
|
||||||
|
row = self.layout.row()
|
||||||
|
row.prop(props, "height")
|
||||||
|
|
||||||
row = layout.row()
|
row = self.layout.row()
|
||||||
row.prop(props, "raster_x")
|
row.prop(context.scene.camera.data, "clip_end", text="Depth")
|
||||||
row = layout.row()
|
|
||||||
row.prop(props, "raster_y")
|
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "diagram_scale")
|
row.prop(props, "diagram_scale", text="Scale")
|
||||||
row.prop(props, "is_nts", text="", icon="MOD_EDGESPLIT")
|
row.prop(props, "is_nts", text="", icon="MOD_EDGESPLIT")
|
||||||
|
|
||||||
if props.diagram_scale == "CUSTOM":
|
if props.diagram_scale == "CUSTOM":
|
||||||
row = layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(props, "custom_scale_numerator", text="Custom Scale")
|
row.prop(props, "custom_scale_numerator", text="Custom Scale")
|
||||||
row.prop(props, "custom_scale_denominator", text="")
|
row.prop(props, "custom_scale_denominator", text="")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
if props.has_underlay:
|
||||||
|
row = self.layout.row()
|
||||||
|
row.prop(props, "dpi")
|
||||||
|
|
||||||
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.create_drawing", text="Create Drawing", icon="OUTPUT")
|
row.operator("bim.create_drawing", text="Create Drawing", icon="OUTPUT")
|
||||||
op = row.operator("bim.open_drawing", icon="URL", text="")
|
op = row.operator("bim.open_drawing", icon="URL", text="")
|
||||||
op.view = context.active_object.name.split("/")[1]
|
op.view = context.scene.camera.name.split("/")[1]
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_drawing_underlay(Panel):
|
class BIM_PT_drawing_underlay(Panel):
|
||||||
|
|||||||
@@ -633,16 +633,11 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
camera.show_limits = True
|
camera.show_limits = True
|
||||||
|
|
||||||
if camera_type == "ORTHO":
|
if camera_type == "ORTHO":
|
||||||
camera.ortho_scale = width if width > height else height
|
|
||||||
camera.clip_start = 0.002 # Technically 0, but Blender doesn't allow this, so 2mm it is!
|
camera.clip_start = 0.002 # Technically 0, but Blender doesn't allow this, so 2mm it is!
|
||||||
camera.clip_end = depth
|
camera.clip_end = depth
|
||||||
|
|
||||||
if width > height:
|
camera.BIMCameraProperties.width = width
|
||||||
camera.BIMCameraProperties.raster_x = 1000
|
camera.BIMCameraProperties.height = height
|
||||||
camera.BIMCameraProperties.raster_y = round(1000 * (height / width))
|
|
||||||
else:
|
|
||||||
camera.BIMCameraProperties.raster_x = round(1000 * (width / height))
|
|
||||||
camera.BIMCameraProperties.raster_y = 1000
|
|
||||||
elif camera_type == "PERSP":
|
elif camera_type == "PERSP":
|
||||||
abs_min_z = abs(min(z))
|
abs_min_z = abs(min(z))
|
||||||
abs_max_z = abs(max(z))
|
abs_max_z = abs(max(z))
|
||||||
@@ -650,14 +645,13 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
camera.clip_end = abs_min_z
|
camera.clip_end = abs_min_z
|
||||||
max_res = 1000
|
max_res = 1000
|
||||||
|
|
||||||
|
camera.BIMCameraProperties.width = width
|
||||||
|
camera.BIMCameraProperties.height = height
|
||||||
|
|
||||||
if width > height:
|
if width > height:
|
||||||
fov = 2 * math.atan(width / (2 * abs_min_z))
|
fov = 2 * math.atan(width / (2 * abs_min_z))
|
||||||
camera.BIMCameraProperties.raster_x = max_res
|
|
||||||
camera.BIMCameraProperties.raster_y = int(max_res / (width / height))
|
|
||||||
else:
|
else:
|
||||||
fov = 2 * math.atan(height / (2 * abs_min_z))
|
fov = 2 * math.atan(height / (2 * abs_min_z))
|
||||||
camera.BIMCameraProperties.raster_y = max_res
|
|
||||||
camera.BIMCameraProperties.raster_x = int(max_res * (width / height))
|
|
||||||
|
|
||||||
camera.angle = fov
|
camera.angle = fov
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user