mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Improved user friendly UI for sheet creation
This commit is contained in:
@@ -115,10 +115,10 @@ if bpy is not None:
|
||||
operator.AddSubcontext,
|
||||
operator.RemoveSubcontext,
|
||||
operator.CutSection,
|
||||
operator.CreateSheet,
|
||||
operator.AddSheet,
|
||||
operator.OpenSheet,
|
||||
operator.OpenCompiledSheet,
|
||||
operator.AddViewToSheet,
|
||||
operator.AddDrawingToSheet,
|
||||
operator.CreateSheets,
|
||||
operator.OpenView,
|
||||
operator.ActivateView,
|
||||
@@ -185,6 +185,7 @@ if bpy is not None:
|
||||
operator.ActivateDrawingStyle,
|
||||
operator.EditVectorStyle,
|
||||
operator.PurgeProjectClassifications,
|
||||
operator.RemoveSheet,
|
||||
prop.StrProperty,
|
||||
prop.Variable,
|
||||
prop.Role,
|
||||
@@ -203,6 +204,7 @@ if bpy is not None:
|
||||
prop.Constraint,
|
||||
prop.Drawing,
|
||||
prop.DrawingStyle,
|
||||
prop.Sheet,
|
||||
prop.BcfTopic,
|
||||
prop.BcfTopicLabel,
|
||||
prop.BcfTopicFile,
|
||||
|
||||
@@ -2169,15 +2169,16 @@ class CutSection(bpy.types.Operator):
|
||||
return bpy.context.scene.render.resolution_x > bpy.context.scene.render.resolution_y
|
||||
|
||||
|
||||
class CreateSheet(bpy.types.Operator):
|
||||
bl_idname = 'bim.create_sheet'
|
||||
bl_label = 'Create Sheet'
|
||||
class AddSheet(bpy.types.Operator):
|
||||
bl_idname = 'bim.add_sheet'
|
||||
bl_label = 'Add Sheet'
|
||||
|
||||
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.data_dir = bpy.context.scene.BIMProperties.data_dir
|
||||
sheet_builder.create(bpy.context.scene.DocProperties.sheet_name)
|
||||
bpy.context.scene.DocProperties.sheet_name = ''
|
||||
sheet_builder.create(new.name)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@@ -2186,9 +2187,10 @@ class OpenSheet(bpy.types.Operator):
|
||||
bl_label = 'Open Sheet'
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.DocProperties
|
||||
webbrowser.open('file://' + os.path.join(
|
||||
bpy.context.scene.BIMProperties.data_dir, 'sheets',
|
||||
bpy.context.scene.DocProperties.available_sheets + '.svg'))
|
||||
props.sheets[props.active_sheet_index].name + '.svg'))
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@@ -2197,22 +2199,25 @@ class OpenCompiledSheet(bpy.types.Operator):
|
||||
bl_label = 'Open Compiled Sheet'
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.DocProperties
|
||||
webbrowser.open('file://' + os.path.join(
|
||||
bpy.context.scene.BIMProperties.data_dir, 'build',
|
||||
bpy.context.scene.DocProperties.available_sheets,
|
||||
bpy.context.scene.DocProperties.available_sheets + '.svg'))
|
||||
props.sheets[props.active_sheet_index].name,
|
||||
props.sheets[props.active_sheet_index].name + '.svg'))
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class AddViewToSheet(bpy.types.Operator):
|
||||
bl_idname = 'bim.add_view_to_sheet'
|
||||
bl_label = 'Add View To Sheet'
|
||||
class AddDrawingToSheet(bpy.types.Operator):
|
||||
bl_idname = 'bim.add_drawing_to_sheet'
|
||||
bl_label = 'Add Drawing To Sheet'
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.DocProperties
|
||||
sheet_builder = sheeter.SheetBuilder()
|
||||
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'}
|
||||
|
||||
|
||||
@@ -2221,9 +2226,10 @@ class CreateSheets(bpy.types.Operator):
|
||||
bl_label = 'Create Sheets'
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.DocProperties
|
||||
sheet_builder = sheeter.SheetBuilder()
|
||||
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'}
|
||||
|
||||
|
||||
@@ -3596,3 +3602,14 @@ class PurgeProjectClassifications(bpy.types.Operator):
|
||||
prop.classification_enum.clear()
|
||||
prop.getClassifications(self, context)
|
||||
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'}
|
||||
|
||||
@@ -403,22 +403,6 @@ def getTargetViews(self, context):
|
||||
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):
|
||||
global vector_styles_enum
|
||||
if len(vector_styles_enum) < 1:
|
||||
@@ -453,6 +437,22 @@ class Drawing(PropertyGroup):
|
||||
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):
|
||||
name: StringProperty(name='Name')
|
||||
raster_style: StringProperty(name='Raster Style')
|
||||
@@ -468,8 +468,8 @@ class DocProperties(PropertyGroup):
|
||||
should_extract: BoolProperty(name="Should Extract", default=True)
|
||||
drawings: CollectionProperty(name='Drawings', type=Drawing)
|
||||
active_drawing_index: IntProperty(name='Active Drawing Index')
|
||||
sheet_name: StringProperty(name="Sheet Name", update=refreshSheets)
|
||||
available_sheets: EnumProperty(items=getSheets, name="Available Sheets")
|
||||
sheets: CollectionProperty(name='Sheets', type=Sheet)
|
||||
active_sheet_index: IntProperty(name='Active Sheet Index')
|
||||
ifc_files: CollectionProperty(name='IFCs', type=StrProperty)
|
||||
drawing_styles: CollectionProperty(name='Drawing Styles', type=DrawingStyle)
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ class BIM_PT_gis(Panel):
|
||||
|
||||
|
||||
class BIM_PT_drawings(Panel):
|
||||
bl_label = "Drawings"
|
||||
bl_label = "SVG Drawings"
|
||||
bl_idname = "BIM_PT_drawings"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
@@ -729,18 +729,16 @@ class BIM_PT_drawings(Panel):
|
||||
layout.use_property_split = True
|
||||
props = bpy.context.scene.DocProperties
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.add_drawing')
|
||||
|
||||
if props.drawings:
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.add_drawing')
|
||||
op = row.operator('bim.open_view', icon='URL', text='')
|
||||
op.view = props.drawings[props.active_drawing_index].name
|
||||
row.operator('bim.activate_view', icon='SCENE', text='')
|
||||
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')
|
||||
else:
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.add_drawing')
|
||||
|
||||
row = layout.row()
|
||||
row.operator('bim.add_ifc_file')
|
||||
@@ -753,7 +751,7 @@ class BIM_PT_drawings(Panel):
|
||||
|
||||
|
||||
class BIM_PT_sheets(Panel):
|
||||
bl_label = "Sheets"
|
||||
bl_label = "SVG Sheets"
|
||||
bl_idname = "BIM_PT_sheets"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
@@ -764,17 +762,18 @@ class BIM_PT_sheets(Panel):
|
||||
layout.use_property_split = True
|
||||
props = bpy.context.scene.DocProperties
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'sheet_name')
|
||||
row.operator('bim.create_sheet', icon='ADD', text='')
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.add_sheet')
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'available_sheets')
|
||||
row.operator('bim.open_sheet', icon='URL', text='')
|
||||
row.operator('bim.open_compiled_sheet', icon='OUTPUT', text='')
|
||||
if props.sheets:
|
||||
row.operator('bim.open_sheet', icon='URL', 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.operator('bim.add_view_to_sheet')
|
||||
row.operator('bim.add_drawing_to_sheet')
|
||||
row.operator('bim.create_sheets')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user