Improved user friendly UI for sheet creation

This commit is contained in:
Dion Moult
2020-08-16 11:54:05 +10:00
parent b5acf81be2
commit b7bb7815ad
4 changed files with 66 additions and 48 deletions
@@ -115,10 +115,10 @@ if bpy is not None:
operator.AddSubcontext, operator.AddSubcontext,
operator.RemoveSubcontext, operator.RemoveSubcontext,
operator.CutSection, operator.CutSection,
operator.CreateSheet, operator.AddSheet,
operator.OpenSheet, operator.OpenSheet,
operator.OpenCompiledSheet, operator.OpenCompiledSheet,
operator.AddViewToSheet, operator.AddDrawingToSheet,
operator.CreateSheets, operator.CreateSheets,
operator.OpenView, operator.OpenView,
operator.ActivateView, operator.ActivateView,
@@ -185,6 +185,7 @@ if bpy is not None:
operator.ActivateDrawingStyle, operator.ActivateDrawingStyle,
operator.EditVectorStyle, operator.EditVectorStyle,
operator.PurgeProjectClassifications, operator.PurgeProjectClassifications,
operator.RemoveSheet,
prop.StrProperty, prop.StrProperty,
prop.Variable, prop.Variable,
prop.Role, prop.Role,
@@ -203,6 +204,7 @@ if bpy is not None:
prop.Constraint, prop.Constraint,
prop.Drawing, prop.Drawing,
prop.DrawingStyle, prop.DrawingStyle,
prop.Sheet,
prop.BcfTopic, prop.BcfTopic,
prop.BcfTopicLabel, prop.BcfTopicLabel,
prop.BcfTopicFile, prop.BcfTopicFile,
+30 -13
View File
@@ -2169,15 +2169,16 @@ class CutSection(bpy.types.Operator):
return bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y return bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y
class CreateSheet(bpy.types.Operator): class AddSheet(bpy.types.Operator):
bl_idname = 'bim.create_sheet' bl_idname = 'bim.add_sheet'
bl_label = 'Create Sheet' bl_label = 'Add Sheet'
def execute(self, context): def execute(self, context):
new = bpy.context.scene.DocProperties.sheets.add()
new.name = '{} - SHEET'.format(len(bpy.context.scene.DocProperties.sheets))
sheet_builder = sheeter.SheetBuilder() sheet_builder = sheeter.SheetBuilder()
sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir
sheet_builder.create(bpy.context.scene.DocProperties.sheet_name) sheet_builder.create(new.name)
bpy.context.scene.DocProperties.sheet_name = ''
return {'FINISHED'} return {'FINISHED'}
@@ -2186,9 +2187,10 @@ class OpenSheet(bpy.types.Operator):
bl_label = 'Open Sheet' bl_label = 'Open Sheet'
def execute(self, context): def execute(self, context):
props = bpy.context.scene.DocProperties
webbrowser.open('file://' + os.path.join( webbrowser.open('file://' + os.path.join(
bpy.context.scene.BIMProperties.data_dir, 'sheets', bpy.context.scene.BIMProperties.data_dir, 'sheets',
bpy.context.scene.DocProperties.available_sheets + '.svg')) props.sheets[props.active_sheet_index].name + '.svg'))
return {'FINISHED'} return {'FINISHED'}
@@ -2197,22 +2199,25 @@ class OpenCompiledSheet(bpy.types.Operator):
bl_label = 'Open Compiled Sheet' bl_label = 'Open Compiled Sheet'
def execute(self, context): def execute(self, context):
props = bpy.context.scene.DocProperties
webbrowser.open('file://' + os.path.join( webbrowser.open('file://' + os.path.join(
bpy.context.scene.BIMProperties.data_dir, 'build', bpy.context.scene.BIMProperties.data_dir, 'build',
bpy.context.scene.DocProperties.available_sheets, props.sheets[props.active_sheet_index].name,
bpy.context.scene.DocProperties.available_sheets + '.svg')) props.sheets[props.active_sheet_index].name + '.svg'))
return {'FINISHED'} return {'FINISHED'}
class AddViewToSheet(bpy.types.Operator): class AddDrawingToSheet(bpy.types.Operator):
bl_idname = 'bim.add_view_to_sheet' bl_idname = 'bim.add_drawing_to_sheet'
bl_label = 'Add View To Sheet' bl_label = 'Add Drawing To Sheet'
def execute(self, context): def execute(self, context):
props = bpy.context.scene.DocProperties props = bpy.context.scene.DocProperties
sheet_builder = sheeter.SheetBuilder() sheet_builder = sheeter.SheetBuilder()
sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir
sheet_builder.add_view(props.available_views, props.available_sheets) sheet_builder.add_view(
props.drawings[props.active_drawing_index].name,
props.sheets[props.active_sheet_index].name)
return {'FINISHED'} return {'FINISHED'}
@@ -2221,9 +2226,10 @@ class CreateSheets(bpy.types.Operator):
bl_label = 'Create Sheets' bl_label = 'Create Sheets'
def execute(self, context): def execute(self, context):
props = bpy.context.scene.DocProperties
sheet_builder = sheeter.SheetBuilder() sheet_builder = sheeter.SheetBuilder()
sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir sheet_builder.data_dir = bpy.context.scene.BIMProperties.data_dir
sheet_builder.build(bpy.context.scene.DocProperties.available_sheets) sheet_builder.build(props.sheets[props.active_sheet_index].name)
return {'FINISHED'} return {'FINISHED'}
@@ -3596,3 +3602,14 @@ class PurgeProjectClassifications(bpy.types.Operator):
prop.classification_enum.clear() prop.classification_enum.clear()
prop.getClassifications(self, context) prop.getClassifications(self, context)
return {'FINISHED'} return {'FINISHED'}
class RemoveSheet(bpy.types.Operator):
bl_idname = 'bim.remove_sheet'
bl_label = 'Remove Sheet'
index: bpy.props.IntProperty()
def execute(self, context):
props = bpy.context.scene.DocProperties
props.sheets.remove(self.index)
return {'FINISHED'}
+18 -18
View File
@@ -403,22 +403,6 @@ def getTargetViews(self, context):
return target_views_enum return target_views_enum
def refreshSheets(self, context):
global sheets_enum
sheets_enum.clear()
getSheets(self, context)
def getSheets(self, context):
global sheets_enum
if len(sheets_enum) < 1:
sheets_enum.clear()
for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, 'sheets')).glob('*.svg'):
f = str(filename.stem)
sheets_enum.append((f, f, ''))
return sheets_enum
def getVectorStyles(self, context): def getVectorStyles(self, context):
global vector_styles_enum global vector_styles_enum
if len(vector_styles_enum) < 1: if len(vector_styles_enum) < 1:
@@ -453,6 +437,22 @@ class Drawing(PropertyGroup):
camera: PointerProperty(name='Camera', type=bpy.types.Object) camera: PointerProperty(name='Camera', type=bpy.types.Object)
class Sheet(PropertyGroup):
def set_name(self, new):
old = self.get('name')
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, 'sheets')
if old and os.path.isfile(os.path.join(path, old + '.svg')):
os.rename(os.path.join(path, old + '.svg'), os.path.join(path, new + '.svg'))
self['name'] = new
def get_name(self):
return self.get('name')
name: StringProperty(name='Name', get=get_name, set=set_name)
drawings: CollectionProperty(name='Drawings', type=Drawing)
active_drawing_index: IntProperty(name='Active Drawing Index')
class DrawingStyle(PropertyGroup): class DrawingStyle(PropertyGroup):
name: StringProperty(name='Name') name: StringProperty(name='Name')
raster_style: StringProperty(name='Raster Style') raster_style: StringProperty(name='Raster Style')
@@ -468,8 +468,8 @@ class DocProperties(PropertyGroup):
should_extract: BoolProperty(name="Should Extract", default=True) should_extract: BoolProperty(name="Should Extract", default=True)
drawings: CollectionProperty(name='Drawings', type=Drawing) drawings: CollectionProperty(name='Drawings', type=Drawing)
active_drawing_index: IntProperty(name='Active Drawing Index') active_drawing_index: IntProperty(name='Active Drawing Index')
sheet_name: StringProperty(name="Sheet Name", update=refreshSheets) sheets: CollectionProperty(name='Sheets', type=Sheet)
available_sheets: EnumProperty(items=getSheets, name="Available Sheets") active_sheet_index: IntProperty(name='Active Sheet Index')
ifc_files: CollectionProperty(name='IFCs', type=StrProperty) ifc_files: CollectionProperty(name='IFCs', type=StrProperty)
drawing_styles: CollectionProperty(name='Drawing Styles', type=DrawingStyle) drawing_styles: CollectionProperty(name='Drawing Styles', type=DrawingStyle)
+14 -15
View File
@@ -718,7 +718,7 @@ class BIM_PT_gis(Panel):
class BIM_PT_drawings(Panel): class BIM_PT_drawings(Panel):
bl_label = "Drawings" bl_label = "SVG Drawings"
bl_idname = "BIM_PT_drawings" bl_idname = "BIM_PT_drawings"
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
@@ -729,18 +729,16 @@ class BIM_PT_drawings(Panel):
layout.use_property_split = True layout.use_property_split = True
props = bpy.context.scene.DocProperties props = bpy.context.scene.DocProperties
row = layout.row(align=True)
row.operator('bim.add_drawing')
if props.drawings: if props.drawings:
row = layout.row(align=True)
row.operator('bim.add_drawing')
op = row.operator('bim.open_view', icon='URL', text='') op = row.operator('bim.open_view', icon='URL', text='')
op.view = props.drawings[props.active_drawing_index].name op.view = props.drawings[props.active_drawing_index].name
row.operator('bim.activate_view', icon='SCENE', text='') row.operator('bim.activate_view', icon='SCENE', text='')
row.operator('bim.remove_drawing', icon='X', text='').index = props.active_drawing_index row.operator('bim.remove_drawing', icon='X', text='').index = props.active_drawing_index
layout.template_list('BIM_UL_generic', '', props, 'drawings', props, 'active_drawing_index') layout.template_list('BIM_UL_generic', '', props, 'drawings', props, 'active_drawing_index')
else:
row = layout.row(align=True)
row.operator('bim.add_drawing')
row = layout.row() row = layout.row()
row.operator('bim.add_ifc_file') row.operator('bim.add_ifc_file')
@@ -753,7 +751,7 @@ class BIM_PT_drawings(Panel):
class BIM_PT_sheets(Panel): class BIM_PT_sheets(Panel):
bl_label = "Sheets" bl_label = "SVG Sheets"
bl_idname = "BIM_PT_sheets" bl_idname = "BIM_PT_sheets"
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
@@ -764,17 +762,18 @@ class BIM_PT_sheets(Panel):
layout.use_property_split = True layout.use_property_split = True
props = bpy.context.scene.DocProperties props = bpy.context.scene.DocProperties
row = layout.row() row = layout.row(align=True)
row.prop(props, 'sheet_name') row.operator('bim.add_sheet')
row.operator('bim.create_sheet', icon='ADD', text='')
row = layout.row() if props.sheets:
row.prop(props, 'available_sheets') row.operator('bim.open_sheet', icon='URL', text='')
row.operator('bim.open_sheet', icon='URL', text='') row.operator('bim.open_compiled_sheet', icon='OUTPUT', text='')
row.operator('bim.open_compiled_sheet', icon='OUTPUT', text='') row.operator('bim.remove_sheet', icon='X', text='').index = props.active_sheet_index
layout.template_list('BIM_UL_generic', '', props, 'sheets', props, 'active_sheet_index')
row = layout.row(align=True) row = layout.row(align=True)
row.operator('bim.add_view_to_sheet') row.operator('bim.add_drawing_to_sheet')
row.operator('bim.create_sheets') row.operator('bim.create_sheets')