mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Drawing styles now can store rudimentary rendering settings
This commit is contained in:
@@ -137,8 +137,6 @@ if bpy is not None:
|
||||
operator.AssignContext,
|
||||
operator.SwitchContext,
|
||||
operator.RemoveContext,
|
||||
operator.SetViewPreset1,
|
||||
operator.SetViewPreset2,
|
||||
operator.OpenUpstream,
|
||||
operator.BIM_OT_CopyAttributesToSelection,
|
||||
operator.BIM_OT_ChangeClassificationLevel,
|
||||
|
||||
@@ -2425,44 +2425,6 @@ class RemoveContext(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SetViewPreset1(bpy.types.Operator):
|
||||
bl_idname = 'bim.set_view_preset_1'
|
||||
bl_label = 'Set View Preset 1'
|
||||
|
||||
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'
|
||||
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.view_settings.use_curve_mapping = True
|
||||
bpy.context.scene.view_settings.curve_mapping.curves[3].points.new(.4, 0) # Increase black contrast
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class OpenUpstream(bpy.types.Operator):
|
||||
bl_idname = 'bim.open_upstream'
|
||||
bl_label = 'Open Upstream Reference'
|
||||
@@ -3481,9 +3443,28 @@ class RemoveDrawingStyle(bpy.types.Operator):
|
||||
class SaveDrawingStyle(bpy.types.Operator):
|
||||
bl_idname = 'bim.save_drawing_style'
|
||||
bl_label = 'Save Drawing Style'
|
||||
index: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
# TODO
|
||||
style = {
|
||||
'bpy.data.worlds[0].color': tuple(bpy.data.worlds[0].color),
|
||||
'bpy.context.scene.render.engine': bpy.context.scene.render.engine,
|
||||
'bpy.context.scene.display.shading.show_object_outline': bpy.context.scene.display.shading.show_object_outline,
|
||||
'bpy.context.scene.display.shading.show_cavity': bpy.context.scene.display.shading.show_cavity,
|
||||
'bpy.context.scene.display.shading.cavity_type': bpy.context.scene.display.shading.cavity_type,
|
||||
'bpy.context.scene.display.shading.curvature_ridge_factor': bpy.context.scene.display.shading.curvature_ridge_factor,
|
||||
'bpy.context.scene.display.shading.curvature_valley_factor': bpy.context.scene.display.shading.curvature_valley_factor,
|
||||
'bpy.context.scene.view_settings.view_transform': bpy.context.scene.view_settings.view_transform,
|
||||
'bpy.context.scene.display.shading.light': bpy.context.scene.display.shading.light,
|
||||
'bpy.context.scene.display.shading.color_type': bpy.context.scene.display.shading.color_type,
|
||||
'bpy.context.scene.display.shading.single_color': tuple(bpy.context.scene.display.shading.single_color),
|
||||
'bpy.context.scene.view_settings.use_curve_mapping': bpy.context.scene.view_settings.use_curve_mapping,
|
||||
}
|
||||
if self.index:
|
||||
index = int(self.index)
|
||||
else:
|
||||
index = bpy.context.active_object.data.BIMCameraProperties.active_drawing_style_index
|
||||
bpy.context.scene.DocProperties.drawing_styles[index].raster_style = json.dumps(style)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@@ -3492,5 +3473,17 @@ class ActivateDrawingStyle(bpy.types.Operator):
|
||||
bl_label = 'Activate Drawing Style'
|
||||
|
||||
def execute(self, context):
|
||||
# TODO
|
||||
style = json.loads(bpy.context.scene.DocProperties.drawing_styles[bpy.context.active_object.data.BIMCameraProperties.active_drawing_style_index].raster_style)
|
||||
bpy.data.worlds[0].color = style['bpy.data.worlds[0].color']
|
||||
bpy.context.scene.render.engine = style['bpy.context.scene.render.engine']
|
||||
bpy.context.scene.display.shading.show_object_outline = style['bpy.context.scene.display.shading.show_object_outline']
|
||||
bpy.context.scene.display.shading.show_cavity = style['bpy.context.scene.display.shading.show_cavity']
|
||||
bpy.context.scene.display.shading.cavity_type = style['bpy.context.scene.display.shading.cavity_type']
|
||||
bpy.context.scene.display.shading.curvature_ridge_factor = style['bpy.context.scene.display.shading.curvature_ridge_factor']
|
||||
bpy.context.scene.display.shading.curvature_valley_factor = style['bpy.context.scene.display.shading.curvature_valley_factor']
|
||||
bpy.context.scene.view_settings.view_transform = style['bpy.context.scene.view_settings.view_transform']
|
||||
bpy.context.scene.display.shading.light = style['bpy.context.scene.display.shading.light']
|
||||
bpy.context.scene.display.shading.color_type = style['bpy.context.scene.display.shading.color_type']
|
||||
bpy.context.scene.display.shading.single_color = style['bpy.context.scene.display.shading.single_color']
|
||||
bpy.context.scene.view_settings.use_curve_mapping = style['bpy.context.scene.view_settings.use_curve_mapping']
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -59,6 +59,47 @@ def setDefaultProperties(scene):
|
||||
subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add()
|
||||
subcontext.name = 'Body'
|
||||
subcontext.target_view = 'MODEL_VIEW'
|
||||
subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add()
|
||||
subcontext.name = 'Box'
|
||||
subcontext.target_view = 'MODEL_VIEW'
|
||||
if len(bpy.context.scene.DocProperties.drawing_styles) == 0:
|
||||
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||
drawing_style.name = 'Blender Default'
|
||||
bpy.ops.bim.save_drawing_style(index='0')
|
||||
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||
drawing_style.name = 'Shaded'
|
||||
drawing_style.raster_style = json.dumps({
|
||||
'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': 'STUDIO',
|
||||
'bpy.context.scene.display.shading.color_type': 'MATERIAL',
|
||||
'bpy.context.scene.display.shading.single_color': (1, 1, 1),
|
||||
'bpy.context.scene.view_settings.use_curve_mapping': False,
|
||||
})
|
||||
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||
drawing_style.name = 'Technical'
|
||||
drawing_style.raster_style = json.dumps({
|
||||
'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.view_settings.use_curve_mapping': True,
|
||||
})
|
||||
# TODO: This is used for technical styles, but probably should not be hardcoded
|
||||
bpy.context.scene.view_settings.curve_mapping.curves[3].points.new(.4, 0) # Increase black contrast
|
||||
|
||||
|
||||
def getIfcPredefinedTypes(self, context):
|
||||
|
||||
@@ -728,10 +728,6 @@ class BIM_PT_documentation(Panel):
|
||||
layout.use_property_split = True
|
||||
props = bpy.context.scene.DocProperties
|
||||
|
||||
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', text='Drawing Name')
|
||||
row.operator('bim.create_view', icon='ADD', text='')
|
||||
@@ -885,8 +881,6 @@ class BIM_PT_camera(Panel):
|
||||
row.prop(drawing_style, 'name')
|
||||
row.operator('bim.remove_drawing_style', icon='X', text='').index = props.active_drawing_style_index
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(drawing_style, 'raster_style')
|
||||
row = layout.row(align=True)
|
||||
row.prop(drawing_style, 'vector_style')
|
||||
row = layout.row(align=True)
|
||||
@@ -894,6 +888,10 @@ class BIM_PT_camera(Panel):
|
||||
row = layout.row(align=True)
|
||||
row.prop(drawing_style, 'exclude_query')
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.save_drawing_style')
|
||||
row.operator('bim.activate_drawing_style')
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.cut_section', text='Create Drawing')
|
||||
op = row.operator('bim.open_view', icon='URL', text='')
|
||||
|
||||
Reference in New Issue
Block a user