mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
New interface to quickly create a new view for documentation
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user