New interface to quickly create a new view for documentation

This commit is contained in:
Dion Moult
2020-01-06 10:41:59 +11:00
parent 642738e0c0
commit 461b1735dd
3 changed files with 25 additions and 0 deletions
@@ -759,6 +759,25 @@ class RemoveSubcontext(bpy.types.Operator):
return {'FINISHED'}
class CreateView(bpy.types.Operator):
bl_idname = 'bim.create_view'
bl_label = 'Create View'
def execute(self, context):
if not bpy.data.collections.get('Views'):
bpy.context.scene.collection.children.link(bpy.data.collections.new('Views'))
views_collection = bpy.data.collections.get('Views')
view_collection = bpy.data.collections.new(bpy.context.scene.DocProperties.view_name)
views_collection.children.link(view_collection)
camera = bpy.data.objects.new(bpy.context.scene.DocProperties.view_name, bpy.data.cameras.new(bpy.context.scene.DocProperties.view_name))
camera.data.type = 'ORTHO'
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')
area.spaces[0].region_3d.view_perspective = 'CAMERA'
return {'FINISHED'}
class CutSection(bpy.types.Operator):
bl_idname = 'bim.cut_section'
bl_label = 'Cut Section'
+1
View File
@@ -217,6 +217,7 @@ class Subcontext(PropertyGroup):
class DocProperties(PropertyGroup):
diagram_scale: EnumProperty(items=getDiagramScales, name='Diagram Scale')
should_recut: BoolProperty(name="Should Recut", default=True)
view_name: StringProperty(name="View Name")
class BIMProperties(PropertyGroup):
+5
View File
@@ -191,8 +191,13 @@ class BIM_PT_documentation(Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
props = bpy.context.scene.DocProperties
row = layout.row()
row.prop(props, 'view_name')
row.operator('bim.create_view', icon='ADD', text='')
row = layout.row()
row.prop(props, 'should_recut')