mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
Create interface panel to select external materials
This commit is contained in:
@@ -29,8 +29,10 @@ classes = (
|
|||||||
operator.SelectAudited,
|
operator.SelectAudited,
|
||||||
operator.RejectElement,
|
operator.RejectElement,
|
||||||
ui.BIMProperties,
|
ui.BIMProperties,
|
||||||
|
ui.MaterialProperties,
|
||||||
ui.BIMPanel,
|
ui.BIMPanel,
|
||||||
ui.MVDPanel,
|
ui.MVDPanel,
|
||||||
|
ui.MaterialPanel,
|
||||||
)
|
)
|
||||||
|
|
||||||
def menu_func_export(self, context):
|
def menu_func_export(self, context):
|
||||||
@@ -47,6 +49,7 @@ def register():
|
|||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
||||||
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)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
@@ -54,6 +57,7 @@ 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)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|||||||
@@ -1064,7 +1064,7 @@ class IfcExporter():
|
|||||||
def create_styled_item(self, item, representation_item=None):
|
def create_styled_item(self, item, representation_item=None):
|
||||||
styles = []
|
styles = []
|
||||||
styles.append(self.create_surface_style_rendering(item))
|
styles.append(self.create_surface_style_rendering(item))
|
||||||
if 'IsExternal' in item['raw'].keys():
|
if item['raw'].MaterialProperties.is_external:
|
||||||
styles.append(self.file.create_entity('IfcExternallyDefinedSurfaceStyle',
|
styles.append(self.file.create_entity('IfcExternallyDefinedSurfaceStyle',
|
||||||
**self.get_material_external_definition(item['raw'])))
|
**self.get_material_external_definition(item['raw'])))
|
||||||
surface_style = self.file.createIfcSurfaceStyle(None, 'BOTH', styles)
|
surface_style = self.file.createIfcSurfaceStyle(None, 'BOTH', styles)
|
||||||
@@ -1105,9 +1105,9 @@ class IfcExporter():
|
|||||||
|
|
||||||
def get_material_external_definition(self, material):
|
def get_material_external_definition(self, material):
|
||||||
return {
|
return {
|
||||||
'Location': material['Location'],
|
'Location': material.MaterialProperties.location,
|
||||||
'Identification': material['Identification'] if 'Identification' in material else material.name,
|
'Identification': material.MaterialProperties.identification if material.MaterialProperties.identification else material.name,
|
||||||
'Name': material['Name'] if 'Name' in material else material.name
|
'Name': material.MaterialProperties.name if material.MaterialProperties.name else material.name
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_colour_rgb(self, colour):
|
def create_colour_rgb(self, colour):
|
||||||
|
|||||||
@@ -35,9 +35,35 @@ class BIMProperties(bpy.types.PropertyGroup):
|
|||||||
export_has_representations: bpy.props.BoolProperty(name="Export Representations", default=True)
|
export_has_representations: bpy.props.BoolProperty(name="Export Representations", default=True)
|
||||||
qa_reject_element_reason: bpy.props.StringProperty(name="Element rejection reason")
|
qa_reject_element_reason: bpy.props.StringProperty(name="Element rejection reason")
|
||||||
|
|
||||||
|
class MaterialProperties(bpy.types.PropertyGroup):
|
||||||
|
is_external: bpy.props.BoolProperty(name="Has External Definition")
|
||||||
|
location: bpy.props.StringProperty(name="Location")
|
||||||
|
identification: bpy.props.StringProperty(name="Identification")
|
||||||
|
name: bpy.props.StringProperty(name="Name")
|
||||||
|
|
||||||
|
class MaterialPanel(bpy.types.Panel):
|
||||||
|
bl_label = 'IFC Materials'
|
||||||
|
bl_idname = 'BIM_PT_material'
|
||||||
|
bl_space_type = 'PROPERTIES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_context = 'material'
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
if not bpy.context.active_object.active_material:
|
||||||
|
return
|
||||||
|
layout = self.layout
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'is_external')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'location')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'identification')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.active_material.MaterialProperties, 'name')
|
||||||
|
|
||||||
class BIMPanel(bpy.types.Panel):
|
class BIMPanel(bpy.types.Panel):
|
||||||
bl_label = "Building Information Modeling"
|
bl_label = "Building Information Modeling"
|
||||||
bl_idname = "bim.panel"
|
bl_idname = "BIM_PT_bim"
|
||||||
bl_space_type = 'PROPERTIES'
|
bl_space_type = 'PROPERTIES'
|
||||||
bl_region_type = 'WINDOW'
|
bl_region_type = 'WINDOW'
|
||||||
bl_context = "scene"
|
bl_context = "scene"
|
||||||
@@ -95,7 +121,7 @@ class BIMPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
class MVDPanel(bpy.types.Panel):
|
class MVDPanel(bpy.types.Panel):
|
||||||
bl_label = "Model View Definitions"
|
bl_label = "Model View Definitions"
|
||||||
bl_idname = "mvd.panel"
|
bl_idname = "BIM_PT_mvd"
|
||||||
bl_space_type = 'PROPERTIES'
|
bl_space_type = 'PROPERTIES'
|
||||||
bl_region_type = 'WINDOW'
|
bl_region_type = 'WINDOW'
|
||||||
bl_context = "scene"
|
bl_context = "scene"
|
||||||
|
|||||||
Reference in New Issue
Block a user