Create legacy features to export materials into broken BIM programs like Revit

This commit is contained in:
Dion Moult
2019-11-08 15:10:51 +11:00
parent 80dccfeb54
commit 60b3daf686
3 changed files with 18 additions and 4 deletions
@@ -618,9 +618,10 @@ class IfcParser():
if not object.data:
continue
for slot in object.material_slots:
if slot.material.name in results \
or slot.link == 'DATA':
continue
if not self.ifc_export_settings.should_export_all_materials_as_styled_items:
if slot.material.name in results \
or slot.link == 'DATA':
continue
results.append({
'ifc': None,
'raw': slot.material,
@@ -1101,7 +1102,10 @@ class IfcExporter():
if item['raw'].BIMMaterialProperties.is_external:
styles.append(self.file.create_entity('IfcExternallyDefinedSurfaceStyle',
**self.get_material_external_definition(item['raw'])))
surface_style = self.file.createIfcSurfaceStyle(None, 'BOTH', styles)
# Name is filled out because Revit treats this incorrectly as the material name
surface_style = self.file.createIfcSurfaceStyle(item['attributes']['Name'], 'BOTH', styles)
if self.ifc_export_settings.should_use_presentation_style_assignment:
surface_style = self.file.createIfcPresentationStyleAssignment([surface_style])
return self.file.createIfcStyledItem(representation_item, [surface_style], item['attributes']['Name'])
def create_materials(self):
@@ -1654,6 +1658,8 @@ class IfcExportSettings:
self.subcontexts = ['Axis', 'FootPrint', 'Reference', 'Body', 'Clearance', 'CoG', 'SurveyPoints']
self.generated_subcontexts = ['Box']
self.target_views = ['GRAPH_VIEW', 'SKETCH_VIEW', 'MODEL_VIEW', 'PLAN_VIEW', 'REFLECTED_PLAN_VIEW', 'SECTION_VIEW', 'ELEVATION_VIEW', 'USERDEFINED', 'NOTDEFINED']
self.should_export_all_materials_as_styled_items = False
self.should_use_presentation_style_assignment = False
# TODO make this configurable via UI
self.context_tree = self.build_context_tree()
@@ -32,6 +32,8 @@ class ExportIFC(bpy.types.Operator):
ifc_export_settings.schema_dir = bpy.context.scene.BIMProperties.schema_dir
ifc_export_settings.output_file = bpy.path.ensure_ext(self.filepath, '.ifc')
ifc_export_settings.has_representations = bpy.context.scene.BIMProperties.export_has_representations
ifc_export_settings.should_export_all_materials_as_styled_items = bpy.context.scene.BIMProperties.export_should_export_all_materials_as_styled_items
ifc_export_settings.should_use_presentation_style_assignment = bpy.context.scene.BIMProperties.export_should_use_presentation_style_assignment
ifc_parser = export_ifc.IfcParser(ifc_export_settings)
ifc_schema = export_ifc.IfcSchema(ifc_export_settings)
qto_calculator = export_ifc.QtoCalculator()
+6
View File
@@ -61,6 +61,8 @@ class BIMProperties(bpy.types.PropertyGroup):
name="Predefined Type", default=None)
ifc_userdefined_type: bpy.props.StringProperty(name="Userdefined Type")
export_has_representations: bpy.props.BoolProperty(name="Export Representations", default=True)
export_should_export_all_materials_as_styled_items: bpy.props.BoolProperty(name="Export All Materials as Styled Items", default=False)
export_should_use_presentation_style_assignment: bpy.props.BoolProperty(name="Export with Presentation Style Assignment", default=False)
qa_reject_element_reason: bpy.props.StringProperty(name="Element Rejection Reason")
pset_name: bpy.props.EnumProperty(items=getPsetNames, name="Pset Name")
pset_file: bpy.props.EnumProperty(items=getPsetFiles, name="Pset File")
@@ -440,3 +442,7 @@ class MVDPanel(bpy.types.Panel):
row = layout.row()
row.prop(bim_properties, "export_has_representations")
row = layout.row()
row.prop(bim_properties, "export_should_export_all_materials_as_styled_items")
row = layout.row()
row.prop(bim_properties, "export_should_use_presentation_style_assignment")