mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Refactor operators into their own file and provide logging capabilities
This commit is contained in:
@@ -4,60 +4,6 @@ import os
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__)) + os.path.sep
|
||||
|
||||
class BIMOpAssignClass(bpy.types.Operator):
|
||||
bl_idname = 'bim.assign_class'
|
||||
bl_label = 'Assign IFC Class'
|
||||
|
||||
def execute(self, context):
|
||||
for object in bpy.context.selected_objects:
|
||||
existing_class = None
|
||||
if '/' in object.name \
|
||||
and object.name[0:3] == 'Ifc':
|
||||
existing_class = object.name.split('/')[0]
|
||||
if existing_class:
|
||||
object.name = '{}/{}'.format(
|
||||
bpy.context.scene.BIMProperties.ifc_class,
|
||||
object.name.split('/')[1])
|
||||
else:
|
||||
object.name = '{}/{}'.format(
|
||||
bpy.context.scene.BIMProperties.ifc_class,
|
||||
object.name)
|
||||
if existing_class != bpy.context.scene.BIMProperties.ifc_class \
|
||||
and 'IfcPredefinedType' in object.keys():
|
||||
del(object['IfcPredefinedType'])
|
||||
object['IfcPredefinedType'] = bpy.context.scene.BIMProperties.ifc_predefined_type
|
||||
if bpy.context.scene.BIMProperties.ifc_predefined_type == 'USERDEFINED':
|
||||
object['IfcObjectType'] = bpy.context.scene.BIMProperties.ifc_userdefined_type
|
||||
elif 'IfcObjectType' in object.keys():
|
||||
del(object['IfcObjectType'])
|
||||
return {'FINISHED'}
|
||||
|
||||
class BIMOpSelectDataDir(bpy.types.Operator):
|
||||
bl_idname = "bim.select_data_dir"
|
||||
bl_label = "Select Data Directory"
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BIMProperties.data_dir = self.filepath
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
class BIMOpSelectSchemaDir(bpy.types.Operator):
|
||||
bl_idname = "bim.select_schema_dir"
|
||||
bl_label = "Select Schema Directory"
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BIMProperties.schema_dir = self.filepath
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
class IfcSchema():
|
||||
def __init__(self):
|
||||
with open('{}ifc_elements_IFC4.json'.format(cwd + 'schema/')) as f:
|
||||
|
||||
Reference in New Issue
Block a user