Create interface panel to select external materials

This commit is contained in:
Dion Moult
2019-10-13 11:14:49 +11:00
parent 3db6f42f04
commit 4476cce08c
3 changed files with 36 additions and 6 deletions
@@ -29,8 +29,10 @@ classes = (
operator.SelectAudited,
operator.RejectElement,
ui.BIMProperties,
ui.MaterialProperties,
ui.BIMPanel,
ui.MVDPanel,
ui.MaterialPanel,
)
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_import.append(menu_func_import)
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=ui.BIMProperties)
bpy.types.Material.MaterialProperties = bpy.props.PointerProperty(type=ui.MaterialProperties)
def unregister():
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_import.remove(menu_func_import)
del(bpy.types.Scene.BIMProperties)
del(bpy.types.Scene.MaterialProperties)
if __name__ == "__main__":
register()
@@ -1064,7 +1064,7 @@ class IfcExporter():
def create_styled_item(self, item, representation_item=None):
styles = []
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',
**self.get_material_external_definition(item['raw'])))
surface_style = self.file.createIfcSurfaceStyle(None, 'BOTH', styles)
@@ -1105,9 +1105,9 @@ class IfcExporter():
def get_material_external_definition(self, material):
return {
'Location': material['Location'],
'Identification': material['Identification'] if 'Identification' in material else material.name,
'Name': material['Name'] if 'Name' in material else material.name
'Location': material.MaterialProperties.location,
'Identification': material.MaterialProperties.identification if material.MaterialProperties.identification else material.name,
'Name': material.MaterialProperties.name if material.MaterialProperties.name else material.name
}
def create_colour_rgb(self, colour):
+28 -2
View File
@@ -35,9 +35,35 @@ class BIMProperties(bpy.types.PropertyGroup):
export_has_representations: bpy.props.BoolProperty(name="Export Representations", default=True)
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):
bl_label = "Building Information Modeling"
bl_idname = "bim.panel"
bl_idname = "BIM_PT_bim"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
@@ -95,7 +121,7 @@ class BIMPanel(bpy.types.Panel):
class MVDPanel(bpy.types.Panel):
bl_label = "Model View Definitions"
bl_idname = "mvd.panel"
bl_idname = "BIM_PT_mvd"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"