mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 10:28:37 +00:00
Create legacy features to export materials into broken BIM programs like Revit
This commit is contained in:
@@ -618,9 +618,10 @@ class IfcParser():
|
|||||||
if not object.data:
|
if not object.data:
|
||||||
continue
|
continue
|
||||||
for slot in object.material_slots:
|
for slot in object.material_slots:
|
||||||
if slot.material.name in results \
|
if not self.ifc_export_settings.should_export_all_materials_as_styled_items:
|
||||||
or slot.link == 'DATA':
|
if slot.material.name in results \
|
||||||
continue
|
or slot.link == 'DATA':
|
||||||
|
continue
|
||||||
results.append({
|
results.append({
|
||||||
'ifc': None,
|
'ifc': None,
|
||||||
'raw': slot.material,
|
'raw': slot.material,
|
||||||
@@ -1101,7 +1102,10 @@ class IfcExporter():
|
|||||||
if item['raw'].BIMMaterialProperties.is_external:
|
if item['raw'].BIMMaterialProperties.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)
|
# 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'])
|
return self.file.createIfcStyledItem(representation_item, [surface_style], item['attributes']['Name'])
|
||||||
|
|
||||||
def create_materials(self):
|
def create_materials(self):
|
||||||
@@ -1654,6 +1658,8 @@ class IfcExportSettings:
|
|||||||
self.subcontexts = ['Axis', 'FootPrint', 'Reference', 'Body', 'Clearance', 'CoG', 'SurveyPoints']
|
self.subcontexts = ['Axis', 'FootPrint', 'Reference', 'Body', 'Clearance', 'CoG', 'SurveyPoints']
|
||||||
self.generated_subcontexts = ['Box']
|
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.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
|
# TODO make this configurable via UI
|
||||||
self.context_tree = self.build_context_tree()
|
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.schema_dir = bpy.context.scene.BIMProperties.schema_dir
|
||||||
ifc_export_settings.output_file = bpy.path.ensure_ext(self.filepath, '.ifc')
|
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.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_parser = export_ifc.IfcParser(ifc_export_settings)
|
||||||
ifc_schema = export_ifc.IfcSchema(ifc_export_settings)
|
ifc_schema = export_ifc.IfcSchema(ifc_export_settings)
|
||||||
qto_calculator = export_ifc.QtoCalculator()
|
qto_calculator = export_ifc.QtoCalculator()
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class BIMProperties(bpy.types.PropertyGroup):
|
|||||||
name="Predefined Type", default=None)
|
name="Predefined Type", default=None)
|
||||||
ifc_userdefined_type: bpy.props.StringProperty(name="Userdefined Type")
|
ifc_userdefined_type: bpy.props.StringProperty(name="Userdefined Type")
|
||||||
export_has_representations: bpy.props.BoolProperty(name="Export Representations", default=True)
|
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")
|
qa_reject_element_reason: bpy.props.StringProperty(name="Element Rejection Reason")
|
||||||
pset_name: bpy.props.EnumProperty(items=getPsetNames, name="Pset Name")
|
pset_name: bpy.props.EnumProperty(items=getPsetNames, name="Pset Name")
|
||||||
pset_file: bpy.props.EnumProperty(items=getPsetFiles, name="Pset File")
|
pset_file: bpy.props.EnumProperty(items=getPsetFiles, name="Pset File")
|
||||||
@@ -440,3 +442,7 @@ class MVDPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bim_properties, "export_has_representations")
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user