mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Implement UI to toggle wireframe / swept solid, and assign profiles and extrusions
Also allow file browser to select a location for an external material
This commit is contained in:
@@ -28,11 +28,16 @@ classes = (
|
|||||||
operator.RejectClass,
|
operator.RejectClass,
|
||||||
operator.SelectAudited,
|
operator.SelectAudited,
|
||||||
operator.RejectElement,
|
operator.RejectElement,
|
||||||
|
operator.SelectExternalMaterialDir,
|
||||||
|
operator.AssignSweptSolidProfile,
|
||||||
|
operator.AssignSweptSolidExtrusion,
|
||||||
ui.BIMProperties,
|
ui.BIMProperties,
|
||||||
ui.MaterialProperties,
|
ui.MaterialProperties,
|
||||||
|
ui.MeshProperties,
|
||||||
ui.BIMPanel,
|
ui.BIMPanel,
|
||||||
ui.MVDPanel,
|
ui.MVDPanel,
|
||||||
ui.MaterialPanel,
|
ui.MaterialPanel,
|
||||||
|
ui.MeshPanel,
|
||||||
)
|
)
|
||||||
|
|
||||||
def menu_func_export(self, context):
|
def menu_func_export(self, context):
|
||||||
@@ -50,6 +55,7 @@ def register():
|
|||||||
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
||||||
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=ui.BIMProperties)
|
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=ui.BIMProperties)
|
||||||
bpy.types.Material.MaterialProperties = bpy.props.PointerProperty(type=ui.MaterialProperties)
|
bpy.types.Material.MaterialProperties = bpy.props.PointerProperty(type=ui.MaterialProperties)
|
||||||
|
bpy.types.Mesh.MeshProperties = bpy.props.PointerProperty(type=ui.MeshProperties)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
@@ -57,7 +63,8 @@ def unregister():
|
|||||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
||||||
del(bpy.types.Scene.BIMProperties)
|
del(bpy.types.Scene.BIMProperties)
|
||||||
del(bpy.types.Scene.MaterialProperties)
|
del(bpy.types.Material.MaterialProperties)
|
||||||
|
del(bpy.types.Mesh.MeshProperties)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|||||||
@@ -547,8 +547,8 @@ class IfcParser():
|
|||||||
'raw_object': object,
|
'raw_object': object,
|
||||||
'context': context,
|
'context': context,
|
||||||
'subcontext': subcontext,
|
'subcontext': subcontext,
|
||||||
'is_wireframe': True if 'IsWireframe' in mesh else False,
|
'is_wireframe': mesh.MeshProperties.is_wireframe,
|
||||||
'is_swept_solid': True if 'IsSweptSolid' in mesh else False,
|
'is_swept_solid': mesh.MeshProperties.is_swept_solid,
|
||||||
'is_generated': is_generated,
|
'is_generated': is_generated,
|
||||||
'attributes': { 'Name': mesh.name }
|
'attributes': { 'Name': mesh.name }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,6 +201,51 @@ class SelectAudited(bpy.types.Operator):
|
|||||||
object.select_set(True)
|
object.select_set(True)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class AssignSweptSolidProfile(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.assign_swept_solid_profile'
|
||||||
|
bl_label = 'Assign Profile'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if bpy.context.mode != 'EDIT_MESH':
|
||||||
|
return {'FINISHED'}
|
||||||
|
for vg in bpy.context.active_object.vertex_groups:
|
||||||
|
if vg.name == 'profile':
|
||||||
|
bpy.ops.object.vertex_group_set_active(group=vg.name)
|
||||||
|
bpy.ops.object.vertex_group_remove()
|
||||||
|
break
|
||||||
|
bpy.ops.object.vertex_group_assign_new()
|
||||||
|
bpy.context.active_object.vertex_groups[bpy.context.active_object.vertex_groups[-1].name].name = 'profile'
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class AssignSweptSolidExtrusion(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.assign_swept_solid_extrusion'
|
||||||
|
bl_label = 'Assign Extrusion'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if bpy.context.mode != 'EDIT_MESH':
|
||||||
|
return {'FINISHED'}
|
||||||
|
for vg in bpy.context.active_object.vertex_groups:
|
||||||
|
if vg.name == 'extrusion':
|
||||||
|
bpy.ops.object.vertex_group_set_active(group=vg.name)
|
||||||
|
bpy.ops.object.vertex_group_remove()
|
||||||
|
break
|
||||||
|
bpy.ops.object.vertex_group_assign_new()
|
||||||
|
bpy.context.active_object.vertex_groups[bpy.context.active_object.vertex_groups[-1].name].name = 'extrusion'
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class SelectExternalMaterialDir(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.select_external_material_dir"
|
||||||
|
bl_label = "Select Material File"
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.context.active_object.active_material.MaterialProperties.location = self.filepath
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
class SelectDataDir(bpy.types.Operator):
|
class SelectDataDir(bpy.types.Operator):
|
||||||
bl_idname = "bim.select_data_dir"
|
bl_idname = "bim.select_data_dir"
|
||||||
bl_label = "Select Data Directory"
|
bl_label = "Select Data Directory"
|
||||||
|
|||||||
@@ -41,6 +41,29 @@ class MaterialProperties(bpy.types.PropertyGroup):
|
|||||||
identification: bpy.props.StringProperty(name="Identification")
|
identification: bpy.props.StringProperty(name="Identification")
|
||||||
name: bpy.props.StringProperty(name="Name")
|
name: bpy.props.StringProperty(name="Name")
|
||||||
|
|
||||||
|
class MeshProperties(bpy.types.PropertyGroup):
|
||||||
|
is_wireframe: bpy.props.BoolProperty(name="Is Wireframe")
|
||||||
|
is_swept_solid: bpy.props.BoolProperty(name="Is Swept Solid")
|
||||||
|
|
||||||
|
class MeshPanel(bpy.types.Panel):
|
||||||
|
bl_label = 'IFC Representations'
|
||||||
|
bl_idname = 'BIM_PT_mesh'
|
||||||
|
bl_space_type = 'PROPERTIES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_context = 'data'
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
if not bpy.context.active_object.data:
|
||||||
|
return
|
||||||
|
layout = self.layout
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.data.MeshProperties, 'is_wireframe')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.data.MeshProperties, 'is_swept_solid')
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.operator('bim.assign_swept_solid_profile')
|
||||||
|
row.operator('bim.assign_swept_solid_extrusion')
|
||||||
|
|
||||||
class MaterialPanel(bpy.types.Panel):
|
class MaterialPanel(bpy.types.Panel):
|
||||||
bl_label = 'IFC Materials'
|
bl_label = 'IFC Materials'
|
||||||
bl_idname = 'BIM_PT_material'
|
bl_idname = 'BIM_PT_material'
|
||||||
@@ -54,8 +77,9 @@ class MaterialPanel(bpy.types.Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'is_external')
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'is_external')
|
||||||
row = layout.row()
|
row = layout.row(align=True)
|
||||||
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'location')
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'location')
|
||||||
|
row.operator('bim.select_external_material_dir', icon="FILE_FOLDER", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'identification')
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'identification')
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user