From 19c8d13e86316e1378d7ed496908fea8ac8d5de5 Mon Sep 17 00:00:00 2001 From: krande Date: Sun, 1 Nov 2020 15:59:43 +0100 Subject: [PATCH 01/15] Started on PresentationLayer support. Made necessary change to props set_unit enumerate list of tuples to adhere to actual IFC naming. --- src/ifcblenderexport/blenderbim/__init__.py | 1 - .../blenderbim/bim/data/process.log | 20 ++ src/ifcblenderexport/blenderbim/bim/prop.py | 181 +++++++++++------- .../blenderbim/libs/site/packages/.gitignore | 4 + 4 files changed, 140 insertions(+), 66 deletions(-) create mode 100644 src/ifcblenderexport/blenderbim/bim/data/process.log create mode 100644 src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore diff --git a/src/ifcblenderexport/blenderbim/__init__.py b/src/ifcblenderexport/blenderbim/__init__.py index e282983a11..731c1ccd17 100644 --- a/src/ifcblenderexport/blenderbim/__init__.py +++ b/src/ifcblenderexport/blenderbim/__init__.py @@ -19,7 +19,6 @@ import site cwd = os.path.dirname(os.path.realpath(__file__)) site.addsitedir(os.path.join(cwd, "libs", "site", "packages")) - # main import from .bim import * diff --git a/src/ifcblenderexport/blenderbim/bim/data/process.log b/src/ifcblenderexport/blenderbim/bim/data/process.log new file mode 100644 index 0000000000..aab92faf3c --- /dev/null +++ b/src/ifcblenderexport/blenderbim/bim/data/process.log @@ -0,0 +1,20 @@ +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Creating object #20=IfcProject('3UJCj26s8HwxY$cAzbL1eO',#5,'MyLayersProject',$,$,$,$,(#11),#19) +INFO:ImportIFC:Creating object #29=IfcSite('3U8zIK6s8HwvkacAzbL1eO',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) +INFO:ImportIFC:Creating object #96=IfcBuilding('3U9f4w6s8Hww4PcAzbL1eO',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) +INFO:ImportIFC:Creating object #89=IfcBeamType('3UK2QY6s8HwwC4cAzbL1eO',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) +INFO:ImportIFC:Creating object #113=IfcBeam('3U9wAe6s8HwxBEcAzbL1eO',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) +INFO:ImportIFC:Creating object #140=IfcPlate('3UA0KC6s8Hww2NcAzbL1eO',#5,'Web1','Web1',$,#124,#139,$,$) +INFO:ImportIFC:Creating object #161=IfcPlate('3UAJrs6s8HwvWrcAzbL1eO',#5,'Web2','Web2',$,#145,#160,$,$) +INFO:ImportIFC:Creating object #182=IfcPlate('3UAOk86s8Hwxy4cAzbL1eO',#5,'Fla1','Fla1',$,#166,#181,$,$) +INFO:ImportIFC:Creating object #203=IfcPlate('3UATfS6s8HwxrxcAzbL1eO',#5,'Fla2','Fla2',$,#187,#202,$,$) +INFO:ImportIFC:Import finished in 0.06 seconds diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 35fa830fa9..52d8e89f8e 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -53,6 +53,7 @@ sheets_enum = [] vector_styles_enum = [] bcfviewpoints_enum = [] + @persistent def setDefaultProperties(scene): if bpy.context.scene.BIMProperties.has_model_context \ @@ -164,7 +165,7 @@ def getDiagramScales(self, context): global diagram_scales_enum if len(diagram_scales_enum) < 1 \ or (bpy.context.scene.unit_settings.system == 'IMPERIAL' and len(diagram_scales_enum) == 13) \ - or (bpy.context.scene.unit_settings.system == 'METRIC' and len(diagram_scales_enum) == 31) : + or (bpy.context.scene.unit_settings.system == 'METRIC' and len(diagram_scales_enum) == 31): if bpy.context.scene.unit_settings.system == 'IMPERIAL': diagram_scales_enum = [ ('CUSTOM', 'Custom', ''), @@ -230,18 +231,29 @@ def updateDrawingName(self, context): def getBoundaryConditionClasses(self, context): return [(c, c, '') for c in - ['IfcBoundaryEdgeCondition', 'IfcBoundaryFaceCondition', - 'IfcBoundaryNodeCondition', 'IfcBoundaryNodeConditionWarping']] + ['IfcBoundaryEdgeCondition', 'IfcBoundaryFaceCondition', + 'IfcBoundaryNodeCondition', 'IfcBoundaryNodeConditionWarping']] def refreshBoundaryConditionAttributes(self, context): while len(context.active_object.BIMObjectProperties.boundary_condition.attributes) > 0: context.active_object.BIMObjectProperties.boundary_condition.attributes.remove(0) - for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.boundary_condition.name]['complex_attributes']: + for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.boundary_condition.name][ + 'complex_attributes']: new_attribute = context.active_object.BIMObjectProperties.boundary_condition.attributes.add() new_attribute.name = attribute['name'] +def getPresentationLayerClasses(self, context): + pass + # TODO: Base this on the logic in getBoundaryConditionClasses + + +def refreshPresentationLayerAttributes(self, context): + pass + # TODO: Base this on the logic in refreshBoundaryConditionAttributes + + def refreshActiveDrawingIndex(self, context): bpy.ops.bim.activate_view(drawing_index=context.scene.DocProperties.active_drawing_index) @@ -330,7 +342,8 @@ def getTitleblocks(self, context): global titleblocks_enum if len(titleblocks_enum) < 1: titleblocks_enum.clear() - for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, 'templates', 'titleblocks')).glob('*.svg'): + for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, 'templates', 'titleblocks')).glob( + '*.svg'): f = str(filename.stem) titleblocks_enum.append((f, f, '')) return titleblocks_enum @@ -438,8 +451,8 @@ def getApplicableAttributes(self, context): if '/' in context.active_object.name \ and context.active_object.name.split('/')[0] in schema.ifc.elements: attributes_enum.extend([(a['name'], a['name'], '') for a in - schema.ifc.elements[context.active_object.name.split('/')[0]]['attributes'] - if self.attributes.find(a['name']) == -1]) + schema.ifc.elements[context.active_object.name.split('/')[0]]['attributes'] + if self.attributes.find(a['name']) == -1]) return attributes_enum @@ -452,8 +465,8 @@ def getApplicableMaterialAttributes(self, context): if material_type[-3:] == 'Set': material_type = material_type[0:-3] materialattributes_enum.extend([(a['name'], a['name'], '') for a in - schema.ifc.IfcMaterialDefinition[material_type]['attributes'] - if self.attributes.find(a['name']) == -1]) + schema.ifc.IfcMaterialDefinition[material_type]['attributes'] + if self.attributes.find(a['name']) == -1]) return materialattributes_enum @@ -556,7 +569,7 @@ class DrawingStyle(PropertyGroup): ('NONE', 'None', ''), ('DEFAULT', 'Default', ''), ('VIEWPORT', 'Viewport', ''), - ], name='Render Type', default='VIEWPORT') + ], name='Render Type', default='VIEWPORT') vector_style: EnumProperty(items=getVectorStyles, name='Vector Style') include_query: StringProperty(name='Include Query') exclude_query: StringProperty(name='Exclude Query') @@ -587,18 +600,19 @@ class BIMCameraProperties(PropertyGroup): ('SECTION_VIEW', 'SECTION_VIEW', ''), ('REFLECTED_PLAN_VIEW', 'REFLECTED_PLAN_VIEW', ''), ('MODEL_VIEW', 'MODEL_VIEW', ''), - ], name='Target View', default='PLAN_VIEW') + ], name='Target View', default='PLAN_VIEW') diagram_scale: EnumProperty(items=getDiagramScales, name='Drawing Scale') custom_diagram_scale: StringProperty(name='Custom Scale') raster_x: IntProperty(name='Raster X', default=1000) raster_y: IntProperty(name='Raster Y', default=1000) is_nts: BoolProperty(name='Is NTS') cut_objects: EnumProperty(items=[ - ('.IfcWall|.IfcSlab|.IfcCurtainWall|.IfcStair|.IfcStairFlight|.IfcColumn|.IfcBeam|.IfcMember|.IfcCovering|.IfcSpace', + ( + '.IfcWall|.IfcSlab|.IfcCurtainWall|.IfcStair|.IfcStairFlight|.IfcColumn|.IfcBeam|.IfcMember|.IfcCovering|.IfcSpace', 'Overall Plan / Section', ''), ('.IfcElement', 'Detail Drawing', ''), ('CUSTOM', 'Custom', '') - ], name='Cut Objects') + ], name='Cut Objects') cut_objects_custom: StringProperty(name='Custom Cut') active_drawing_style_index: IntProperty(name='Active Drawing Style Index') @@ -610,12 +624,12 @@ class BIMTextProperties(PropertyGroup): ('3.5', '3.5 - Large', ''), ('5.0', '5.0 - Header', ''), ('7.0', '7.0 - Title', ''), - ], update=refreshFontSize, name='Font Size') + ], update=refreshFontSize, name='Font Size') symbol: EnumProperty(items=[ ('None', 'None', ''), ('rectangle-tag', 'Rectangle Tag', ''), ('door-tag', 'Door Tag', ''), - ], update=refreshFontSize, name='Symbol') + ], update=refreshFontSize, name='Symbol') related_element: PointerProperty(name='Related Element', type=bpy.types.Object) variables: CollectionProperty(name='Variables', type=Variable) @@ -640,17 +654,18 @@ class DocumentInformation(PropertyGroup): ('NOTDEFINED', 'NOTDEFINED', 'Not defined.'), ('PUBLIC', 'PUBLIC', 'Document is publicly available.'), ('RESTRICTED', 'RESTRICTED', 'Document availability is restricted.'), - ('CONFIDENTIAL', 'CONFIDENTIAL', 'Document is confidential and its contents should not be revealed without permission.'), + ('CONFIDENTIAL', 'CONFIDENTIAL', + 'Document is confidential and its contents should not be revealed without permission.'), ('PERSONAL', 'PERSONAL', 'Document is personal to the author.'), ('USERDEFINED', 'USERDEFINED', 'Describe confidentiality elsewhere.') - ], name='Confidentiality') + ], name='Confidentiality') status: EnumProperty(items=[ ('NOTDEFINED', 'NOTDEFINED', 'Not defined'), ('DRAFT', 'DRAFT', 'Document is a draft.'), ('FINALDRAFT', 'FINALDRAFT', 'Document is a final draft.'), ('FINAL', 'FINAL', 'Document is final.'), ('REVISION', 'REVISION', 'Document has undergone revision.'), - ], name='Status') + ], name='Status') class DocumentReference(PropertyGroup): @@ -667,7 +682,7 @@ class ClashSource(PropertyGroup): mode: EnumProperty(items=[ ('i', 'Include', 'Only the selected objects are included for clashing'), ('e', 'Exclude', 'All objects except the selected objects are included for clashing') - ], name='Mode') + ], name='Mode') class ClashSet(PropertyGroup): @@ -683,27 +698,40 @@ class Constraint(PropertyGroup): constraint_grade: EnumProperty(items=[ ('HARD', 'HARD', 'Qualifies a constraint such that it must be followed rigidly within or at the values set.'), ('SOFT', 'SOFT', 'Qualifies a constraint such that it should be followed within or at the values set.'), - ('ADVISORY', 'ADVISORY', 'Qualifies a constraint such that it is advised that it is followed within or at the values set.'), - ('USERDEFINED', 'USERDEFINED', 'A user-defined grade indicated by a separate attribute at the referencing entity.'), + ('ADVISORY', 'ADVISORY', + 'Qualifies a constraint such that it is advised that it is followed within or at the values set.'), + ('USERDEFINED', 'USERDEFINED', + 'A user-defined grade indicated by a separate attribute at the referencing entity.'), ('NOTDEFINED', 'NOTDEFINED', 'Grade has not been specified.'), - ], name='Grade') + ], name='Grade') constraint_source: StringProperty(name='Source') user_defined_grade: StringProperty(name='Custom Grade') objective_qualifier: EnumProperty(items=[ - ('CODECOMPLIANCE', 'CODECOMPLIANCE', 'A constraint whose objective is to ensure satisfaction of a code compliance provision.'), - ('CODEWAIVER', 'CODEWAIVER', 'A constraint whose objective is to identify an agreement that code compliance requirements (the waiver) will not be enforced.'), - ('DESIGNINTENT', 'DESIGNINTENT', 'A constraint whose objective is to ensure satisfaction of a design intent provision.'), - ('EXTERNAL', 'EXTERNAL', 'A constraint whose objective is to synchronize data with an external source such as a file'), - ('HEALTHANDSAFETY', 'HEALTHANDSAFETY', 'A constraint whose objective is to ensure satisfaction of a health and safety provision.'), - ('MERGECONFLICT', 'MERGECONFLICT', 'A constraint whose objective is to resolve a conflict such as merging data from multiple sources.'), - ('MODELVIEW', 'MODELVIEW', 'A constraint whose objective is to ensure data conforms to a model view definition.'), - ('PARAMETER', 'PARAMETER', 'A constraint whose objective is to calculate a value based on other referenced values.'), - ('REQUIREMENT', 'REQUIREMENT', 'A constraint whose objective is to ensure satisfaction of a project requirement provision.'), - ('SPECIFICATION', 'SPECIFICATION', 'A constraint whose objective is to ensure satisfaction of a specification provision.'), - ('TRIGGERCONDITION', 'TRIGGERCONDITION', 'A constraint whose objective is to indicate a limiting value beyond which the condition of an object requires a particular form of attention.'), + ('CODECOMPLIANCE', 'CODECOMPLIANCE', + 'A constraint whose objective is to ensure satisfaction of a code compliance provision.'), + ('CODEWAIVER', 'CODEWAIVER', + 'A constraint whose objective is to identify an agreement that code compliance requirements (the waiver) will not be enforced.'), + ('DESIGNINTENT', 'DESIGNINTENT', + 'A constraint whose objective is to ensure satisfaction of a design intent provision.'), + ('EXTERNAL', 'EXTERNAL', + 'A constraint whose objective is to synchronize data with an external source such as a file'), + ('HEALTHANDSAFETY', 'HEALTHANDSAFETY', + 'A constraint whose objective is to ensure satisfaction of a health and safety provision.'), + ('MERGECONFLICT', 'MERGECONFLICT', + 'A constraint whose objective is to resolve a conflict such as merging data from multiple sources.'), + ('MODELVIEW', 'MODELVIEW', + 'A constraint whose objective is to ensure data conforms to a model view definition.'), + ('PARAMETER', 'PARAMETER', + 'A constraint whose objective is to calculate a value based on other referenced values.'), + ('REQUIREMENT', 'REQUIREMENT', + 'A constraint whose objective is to ensure satisfaction of a project requirement provision.'), + ('SPECIFICATION', 'SPECIFICATION', + 'A constraint whose objective is to ensure satisfaction of a specification provision.'), + ('TRIGGERCONDITION', 'TRIGGERCONDITION', + 'A constraint whose objective is to indicate a limiting value beyond which the condition of an object requires a particular form of attention.'), ('USERDEFINED', 'USERDEFINED', ''), ('NOTDEFINED', 'NOTDEFINED', '') - ], name='Qualifier') + ], name='Qualifier') user_defined_qualifier: StringProperty(name='Custom Qualifier') @@ -743,6 +771,7 @@ class BcfTopicRelatedTopic(PropertyGroup): def refreshBcfTopic(self, context): RefreshBcfTopic.refresh(context) + class RefreshBcfTopic(): props: None topic: None @@ -860,7 +889,7 @@ class RefreshBcfTopic(): bcfviewpoints_enum.clear() bcf.BcfStore.viewpoints = bcfplugin.getViewpoints(cls.topic, realViewpoint=False) for i, viewpoint in enumerate(bcf.BcfStore.viewpoints): - bcfviewpoints_enum.append((str(i), 'View {}'.format(i+1), '')) + bcfviewpoints_enum.append((str(i), 'View {}'.format(i + 1), '')) @classmethod def load_comments(cls): @@ -890,15 +919,23 @@ class PropertySetTemplate(PropertyGroup): name: StringProperty(name="Name") description: StringProperty(name="Description") template_type: EnumProperty(items=[ - ('PSET_TYPEDRIVENONLY', 'Pset - IfcTypeObject', 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('PSET_TYPEDRIVENOVERRIDE', 'Pset - IfcTypeObject - Override', 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('PSET_OCCURRENCEDRIVEN', 'Pset - IfcObject', 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), - ('PSET_PERFORMANCEDRIVEN', 'Pset - IfcPerformanceHistory', 'The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.'), - ('QTO_TYPEDRIVENONLY', 'Qto - IfcTypeObject', 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('QTO_TYPEDRIVENOVERRIDE', 'Qto - IfcTypeObject - Override', 'The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.'), - ('QTO_OCCURRENCEDRIVEN', 'Qto - IfcObject', 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), - ('NOTDEFINED', 'Not defined', 'No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.') - ], name="Template Type") + ('PSET_TYPEDRIVENONLY', 'Pset - IfcTypeObject', + 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), + ('PSET_TYPEDRIVENOVERRIDE', 'Pset - IfcTypeObject - Override', + 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), + ('PSET_OCCURRENCEDRIVEN', 'Pset - IfcObject', + 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), + ('PSET_PERFORMANCEDRIVEN', 'Pset - IfcPerformanceHistory', + 'The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.'), + ('QTO_TYPEDRIVENONLY', 'Qto - IfcTypeObject', + 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), + ('QTO_TYPEDRIVENOVERRIDE', 'Qto - IfcTypeObject - Override', + 'The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.'), + ('QTO_OCCURRENCEDRIVEN', 'Qto - IfcObject', + 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), + ('NOTDEFINED', 'Not defined', + 'No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.') + ], name="Template Type") applicable_entity: StringProperty(name="Applicable Entity") @@ -1018,12 +1055,12 @@ class PropertyTemplate(PropertyGroup): 'IfcVolumetricFlowRateMeasure', 'IfcWarpingConstantMeasure', 'IfcWarpingMomentMeasure', - ] - ], name='Primary Measure Type') + ] + ], name='Primary Measure Type') class Address(PropertyGroup): - name: StringProperty(name="Name", default='IfcPostalAddress') # Stores IfcPostalAddress or IfcTelecomAddress + name: StringProperty(name="Name", default='IfcPostalAddress') # Stores IfcPostalAddress or IfcTelecomAddress purpose: EnumProperty(items=[ ('OFFICE', 'OFFICE', 'An office address.'), ('SITE', 'SITE', 'A site address.'), @@ -1144,7 +1181,7 @@ class ClassificationView(PropertyGroup): self.children.clear() elif rt == '': if self.crumbs: - self.crumbs.remove(len(self.crumbs)-1) + self.crumbs.remove(len(self.crumbs) - 1) self.children.clear() for child in self.root['children'].keys(): self.children.add().name = child @@ -1161,11 +1198,11 @@ class ClassificationView(PropertyGroup): op = layout.operator('bim.change_classification_level', text="@Toplevel") else: op = layout.operator('bim.change_classification_level', text=self.root['name']) - op.path_sid = "%r"%self.id_data + op.path_sid = "%r" % self.id_data op.path_lst = self.path_from_id() op.path_itm = '' layout.template_list('BIM_UL_classifications', - self.path_from_id(), self, 'children', self, 'active_index') + self.path_from_id(), self, 'children', self, 'active_index') # Monkey-patched, just to keep registration in one block @@ -1176,7 +1213,7 @@ ClassificationView.__annotations__['children'] = \ class BIMProperties(PropertyGroup): - schema_dir: StringProperty(default=os.path.join(cwd ,'schema') + os.path.sep, name="Schema Directory") + schema_dir: StringProperty(default=os.path.join(cwd, 'schema') + os.path.sep, name="Schema Directory") data_dir: StringProperty(default=os.path.join(cwd, 'data') + os.path.sep, name="Data Directory") ifc_file: StringProperty(name="IFC File") ifc_cache: StringProperty(name="IFC Cache") @@ -1184,7 +1221,7 @@ class BIMProperties(PropertyGroup): ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses) ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes) ifc_predefined_type: EnumProperty( - items = getIfcPredefinedTypes, + items=getIfcPredefinedTypes, name="Predefined Type", default=None) ifc_userdefined_type: StringProperty(name="Userdefined Type") export_schema: EnumProperty(items=[('IFC4', 'IFC4', ''), ('IFC2X3', 'IFC2X3', '')], name='IFC Schema') @@ -1192,7 +1229,8 @@ class BIMProperties(PropertyGroup): export_json_compact: BoolProperty(name="Export Compact IFCJSON", default=False) export_has_representations: BoolProperty(name="Export Representations", default=True) export_should_guess_quantities: BoolProperty(name="Export with Guessed Quantities", default=False) - export_should_use_presentation_style_assignment: BoolProperty(name="Export with Presentation Style Assignment", default=False) + export_should_use_presentation_style_assignment: BoolProperty(name="Export with Presentation Style Assignment", + default=False) export_should_force_faceted_brep: BoolProperty(name="Export with Faceted Breps", default=False) import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False) import_should_ignore_building_coordinates: BoolProperty(name="Import Ignoring Building Coordinates", default=False) @@ -1202,7 +1240,8 @@ class BIMProperties(PropertyGroup): import_should_import_opening_elements: BoolProperty(name="Import Opening Elements", default=False) import_should_import_spaces: BoolProperty(name="Import Spaces", default=False) import_should_auto_set_workarounds: BoolProperty(name="Automatically Set Vendor Workarounds", default=True) - import_should_treat_styled_item_as_material: BoolProperty(name="Import Treating Styled Item as Material", default=False) + import_should_treat_styled_item_as_material: BoolProperty(name="Import Treating Styled Item as Material", + default=False) import_should_use_legacy: BoolProperty(name="Import with Legacy Importer", default=False) import_should_import_native: BoolProperty(name="Import Native Representations", default=False) import_export_should_roundtrip_native: BoolProperty(name="Roundtrip Native Representations", default=False) @@ -1260,17 +1299,19 @@ class BIMProperties(PropertyGroup): available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts") available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views") classification_references: PointerProperty(type=ClassificationView) - pset_template_files: EnumProperty(items=getPsetTemplateFiles, name="Pset Template Files", update=refreshPropertySetTemplates) + pset_template_files: EnumProperty(items=getPsetTemplateFiles, name="Pset Template Files", + update=refreshPropertySetTemplates) property_set_templates: EnumProperty(items=getPropertySetTemplates, name="Pset Template Files") active_property_set_template: PointerProperty(type=PropertySetTemplate) property_templates: CollectionProperty(name='Property Templates', type=PropertyTemplate) should_section_selected_objects: BoolProperty(name="Section Selected Objects", default=False) - section_plane_colour: FloatVectorProperty(name='Temporary Section Cutaway Colour', subtype='COLOR', default=(1, 0, 0), min=0.0, max=1.0) + section_plane_colour: FloatVectorProperty(name='Temporary Section Cutaway Colour', subtype='COLOR', + default=(1, 0, 0), min=0.0, max=1.0) ifc_import_filter: EnumProperty(items=[ ('NONE', 'None', ''), ('WHITELIST', 'Whitelist', ''), ('BLACKLIST', 'Blacklist', ''), - ], name='Import Filter') + ], name='Import Filter') ifc_selector: StringProperty(default='', name='IFC Selector') csv_attributes: CollectionProperty(name='CSV Attributes', type=StrProperty) document_information: CollectionProperty(name='Document Information', type=DocumentInformation) @@ -1291,19 +1332,19 @@ class BIMProperties(PropertyGroup): ('square feet', 'square feet', ''), ('square inches', 'square inches', ''), ('square kilometers', 'square kilometers', ''), - ('square meters', 'square meters', ''), + ('SQUARE_METRE', 'square meters', ''), ('square miles', 'square miles', ''), ('square millimeters', 'square millimeters', ''), ('square yards', 'square yards', ''), - ], name='IFC Area Unit') + ], name='IFC Area Unit') volume_unit: EnumProperty(items=[ ('cubic centimeters', 'cubic centimeters', ''), ('cubic feet', 'cubic feet', ''), ('cubic inches', 'cubic inches', ''), - ('cubic meters', 'cubic meters', ''), + ('CUBIC_METRE', 'cubic meters', ''), ('cubic millimeters', 'cubic millimeters', ''), ('cubic yards', 'cubic yards', ''), - ], name='IFC Volume Unit') + ], name='IFC Volume Unit') metric_precision: FloatProperty(default=0, name='Drawing Metric Precision') imperial_precision: EnumProperty(items=[ ('NONE', 'No rounding', ''), @@ -1316,8 +1357,9 @@ class BIMProperties(PropertyGroup): ('1/64', 'Nearest 1/64"', ''), ('1/128', 'Nearest 1/128"', ''), ('1/256', 'Nearest 1/256"', ''), - ], name='Drawing Imperial Precision') - override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, max=1.0, size=4) + ], name='Drawing Imperial Precision') + override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, + max=1.0, size=4) class BCFProperties(PropertyGroup): @@ -1357,6 +1399,7 @@ class MapConversion(PropertyGroup): x_axis_ordinate: StringProperty(name="X Axis Ordinate") scale: StringProperty(name="Scale") + class TargetCRS(PropertyGroup): name: StringProperty(name="Name") description: StringProperty(name="Description") @@ -1366,6 +1409,7 @@ class TargetCRS(PropertyGroup): map_zone: StringProperty(name="Map Zone") map_unit: StringProperty(name="Map Unit") + class BIMLibrary(PropertyGroup): name: StringProperty(name="Name") version: StringProperty(name="Version") @@ -1388,7 +1432,7 @@ class IfcParameter(PropertyGroup): name: StringProperty(name="Name") step_id: IntProperty(name="STEP ID") index: IntProperty(name="Index") - value: FloatProperty(name="Value") # For now, only floats + value: FloatProperty(name="Value") # For now, only floats type: StringProperty(name="Type") @@ -1402,7 +1446,14 @@ class GlobalId(PropertyGroup): class BoundaryCondition(PropertyGroup): - name: EnumProperty(items=getBoundaryConditionClasses, name='Boundary Type', update=refreshBoundaryConditionAttributes) + name: EnumProperty(items=getBoundaryConditionClasses, name='Boundary Type', + update=refreshBoundaryConditionAttributes) + attributes: CollectionProperty(name="Attributes", type=Attribute) + + +class PresentationLayer(PropertyGroup): + name: EnumProperty(items=getPresentationLayerClasses, name='Presentation Layer', + update=refreshPresentationLayerAttributes) attributes: CollectionProperty(name="Attributes", type=Attribute) diff --git a/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore b/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore new file mode 100644 index 0000000000..2916366195 --- /dev/null +++ b/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore @@ -0,0 +1,4 @@ +* +!ifcopenshell.pth +!OCC.pth +!svgwrite.pth \ No newline at end of file From 35bcaa804b4303e50a9c4700b7b16f26fd570fbf Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Mon, 2 Nov 2020 07:13:51 +0100 Subject: [PATCH 02/15] testing with layers [skip ci] --- .../blenderbim/libs/site/packages/.gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore diff --git a/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore b/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore new file mode 100644 index 0000000000..808d16c90d --- /dev/null +++ b/src/ifcblenderexport/blenderbim/libs/site/packages/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!ifcopenshell.pth +!OCC.pth +!svgwrite.pth \ No newline at end of file From d9ecd204141b42955cb28d9c214788372d6ad4e2 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Mon, 2 Nov 2020 15:14:33 +0100 Subject: [PATCH 03/15] testing with layers [skip ci] --- .../blenderbim/bim/__init__.py | 1 + .../blenderbim/bim/data/process.log | 51 + src/ifcblenderexport/blenderbim/bim/prop.py | 1562 +++++++++-------- src/ifcblenderexport/blenderbim/bim/ui.py | 5 +- test/input | 2 +- 5 files changed, 922 insertions(+), 699 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index e52d3ec08b..e9dc8800fb 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -240,6 +240,7 @@ if bpy is not None: prop.Attribute, prop.IfcParameter, prop.BoundaryCondition, + prop.PresentationLayer, prop.PsetQto, prop.GlobalId, prop.RepresentationItem, diff --git a/src/ifcblenderexport/blenderbim/bim/data/process.log b/src/ifcblenderexport/blenderbim/bim/data/process.log index aab92faf3c..ce1ce1e1cd 100644 --- a/src/ifcblenderexport/blenderbim/bim/data/process.log +++ b/src/ifcblenderexport/blenderbim/bim/data/process.log @@ -18,3 +18,54 @@ INFO:ImportIFC:Creating object #161=IfcPlate('3UAJrs6s8HwvWrcAzbL1eO',#5,'Web2', INFO:ImportIFC:Creating object #182=IfcPlate('3UAOk86s8Hwxy4cAzbL1eO',#5,'Fla1','Fla1',$,#166,#181,$,$) INFO:ImportIFC:Creating object #203=IfcPlate('3UATfS6s8HwxrxcAzbL1eO',#5,'Fla2','Fla2',$,#187,#202,$,$) INFO:ImportIFC:Import finished in 0.06 seconds +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) +INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) +INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) +INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) +INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) +INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) +INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) +INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) +INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) +INFO:ImportIFC:Import finished in 0.07 seconds +INFO:ExportIFC:Starting export +INFO:ExportIFC:Export finished in 0.05 seconds +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) +INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) +INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) +INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) +INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) +INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) +INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) +INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) +INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) +INFO:ImportIFC:Import finished in 0.04 seconds +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) +INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) +INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) +INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) +INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) +INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) +INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) +INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) +INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) +INFO:ImportIFC:Import finished in 0.04 seconds +INFO:ImportIFC:Starting import +INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc +INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) +INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) +INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) +INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) +INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) +INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) +INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) +INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) +INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) +INFO:ImportIFC:Import finished in 0.04 seconds +INFO:ExportIFC:Starting export diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 52d8e89f8e..4298a7abea 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -19,7 +19,7 @@ from bpy.props import ( IntProperty, FloatProperty, FloatVectorProperty, - CollectionProperty + CollectionProperty, ) cwd = os.path.dirname(os.path.realpath(__file__)) @@ -56,82 +56,87 @@ bcfviewpoints_enum = [] @persistent def setDefaultProperties(scene): - if bpy.context.scene.BIMProperties.has_model_context \ - and len(bpy.context.scene.BIMProperties.model_subcontexts) == 0: + if ( + bpy.context.scene.BIMProperties.has_model_context + and len(bpy.context.scene.BIMProperties.model_subcontexts) == 0 + ): subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add() - subcontext.name = 'Body' - subcontext.target_view = 'MODEL_VIEW' + subcontext.name = "Body" + subcontext.target_view = "MODEL_VIEW" subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add() - subcontext.name = 'Box' - subcontext.target_view = 'MODEL_VIEW' - if bpy.context.scene.BIMProperties.has_plan_context \ - and len(bpy.context.scene.BIMProperties.plan_subcontexts) == 0: + subcontext.name = "Box" + subcontext.target_view = "MODEL_VIEW" + if bpy.context.scene.BIMProperties.has_plan_context and len(bpy.context.scene.BIMProperties.plan_subcontexts) == 0: subcontext = bpy.context.scene.BIMProperties.plan_subcontexts.add() - subcontext.name = 'Annotation' - subcontext.target_view = 'PLAN_VIEW' + subcontext.name = "Annotation" + subcontext.target_view = "PLAN_VIEW" if len(bpy.context.scene.DocProperties.drawing_styles) == 0: drawing_style = bpy.context.scene.DocProperties.drawing_styles.add() - drawing_style.name = 'Technical' - drawing_style.render_type = 'VIEWPORT' - drawing_style.raster_style = json.dumps({ - 'bpy.data.worlds[0].color': (1, 1, 1), - 'bpy.context.scene.render.engine': 'BLENDER_WORKBENCH', - 'bpy.context.scene.render.film_transparent': False, - 'bpy.context.scene.display.shading.show_object_outline': True, - 'bpy.context.scene.display.shading.show_cavity': False, - 'bpy.context.scene.display.shading.cavity_type': 'BOTH', - 'bpy.context.scene.display.shading.curvature_ridge_factor': 1, - 'bpy.context.scene.display.shading.curvature_valley_factor': 1, - 'bpy.context.scene.view_settings.view_transform': 'Standard', - 'bpy.context.scene.display.shading.light': 'FLAT', - 'bpy.context.scene.display.shading.color_type': 'SINGLE', - 'bpy.context.scene.display.shading.single_color': (1, 1, 1), - 'bpy.context.scene.display.shading.show_shadows': False, - 'bpy.context.scene.display.shading.shadow_intensity': 0.5, - 'bpy.context.scene.display.light_direction': (.5, .5, .5), - 'bpy.context.scene.view_settings.use_curve_mapping': False, - 'space.overlay.show_wireframes': True, - 'space.overlay.wireframe_threshold': 0, - 'space.overlay.show_floor': False, - 'space.overlay.show_axis_x': False, - 'space.overlay.show_axis_y': False, - 'space.overlay.show_axis_z': False, - 'space.overlay.show_object_origins': False, - 'space.overlay.show_relationship_lines': False, - }) + drawing_style.name = "Technical" + drawing_style.render_type = "VIEWPORT" + drawing_style.raster_style = json.dumps( + { + "bpy.data.worlds[0].color": (1, 1, 1), + "bpy.context.scene.render.engine": "BLENDER_WORKBENCH", + "bpy.context.scene.render.film_transparent": False, + "bpy.context.scene.display.shading.show_object_outline": True, + "bpy.context.scene.display.shading.show_cavity": False, + "bpy.context.scene.display.shading.cavity_type": "BOTH", + "bpy.context.scene.display.shading.curvature_ridge_factor": 1, + "bpy.context.scene.display.shading.curvature_valley_factor": 1, + "bpy.context.scene.view_settings.view_transform": "Standard", + "bpy.context.scene.display.shading.light": "FLAT", + "bpy.context.scene.display.shading.color_type": "SINGLE", + "bpy.context.scene.display.shading.single_color": (1, 1, 1), + "bpy.context.scene.display.shading.show_shadows": False, + "bpy.context.scene.display.shading.shadow_intensity": 0.5, + "bpy.context.scene.display.light_direction": (0.5, 0.5, 0.5), + "bpy.context.scene.view_settings.use_curve_mapping": False, + "space.overlay.show_wireframes": True, + "space.overlay.wireframe_threshold": 0, + "space.overlay.show_floor": False, + "space.overlay.show_axis_x": False, + "space.overlay.show_axis_y": False, + "space.overlay.show_axis_z": False, + "space.overlay.show_object_origins": False, + "space.overlay.show_relationship_lines": False, + } + ) drawing_style = bpy.context.scene.DocProperties.drawing_styles.add() - drawing_style.name = 'Shaded' - drawing_style.render_type = 'VIEWPORT' - drawing_style.raster_style = json.dumps({ - 'bpy.data.worlds[0].color': (1, 1, 1), - 'bpy.context.scene.render.engine': 'BLENDER_WORKBENCH', - 'bpy.context.scene.render.film_transparent': False, - 'bpy.context.scene.display.shading.show_object_outline': True, - 'bpy.context.scene.display.shading.show_cavity': True, - 'bpy.context.scene.display.shading.cavity_type': 'BOTH', - 'bpy.context.scene.display.shading.curvature_ridge_factor': 1, - 'bpy.context.scene.display.shading.curvature_valley_factor': 1, - 'bpy.context.scene.view_settings.view_transform': 'Standard', - 'bpy.context.scene.display.shading.light': 'STUDIO', - 'bpy.context.scene.display.shading.color_type': 'MATERIAL', - 'bpy.context.scene.display.shading.single_color': (1, 1, 1), - 'bpy.context.scene.display.shading.show_shadows': True, - 'bpy.context.scene.display.shading.shadow_intensity': 0.5, - 'bpy.context.scene.display.light_direction': (.5, .5, .5), - 'bpy.context.scene.view_settings.use_curve_mapping': False, - 'space.overlay.show_wireframes': True, - 'space.overlay.wireframe_threshold': 0, - 'space.overlay.show_floor': False, - 'space.overlay.show_axis_x': False, - 'space.overlay.show_axis_y': False, - 'space.overlay.show_axis_z': False, - 'space.overlay.show_object_origins': False, - 'space.overlay.show_relationship_lines': False, - }) + drawing_style.name = "Shaded" + drawing_style.render_type = "VIEWPORT" + drawing_style.raster_style = json.dumps( + { + "bpy.data.worlds[0].color": (1, 1, 1), + "bpy.context.scene.render.engine": "BLENDER_WORKBENCH", + "bpy.context.scene.render.film_transparent": False, + "bpy.context.scene.display.shading.show_object_outline": True, + "bpy.context.scene.display.shading.show_cavity": True, + "bpy.context.scene.display.shading.cavity_type": "BOTH", + "bpy.context.scene.display.shading.curvature_ridge_factor": 1, + "bpy.context.scene.display.shading.curvature_valley_factor": 1, + "bpy.context.scene.view_settings.view_transform": "Standard", + "bpy.context.scene.display.shading.light": "STUDIO", + "bpy.context.scene.display.shading.color_type": "MATERIAL", + "bpy.context.scene.display.shading.single_color": (1, 1, 1), + "bpy.context.scene.display.shading.show_shadows": True, + "bpy.context.scene.display.shading.shadow_intensity": 0.5, + "bpy.context.scene.display.light_direction": (0.5, 0.5, 0.5), + "bpy.context.scene.view_settings.use_curve_mapping": False, + "space.overlay.show_wireframes": True, + "space.overlay.wireframe_threshold": 0, + "space.overlay.show_floor": False, + "space.overlay.show_axis_x": False, + "space.overlay.show_axis_y": False, + "space.overlay.show_axis_z": False, + "space.overlay.show_object_origins": False, + "space.overlay.show_relationship_lines": False, + } + ) drawing_style = bpy.context.scene.DocProperties.drawing_styles.add() - drawing_style.name = 'Blender Default' - drawing_style.render_type = 'DEFAULT' - bpy.ops.bim.save_drawing_style(index='2') + drawing_style.name = "Blender Default" + drawing_style.render_type = "DEFAULT" + bpy.ops.bim.save_drawing_style(index="2") def getIfcPredefinedTypes(self, context): @@ -140,10 +145,10 @@ def getIfcPredefinedTypes(self, context): for name, data in schema.ifc.elements.items(): if name != self.ifc_class.strip(): continue - for attribute in data['attributes']: - if attribute['name'] != 'PredefinedType': + for attribute in data["attributes"]: + if attribute["name"] != "PredefinedType": continue - types_enum.extend([(e, e, '') for e in attribute['enum_values']]) + types_enum.extend([(e, e, "") for e in attribute["enum_values"]]) return types_enum @@ -163,58 +168,60 @@ def refreshPredefinedTypes(self, context): def getDiagramScales(self, context): global diagram_scales_enum - if len(diagram_scales_enum) < 1 \ - or (bpy.context.scene.unit_settings.system == 'IMPERIAL' and len(diagram_scales_enum) == 13) \ - or (bpy.context.scene.unit_settings.system == 'METRIC' and len(diagram_scales_enum) == 31): - if bpy.context.scene.unit_settings.system == 'IMPERIAL': + if ( + len(diagram_scales_enum) < 1 + or (bpy.context.scene.unit_settings.system == "IMPERIAL" and len(diagram_scales_enum) == 13) + or (bpy.context.scene.unit_settings.system == "METRIC" and len(diagram_scales_enum) == 31) + ): + if bpy.context.scene.unit_settings.system == "IMPERIAL": diagram_scales_enum = [ - ('CUSTOM', 'Custom', ''), - ('1\'=1\'-0"|1/1', '1\'=1\'-0"', ''), - ('6"=1\'-0"|1/6', '6"=1\'-0"', ''), - ('1-1/2"=1\'-0"|1/8', '1-1/2"=1\'-0"', ''), - ('1"=1\'-0"|1/12', '1"=1\'-0"', ''), - ('3/4"=1\'-0"|1/16', '3/4"=1\'-0"', ''), - ('1/2"=1\'-0"|1/24', '1/2"=1\'-0"', ''), - ('3/8"=1\'-0"|1/32', '3/8"=1\'-0"', ''), - ('1/4"=1\'-0"|1/48', '1/4"=1\'-0"', ''), - ('3/16"=1\'-0"|1/64', '3/16"=1\'-0"', ''), - ('1/8"=1\'-0"|1/96', '1/8"=1\'-0"', ''), - ('3/32"=1\'-0"|1/128', '3/32"=1\'-0"', ''), - ('1/16"=1\'-0"|1/192', '1/16"=1\'-0"', ''), - ('1/32"=1\'-0"|1/384', '1/32"=1\'-0"', ''), - ('1/64"=1\'-0"|1/768', '1/64"=1\'-0"', ''), - ('1/128"=1\'-0"|1/1536', '1/128"=1\'-0"', ''), - ('1"=10\'|1/120', '1"=10\'', ''), - ('1"=20\'|1/240', '1"=20\'', ''), - ('1"=30\'|1/360', '1"=30\'', ''), - ('1"=40\'|1/480', '1"=40\'', ''), - ('1"=50\'|1/600', '1"=50\'', ''), - ('1"=60\'|1/720', '1"=60\'', ''), - ('1"=70\'|1/840', '1"=70\'', ''), - ('1"=80\'|1/960', '1"=80\'', ''), - ('1"=90\'|1/1080', '1"=90\'', ''), - ('1"=100\'|1/1200', '1"=100\'', ''), - ('1"=150\'|1/1800', '1"=150\'', ''), - ('1"=200\'|1/2400', '1"=200\'', ''), - ('1"=300\'|1/3600', '1"=300\'', ''), - ('1"=400\'|1/4800', '1"=400\'', ''), - ('1"=500\'|1/6000', '1"=500\'', ''), + ("CUSTOM", "Custom", ""), + ("1'=1'-0\"|1/1", "1'=1'-0\"", ""), + ('6"=1\'-0"|1/6', '6"=1\'-0"', ""), + ('1-1/2"=1\'-0"|1/8', '1-1/2"=1\'-0"', ""), + ('1"=1\'-0"|1/12', '1"=1\'-0"', ""), + ('3/4"=1\'-0"|1/16', '3/4"=1\'-0"', ""), + ('1/2"=1\'-0"|1/24', '1/2"=1\'-0"', ""), + ('3/8"=1\'-0"|1/32', '3/8"=1\'-0"', ""), + ('1/4"=1\'-0"|1/48', '1/4"=1\'-0"', ""), + ('3/16"=1\'-0"|1/64', '3/16"=1\'-0"', ""), + ('1/8"=1\'-0"|1/96', '1/8"=1\'-0"', ""), + ('3/32"=1\'-0"|1/128', '3/32"=1\'-0"', ""), + ('1/16"=1\'-0"|1/192', '1/16"=1\'-0"', ""), + ('1/32"=1\'-0"|1/384', '1/32"=1\'-0"', ""), + ('1/64"=1\'-0"|1/768', '1/64"=1\'-0"', ""), + ('1/128"=1\'-0"|1/1536', '1/128"=1\'-0"', ""), + ("1\"=10'|1/120", "1\"=10'", ""), + ("1\"=20'|1/240", "1\"=20'", ""), + ("1\"=30'|1/360", "1\"=30'", ""), + ("1\"=40'|1/480", "1\"=40'", ""), + ("1\"=50'|1/600", "1\"=50'", ""), + ("1\"=60'|1/720", "1\"=60'", ""), + ("1\"=70'|1/840", "1\"=70'", ""), + ("1\"=80'|1/960", "1\"=80'", ""), + ("1\"=90'|1/1080", "1\"=90'", ""), + ("1\"=100'|1/1200", "1\"=100'", ""), + ("1\"=150'|1/1800", "1\"=150'", ""), + ("1\"=200'|1/2400", "1\"=200'", ""), + ("1\"=300'|1/3600", "1\"=300'", ""), + ("1\"=400'|1/4800", "1\"=400'", ""), + ("1\"=500'|1/6000", "1\"=500'", ""), ] else: diagram_scales_enum = [ - ('CUSTOM', 'Custom', ''), - ('1:5000|1/5000', '1:5000', ''), - ('1:2000|1/2000', '1:2000', ''), - ('1:1000|1/1000', '1:1000', ''), - ('1:500|1/500', '1:500', ''), - ('1:200|1/200', '1:200', ''), - ('1:100|1/100', '1:100', ''), - ('1:50|1/50', '1:50', ''), - ('1:20|1/20', '1:20', ''), - ('1:10|1/10', '1:10', ''), - ('1:5|1/5', '1:5', ''), - ('1:2|1/2', '1:2', ''), - ('1:1|1/1', '1:1', '') + ("CUSTOM", "Custom", ""), + ("1:5000|1/5000", "1:5000", ""), + ("1:2000|1/2000", "1:2000", ""), + ("1:1000|1/1000", "1:1000", ""), + ("1:500|1/500", "1:500", ""), + ("1:200|1/200", "1:200", ""), + ("1:100|1/100", "1:100", ""), + ("1:50|1/50", "1:50", ""), + ("1:20|1/20", "1:20", ""), + ("1:10|1/10", "1:10", ""), + ("1:5|1/5", "1:5", ""), + ("1:2|1/2", "1:2", ""), + ("1:1|1/1", "1:1", ""), ] return diagram_scales_enum @@ -224,34 +231,51 @@ def updateDrawingName(self, context): return if self.camera.name == self.name: return - self.camera.name = 'IfcGroup/{}'.format(self.name) + self.camera.name = "IfcGroup/{}".format(self.name) self.camera.users_collection[0].name = self.camera.name - self.name = self.camera.name.split('/')[1] + self.name = self.camera.name.split("/")[1] def getBoundaryConditionClasses(self, context): - return [(c, c, '') for c in - ['IfcBoundaryEdgeCondition', 'IfcBoundaryFaceCondition', - 'IfcBoundaryNodeCondition', 'IfcBoundaryNodeConditionWarping']] + return [ + (c, c, "") + for c in [ + "IfcBoundaryEdgeCondition", + "IfcBoundaryFaceCondition", + "IfcBoundaryNodeCondition", + "IfcBoundaryNodeConditionWarping", + ] + ] def refreshBoundaryConditionAttributes(self, context): while len(context.active_object.BIMObjectProperties.boundary_condition.attributes) > 0: context.active_object.BIMObjectProperties.boundary_condition.attributes.remove(0) for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.boundary_condition.name][ - 'complex_attributes']: + "complex_attributes" + ]: new_attribute = context.active_object.BIMObjectProperties.boundary_condition.attributes.add() - new_attribute.name = attribute['name'] + new_attribute.name = attribute["name"] def getPresentationLayerClasses(self, context): - pass - # TODO: Base this on the logic in getBoundaryConditionClasses + return [ + (c, c, "") + for c in [ + "IfcPresentationLayerAssignment", + "IfcPresentationLayerWithStyle", + ] + ] def refreshPresentationLayerAttributes(self, context): - pass - # TODO: Base this on the logic in refreshBoundaryConditionAttributes + while len(context.active_object.BIMObjectProperties.presentation_layer.attributes) > 0: + context.active_object.BIMObjectProperties.presentation_layer.attributes.remove(0) + for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.presentation_layer.name][ + "complex_attributes" + ]: + new_attribute = context.active_object.BIMObjectProperties.presentation_layer.attributes.add() + new_attribute.name = attribute["name"] def refreshActiveDrawingIndex(self, context): @@ -261,43 +285,49 @@ def refreshActiveDrawingIndex(self, context): def getIfcProducts(self, context): global products_enum if len(products_enum) < 1: - products_enum.extend([(e, e, '') for e in [ - 'IfcElement', - 'IfcElementType', - 'IfcSpatialElement', - 'IfcGroup', - 'IfcStructural', - 'IfcPositioningElement', - 'IfcContext', - 'IfcAnnotation']]) + products_enum.extend( + [ + (e, e, "") + for e in [ + "IfcElement", + "IfcElementType", + "IfcSpatialElement", + "IfcGroup", + "IfcStructural", + "IfcPositioningElement", + "IfcContext", + "IfcAnnotation", + ] + ] + ) return products_enum def getIfcClasses(self, context): global classes_enum if len(classes_enum) < 1: - classes_enum.extend([(e, e, '') for e in getattr(schema.ifc, self.ifc_product)]) + classes_enum.extend([(e, e, "") for e in getattr(schema.ifc, self.ifc_product)]) return classes_enum def getProfileDef(self, context): global profiledef_enum if len(profiledef_enum) < 1: - profiledef_enum.extend([(e, e, '') for e in getattr(schema.ifc, 'IfcParameterizedProfileDef')]) + profiledef_enum.extend([(e, e, "") for e in getattr(schema.ifc, "IfcParameterizedProfileDef")]) return profiledef_enum def getPersons(self, context): global persons_enum persons_enum.clear() - persons_enum.extend([(p.name, p.name, '') for p in bpy.context.scene.BIMProperties.people]) + persons_enum.extend([(p.name, p.name, "") for p in bpy.context.scene.BIMProperties.people]) return persons_enum def getOrganisations(self, context): global organisations_enum organisations_enum.clear() - organisations_enum.extend([(o.name, o.name, '') for o in bpy.context.scene.BIMProperties.organisations]) + organisations_enum.extend([(o.name, o.name, "") for o in bpy.context.scene.BIMProperties.organisations]) return organisations_enum @@ -305,8 +335,8 @@ def getAvailableMaterialPsets(self, context): global availablematerialpsets_enum if len(availablematerialpsets_enum) < 1: availablematerialpsets_enum.clear() - files = os.listdir(os.path.join(context.scene.BIMProperties.data_dir, 'material')) - availablematerialpsets_enum.extend([(f, f, '') for f in files]) + files = os.listdir(os.path.join(context.scene.BIMProperties.data_dir, "material")) + availablematerialpsets_enum.extend([(f, f, "") for f in files]) return availablematerialpsets_enum @@ -314,11 +344,11 @@ def getIfcPatchRecipes(self, context): global ifcpatchrecipes_enum if len(ifcpatchrecipes_enum) < 1: ifcpatchrecipes_enum.clear() - for filename in Path(os.path.join(cwd, '..', 'libs', 'site', 'packages', 'recipes')).glob('*.py'): + for filename in Path(os.path.join(cwd, "..", "libs", "site", "packages", "recipes")).glob("*.py"): f = str(filename.stem) - if f == '__init__': + if f == "__init__": continue - ifcpatchrecipes_enum.append((f, f, '')) + ifcpatchrecipes_enum.append((f, f, "")) return ifcpatchrecipes_enum @@ -326,9 +356,9 @@ def getFeaturesFiles(self, context): global featuresfiles_enum if len(featuresfiles_enum) < 1: featuresfiles_enum.clear() - for filename in Path(context.scene.BIMProperties.features_dir).glob('*.feature'): + for filename in Path(context.scene.BIMProperties.features_dir).glob("*.feature"): f = str(filename.stem) - featuresfiles_enum.append((f, f, '')) + featuresfiles_enum.append((f, f, "")) return featuresfiles_enum @@ -342,10 +372,11 @@ def getTitleblocks(self, context): global titleblocks_enum if len(titleblocks_enum) < 1: titleblocks_enum.clear() - for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, 'templates', 'titleblocks')).glob( - '*.svg'): + for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, "templates", "titleblocks")).glob( + "*.svg" + ): f = str(filename.stem) - titleblocks_enum.append((f, f, '')) + titleblocks_enum.append((f, f, "")) return titleblocks_enum @@ -360,14 +391,14 @@ def getScenarios(self, context): if len(scenarios_enum) < 1: scenarios_enum.clear() filename = os.path.join( - context.scene.BIMProperties.features_dir, - context.scene.BIMProperties.features_file + '.feature') - with open(filename, 'r') as feature_file: + context.scene.BIMProperties.features_dir, context.scene.BIMProperties.features_file + ".feature" + ) + with open(filename, "r") as feature_file: lines = feature_file.readlines() for line in lines: - if 'Scenario:' in line: - s = line.strip()[len('Scenario: '):] - scenarios_enum.append((s, s, '')) + if "Scenario:" in line: + s = line.strip()[len("Scenario: "):] + scenarios_enum.append((s, s, "")) return scenarios_enum @@ -380,8 +411,8 @@ def refreshScenarios(self, context): def getPsetTemplateFiles(self, context): global psettemplatefiles_enum if len(psettemplatefiles_enum) < 1: - files = os.listdir(os.path.join(self.data_dir, 'pset')) - psettemplatefiles_enum.extend([(f.replace('.ifc', ''), f.replace('.ifc', ''), '') for f in files]) + files = os.listdir(os.path.join(self.data_dir, "pset")) + psettemplatefiles_enum.extend([(f.replace(".ifc", ""), f.replace(".ifc", ""), "") for f in files]) return psettemplatefiles_enum @@ -395,10 +426,11 @@ def getPropertySetTemplates(self, context): global propertysettemplates_enum if len(propertysettemplates_enum) < 1: ifc.IfcStore.pset_template_path = os.path.join( - context.scene.BIMProperties.data_dir, 'pset', context.scene.BIMProperties.pset_template_files + '.ifc') + context.scene.BIMProperties.data_dir, "pset", context.scene.BIMProperties.pset_template_files + ".ifc" + ) ifc.IfcStore.pset_template_file = ifcopenshell.open(ifc.IfcStore.pset_template_path) - templates = ifc.IfcStore.pset_template_file.by_type('IfcPropertySetTemplate') - propertysettemplates_enum.extend([(t.GlobalId, t.Name, '') for t in templates]) + templates = ifc.IfcStore.pset_template_file.by_type("IfcPropertySetTemplate") + propertysettemplates_enum.extend([(t.GlobalId, t.Name, "") for t in templates]) return propertysettemplates_enum @@ -406,28 +438,27 @@ def getClassifications(self, context): global classification_enum if len(classification_enum) < 1: classification_enum.clear() - files = os.listdir(os.path.join(self.schema_dir, 'classifications')) - classification_enum.extend([(f.replace('.ifc', ''), f.replace('.ifc', ''), '') for f in files]) + files = os.listdir(os.path.join(self.schema_dir, "classifications")) + classification_enum.extend([(f.replace(".ifc", ""), f.replace(".ifc", ""), "") for f in files]) return classification_enum def refreshReferences(self, context): context.scene.BIMProperties.classification_references.root = None ClassificationView.raw_data = schema.ifc.load_classification(context.scene.BIMProperties.classification) - context.scene.BIMProperties.classification_references.root = '' + context.scene.BIMProperties.classification_references.root = "" # TODO: move into util module. See bug #971 def getPsetNames(self, context): global psetnames_enum psetnames_enum.clear() - if '/' in context.active_object.name \ - and context.active_object.name.split('/')[0] in schema.ifc.elements: + if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements: empty = ifcopenshell.file() - element = empty.create_entity(context.active_object.name.split('/')[0]) + element = empty.create_entity(context.active_object.name.split("/")[0]) for ifc_class, pset_names in schema.ifc.applicable_psets.items(): if element.is_a(ifc_class): - psetnames_enum.extend([(p, p, '') for p in pset_names]) + psetnames_enum.extend([(p, p, "") for p in pset_names]) return psetnames_enum @@ -435,57 +466,60 @@ def getPsetNames(self, context): def getQtoNames(self, context): global qtonames_enum qtonames_enum.clear() - if '/' in context.active_object.name \ - and context.active_object.name.split('/')[0] in schema.ifc.elements: + if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements: empty = ifcopenshell.file() - element = empty.create_entity(context.active_object.name.split('/')[0]) + element = empty.create_entity(context.active_object.name.split("/")[0]) for ifc_class, qto_names in schema.ifc.applicable_qtos.items(): if element.is_a(ifc_class): - qtonames_enum.extend([(q, q, '') for q in qto_names]) + qtonames_enum.extend([(q, q, "") for q in qto_names]) return qtonames_enum def getApplicableAttributes(self, context): global attributes_enum attributes_enum.clear() - if '/' in context.active_object.name \ - and context.active_object.name.split('/')[0] in schema.ifc.elements: - attributes_enum.extend([(a['name'], a['name'], '') for a in - schema.ifc.elements[context.active_object.name.split('/')[0]]['attributes'] - if self.attributes.find(a['name']) == -1]) + if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements: + attributes_enum.extend( + [ + (a["name"], a["name"], "") + for a in schema.ifc.elements[context.active_object.name.split("/")[0]]["attributes"] + if self.attributes.find(a["name"]) == -1 + ] + ) return attributes_enum def getApplicableMaterialAttributes(self, context): global materialattributes_enum materialattributes_enum.clear() - if '/' in context.active_object.name \ - and context.active_object.name.split('/')[0] in schema.ifc.elements: + if "/" in context.active_object.name and context.active_object.name.split("/")[0] in schema.ifc.elements: material_type = context.active_object.BIMObjectProperties.material_type - if material_type[-3:] == 'Set': + if material_type[-3:] == "Set": material_type = material_type[0:-3] - materialattributes_enum.extend([(a['name'], a['name'], '') for a in - schema.ifc.IfcMaterialDefinition[material_type]['attributes'] - if self.attributes.find(a['name']) == -1]) + materialattributes_enum.extend( + [ + (a["name"], a["name"], "") + for a in schema.ifc.IfcMaterialDefinition[material_type]["attributes"] + if self.attributes.find(a["name"]) == -1 + ] + ) return materialattributes_enum def refreshProfileAttributes(self, context): while len(context.active_object.active_material.BIMMaterialProperties.profile_attributes) > 0: context.active_object.active_material.BIMMaterialProperties.profile_attributes.remove(0) - for attribute in schema.ifc.IfcParameterizedProfileDef[self.profile_def]['attributes']: + for attribute in schema.ifc.IfcParameterizedProfileDef[self.profile_def]["attributes"]: profile_attribute = context.active_object.active_material.BIMMaterialProperties.profile_attributes.add() - profile_attribute.name = attribute['name'] + profile_attribute.name = attribute["name"] def getMaterialTypes(self, context): global materialtypes_enum materialtypes_enum.clear() - materialtypes_enum = [(m, m, '') for m in [ - 'IfcMaterial', - 'IfcMaterialConstituentSet', - 'IfcMaterialLayerSet', - 'IfcMaterialProfileSet']] + materialtypes_enum = [ + (m, m, "") for m in ["IfcMaterial", "IfcMaterialConstituentSet", "IfcMaterialLayerSet", "IfcMaterialProfileSet"] + ] return materialtypes_enum @@ -495,7 +529,7 @@ def getSubcontexts(self, context): # TODO: allow override of generated subcontexts? subcontexts = export_ifc.IfcExportSettings().subcontexts for subcontext in subcontexts: - subcontexts_enum.append((subcontext, subcontext, '')) + subcontexts_enum.append((subcontext, subcontext, "")) return subcontexts_enum @@ -503,7 +537,7 @@ def getTargetViews(self, context): global target_views_enum target_views_enum.clear() for target_view in export_ifc.IfcExportSettings().target_views: - target_views_enum.append((target_view, target_view, '')) + target_views_enum.append((target_view, target_view, "")) return target_views_enum @@ -511,9 +545,9 @@ def getVectorStyles(self, context): global vector_styles_enum if len(vector_styles_enum) < 1: sheets_enum.clear() - for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, 'styles')).glob('*.css'): + for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, "styles")).glob("*.css"): f = str(filename.stem) - vector_styles_enum.append((f, f, '')) + vector_styles_enum.append((f, f, "")) return vector_styles_enum @@ -531,141 +565,163 @@ class Variable(PropertyGroup): class Subcontext(PropertyGroup): - name: StringProperty(name='Name') - context: StringProperty(name='Context') - target_view: StringProperty(name='Target View') + name: StringProperty(name="Name") + context: StringProperty(name="Context") + target_view: StringProperty(name="Target View") class Drawing(PropertyGroup): - name: StringProperty(name='Name', update=updateDrawingName) - camera: PointerProperty(name='Camera', type=bpy.types.Object) + name: StringProperty(name="Name", update=updateDrawingName) + camera: PointerProperty(name="Camera", type=bpy.types.Object) class Schedule(PropertyGroup): - name: StringProperty(name='Name') - file: StringProperty(name='File') + name: StringProperty(name="Name") + file: StringProperty(name="File") class Sheet(PropertyGroup): def set_name(self, new): - old = self.get('name') - path = os.path.join(bpy.context.scene.BIMProperties.data_dir, 'sheets') - if old and os.path.isfile(os.path.join(path, old + '.svg')): - os.rename(os.path.join(path, old + '.svg'), os.path.join(path, new + '.svg')) - self['name'] = new + old = self.get("name") + path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "sheets") + if old and os.path.isfile(os.path.join(path, old + ".svg")): + os.rename(os.path.join(path, old + ".svg"), os.path.join(path, new + ".svg")) + self["name"] = new def get_name(self): - return self.get('name') + return self.get("name") - name: StringProperty(name='Name', get=get_name, set=set_name) - drawings: CollectionProperty(name='Drawings', type=Drawing) - active_drawing_index: IntProperty(name='Active Drawing Index') + name: StringProperty(name="Name", get=get_name, set=set_name) + drawings: CollectionProperty(name="Drawings", type=Drawing) + active_drawing_index: IntProperty(name="Active Drawing Index") class DrawingStyle(PropertyGroup): - name: StringProperty(name='Name') - raster_style: StringProperty(name='Raster Style') - render_type: EnumProperty(items=[ - ('NONE', 'None', ''), - ('DEFAULT', 'Default', ''), - ('VIEWPORT', 'Viewport', ''), - ], name='Render Type', default='VIEWPORT') - vector_style: EnumProperty(items=getVectorStyles, name='Vector Style') - include_query: StringProperty(name='Include Query') - exclude_query: StringProperty(name='Exclude Query') - attributes: CollectionProperty(name='Attributes', type=StrProperty) + name: StringProperty(name="Name") + raster_style: StringProperty(name="Raster Style") + render_type: EnumProperty( + items=[("NONE", "None", ""), ("DEFAULT", "Default", ""), ("VIEWPORT", "Viewport", ""), ], + name="Render Type", + default="VIEWPORT", + ) + vector_style: EnumProperty(items=getVectorStyles, name="Vector Style") + include_query: StringProperty(name="Include Query") + exclude_query: StringProperty(name="Exclude Query") + attributes: CollectionProperty(name="Attributes", type=StrProperty) class DocProperties(PropertyGroup): should_recut: BoolProperty(name="Should Recut", default=True) should_recut_selected: BoolProperty(name="Should Recut Selected Only", default=False) should_extract: BoolProperty(name="Should Extract", default=True) - drawings: CollectionProperty(name='Drawings', type=Drawing) - active_drawing_index: IntProperty(name='Active Drawing Index', update=refreshActiveDrawingIndex) - current_drawing_index: IntProperty(name='Current Drawing Index') - schedules: CollectionProperty(name='Schedules', type=Schedule) - active_schedule_index: IntProperty(name='Active Schedule Index') + drawings: CollectionProperty(name="Drawings", type=Drawing) + active_drawing_index: IntProperty(name="Active Drawing Index", update=refreshActiveDrawingIndex) + current_drawing_index: IntProperty(name="Current Drawing Index") + schedules: CollectionProperty(name="Schedules", type=Schedule) + active_schedule_index: IntProperty(name="Active Schedule Index") titleblock: EnumProperty(items=getTitleblocks, name="Titleblock", update=refreshTitleblocks) - sheets: CollectionProperty(name='Sheets', type=Sheet) - active_sheet_index: IntProperty(name='Active Sheet Index') - ifc_files: CollectionProperty(name='IFCs', type=StrProperty) - drawing_styles: CollectionProperty(name='Drawing Styles', type=DrawingStyle) + sheets: CollectionProperty(name="Sheets", type=Sheet) + active_sheet_index: IntProperty(name="Active Sheet Index") + ifc_files: CollectionProperty(name="IFCs", type=StrProperty) + drawing_styles: CollectionProperty(name="Drawing Styles", type=DrawingStyle) class BIMCameraProperties(PropertyGroup): view_name: StringProperty(name="View Name") - target_view: EnumProperty(items=[ - ('PLAN_VIEW', 'PLAN_VIEW', ''), - ('ELEVATION_VIEW', 'ELEVATION_VIEW', ''), - ('SECTION_VIEW', 'SECTION_VIEW', ''), - ('REFLECTED_PLAN_VIEW', 'REFLECTED_PLAN_VIEW', ''), - ('MODEL_VIEW', 'MODEL_VIEW', ''), - ], name='Target View', default='PLAN_VIEW') - diagram_scale: EnumProperty(items=getDiagramScales, name='Drawing Scale') - custom_diagram_scale: StringProperty(name='Custom Scale') - raster_x: IntProperty(name='Raster X', default=1000) - raster_y: IntProperty(name='Raster Y', default=1000) - is_nts: BoolProperty(name='Is NTS') - cut_objects: EnumProperty(items=[ - ( - '.IfcWall|.IfcSlab|.IfcCurtainWall|.IfcStair|.IfcStairFlight|.IfcColumn|.IfcBeam|.IfcMember|.IfcCovering|.IfcSpace', - 'Overall Plan / Section', ''), - ('.IfcElement', 'Detail Drawing', ''), - ('CUSTOM', 'Custom', '') - ], name='Cut Objects') - cut_objects_custom: StringProperty(name='Custom Cut') - active_drawing_style_index: IntProperty(name='Active Drawing Style Index') + target_view: EnumProperty( + items=[ + ("PLAN_VIEW", "PLAN_VIEW", ""), + ("ELEVATION_VIEW", "ELEVATION_VIEW", ""), + ("SECTION_VIEW", "SECTION_VIEW", ""), + ("REFLECTED_PLAN_VIEW", "REFLECTED_PLAN_VIEW", ""), + ("MODEL_VIEW", "MODEL_VIEW", ""), + ], + name="Target View", + default="PLAN_VIEW", + ) + diagram_scale: EnumProperty(items=getDiagramScales, name="Drawing Scale") + custom_diagram_scale: StringProperty(name="Custom Scale") + raster_x: IntProperty(name="Raster X", default=1000) + raster_y: IntProperty(name="Raster Y", default=1000) + is_nts: BoolProperty(name="Is NTS") + cut_objects: EnumProperty( + items=[ + ( + ".IfcWall|.IfcSlab|.IfcCurtainWall|.IfcStair|.IfcStairFlight|.IfcColumn|.IfcBeam|.IfcMember|.IfcCovering|.IfcSpace", + "Overall Plan / Section", + "", + ), + (".IfcElement", "Detail Drawing", ""), + ("CUSTOM", "Custom", ""), + ], + name="Cut Objects", + ) + cut_objects_custom: StringProperty(name="Custom Cut") + active_drawing_style_index: IntProperty(name="Active Drawing Style Index") class BIMTextProperties(PropertyGroup): - font_size: EnumProperty(items=[ - ('1.8', '1.8 - Small', ''), - ('2.5', '2.5 - Regular', ''), - ('3.5', '3.5 - Large', ''), - ('5.0', '5.0 - Header', ''), - ('7.0', '7.0 - Title', ''), - ], update=refreshFontSize, name='Font Size') - symbol: EnumProperty(items=[ - ('None', 'None', ''), - ('rectangle-tag', 'Rectangle Tag', ''), - ('door-tag', 'Door Tag', ''), - ], update=refreshFontSize, name='Symbol') - related_element: PointerProperty(name='Related Element', type=bpy.types.Object) - variables: CollectionProperty(name='Variables', type=Variable) + font_size: EnumProperty( + items=[ + ("1.8", "1.8 - Small", ""), + ("2.5", "2.5 - Regular", ""), + ("3.5", "3.5 - Large", ""), + ("5.0", "5.0 - Header", ""), + ("7.0", "7.0 - Title", ""), + ], + update=refreshFontSize, + name="Font Size", + ) + symbol: EnumProperty( + items=[("None", "None", ""), ("rectangle-tag", "Rectangle Tag", ""), ("door-tag", "Door Tag", ""), ], + update=refreshFontSize, + name="Symbol", + ) + related_element: PointerProperty(name="Related Element", type=bpy.types.Object) + variables: CollectionProperty(name="Variables", type=Variable) class DocumentInformation(PropertyGroup): - name: StringProperty(name='Identification') - human_name: StringProperty(name='Name') - description: StringProperty(name='Description') - location: StringProperty(name='Location') - purpose: StringProperty(name='Purpose') - intended_use: StringProperty(name='Intended Use') - scope: StringProperty(name='Scope') - revision: StringProperty(name='Revision') - document_owner: StringProperty(name='Owner') - editors: StringProperty(name='Editors') - creation_time: StringProperty(name='Created On') - last_revision_time: StringProperty(name='Last Revised') - electronic_format: StringProperty(name='Format') - valid_from: StringProperty(name='Valid From') - valid_until: StringProperty(name='Valid Until') - confidentiality: EnumProperty(items=[ - ('NOTDEFINED', 'NOTDEFINED', 'Not defined.'), - ('PUBLIC', 'PUBLIC', 'Document is publicly available.'), - ('RESTRICTED', 'RESTRICTED', 'Document availability is restricted.'), - ('CONFIDENTIAL', 'CONFIDENTIAL', - 'Document is confidential and its contents should not be revealed without permission.'), - ('PERSONAL', 'PERSONAL', 'Document is personal to the author.'), - ('USERDEFINED', 'USERDEFINED', 'Describe confidentiality elsewhere.') - ], name='Confidentiality') - status: EnumProperty(items=[ - ('NOTDEFINED', 'NOTDEFINED', 'Not defined'), - ('DRAFT', 'DRAFT', 'Document is a draft.'), - ('FINALDRAFT', 'FINALDRAFT', 'Document is a final draft.'), - ('FINAL', 'FINAL', 'Document is final.'), - ('REVISION', 'REVISION', 'Document has undergone revision.'), - ], name='Status') + name: StringProperty(name="Identification") + human_name: StringProperty(name="Name") + description: StringProperty(name="Description") + location: StringProperty(name="Location") + purpose: StringProperty(name="Purpose") + intended_use: StringProperty(name="Intended Use") + scope: StringProperty(name="Scope") + revision: StringProperty(name="Revision") + document_owner: StringProperty(name="Owner") + editors: StringProperty(name="Editors") + creation_time: StringProperty(name="Created On") + last_revision_time: StringProperty(name="Last Revised") + electronic_format: StringProperty(name="Format") + valid_from: StringProperty(name="Valid From") + valid_until: StringProperty(name="Valid Until") + confidentiality: EnumProperty( + items=[ + ("NOTDEFINED", "NOTDEFINED", "Not defined."), + ("PUBLIC", "PUBLIC", "Document is publicly available."), + ("RESTRICTED", "RESTRICTED", "Document availability is restricted."), + ( + "CONFIDENTIAL", + "CONFIDENTIAL", + "Document is confidential and its contents should not be revealed without permission.", + ), + ("PERSONAL", "PERSONAL", "Document is personal to the author."), + ("USERDEFINED", "USERDEFINED", "Describe confidentiality elsewhere."), + ], + name="Confidentiality", + ) + status: EnumProperty( + items=[ + ("NOTDEFINED", "NOTDEFINED", "Not defined"), + ("DRAFT", "DRAFT", "Document is a draft."), + ("FINALDRAFT", "FINALDRAFT", "Document is a final draft."), + ("FINAL", "FINAL", "Document is final."), + ("REVISION", "REVISION", "Document has undergone revision."), + ], + name="Status", + ) class DocumentReference(PropertyGroup): @@ -677,108 +733,172 @@ class DocumentReference(PropertyGroup): class ClashSource(PropertyGroup): - name: StringProperty(name='File') - selector: StringProperty(name='Selector') - mode: EnumProperty(items=[ - ('i', 'Include', 'Only the selected objects are included for clashing'), - ('e', 'Exclude', 'All objects except the selected objects are included for clashing') - ], name='Mode') + name: StringProperty(name="File") + selector: StringProperty(name="Selector") + mode: EnumProperty( + items=[ + ("i", "Include", "Only the selected objects are included for clashing"), + ("e", "Exclude", "All objects except the selected objects are included for clashing"), + ], + name="Mode", + ) class ClashSet(PropertyGroup): - name: StringProperty(name='Name') - tolerance: FloatProperty(name='Tolerance') - a: CollectionProperty(name='Group A', type=ClashSource) - b: CollectionProperty(name='Group B', type=ClashSource) + name: StringProperty(name="Name") + tolerance: FloatProperty(name="Tolerance") + a: CollectionProperty(name="Group A", type=ClashSource) + b: CollectionProperty(name="Group B", type=ClashSource) + + +class PresentationLayer(PropertyGroup): + name: StringProperty(name="Name") + description: StringProperty(name="Description") + assigned_items: EnumProperty(items=[], name="AssignedItems") + identifier: StringProperty(name="Identifier") + layer_on: BoolProperty(name="LayerOn", default=True) + layer_frozen: BoolProperty(name="LayerFrozen") + layer_blocked: BoolProperty(name="LayerBlocked") + layer_styles: EnumProperty(items=[], name="LayerStyles") class Constraint(PropertyGroup): - name: StringProperty(name='Name') - description: StringProperty(name='Description') - constraint_grade: EnumProperty(items=[ - ('HARD', 'HARD', 'Qualifies a constraint such that it must be followed rigidly within or at the values set.'), - ('SOFT', 'SOFT', 'Qualifies a constraint such that it should be followed within or at the values set.'), - ('ADVISORY', 'ADVISORY', - 'Qualifies a constraint such that it is advised that it is followed within or at the values set.'), - ('USERDEFINED', 'USERDEFINED', - 'A user-defined grade indicated by a separate attribute at the referencing entity.'), - ('NOTDEFINED', 'NOTDEFINED', 'Grade has not been specified.'), - ], name='Grade') - constraint_source: StringProperty(name='Source') - user_defined_grade: StringProperty(name='Custom Grade') - objective_qualifier: EnumProperty(items=[ - ('CODECOMPLIANCE', 'CODECOMPLIANCE', - 'A constraint whose objective is to ensure satisfaction of a code compliance provision.'), - ('CODEWAIVER', 'CODEWAIVER', - 'A constraint whose objective is to identify an agreement that code compliance requirements (the waiver) will not be enforced.'), - ('DESIGNINTENT', 'DESIGNINTENT', - 'A constraint whose objective is to ensure satisfaction of a design intent provision.'), - ('EXTERNAL', 'EXTERNAL', - 'A constraint whose objective is to synchronize data with an external source such as a file'), - ('HEALTHANDSAFETY', 'HEALTHANDSAFETY', - 'A constraint whose objective is to ensure satisfaction of a health and safety provision.'), - ('MERGECONFLICT', 'MERGECONFLICT', - 'A constraint whose objective is to resolve a conflict such as merging data from multiple sources.'), - ('MODELVIEW', 'MODELVIEW', - 'A constraint whose objective is to ensure data conforms to a model view definition.'), - ('PARAMETER', 'PARAMETER', - 'A constraint whose objective is to calculate a value based on other referenced values.'), - ('REQUIREMENT', 'REQUIREMENT', - 'A constraint whose objective is to ensure satisfaction of a project requirement provision.'), - ('SPECIFICATION', 'SPECIFICATION', - 'A constraint whose objective is to ensure satisfaction of a specification provision.'), - ('TRIGGERCONDITION', 'TRIGGERCONDITION', - 'A constraint whose objective is to indicate a limiting value beyond which the condition of an object requires a particular form of attention.'), - ('USERDEFINED', 'USERDEFINED', ''), - ('NOTDEFINED', 'NOTDEFINED', '') - ], name='Qualifier') - user_defined_qualifier: StringProperty(name='Custom Qualifier') + name: StringProperty(name="Name") + description: StringProperty(name="Description") + constraint_grade: EnumProperty( + items=[ + ( + "HARD", + "HARD", + "Qualifies a constraint such that it must be followed rigidly within or at the values set.", + ), + ("SOFT", "SOFT", "Qualifies a constraint such that it should be followed within or at the values set."), + ( + "ADVISORY", + "ADVISORY", + "Qualifies a constraint such that it is advised that it is followed within or at the values set.", + ), + ( + "USERDEFINED", + "USERDEFINED", + "A user-defined grade indicated by a separate attribute at the referencing entity.", + ), + ("NOTDEFINED", "NOTDEFINED", "Grade has not been specified."), + ], + name="Grade", + ) + constraint_source: StringProperty(name="Source") + user_defined_grade: StringProperty(name="Custom Grade") + objective_qualifier: EnumProperty( + items=[ + ( + "CODECOMPLIANCE", + "CODECOMPLIANCE", + "A constraint whose objective is to ensure satisfaction of a code compliance provision.", + ), + ( + "CODEWAIVER", + "CODEWAIVER", + "A constraint whose objective is to identify an agreement that code compliance requirements (the waiver) will not be enforced.", + ), + ( + "DESIGNINTENT", + "DESIGNINTENT", + "A constraint whose objective is to ensure satisfaction of a design intent provision.", + ), + ( + "EXTERNAL", + "EXTERNAL", + "A constraint whose objective is to synchronize data with an external source such as a file", + ), + ( + "HEALTHANDSAFETY", + "HEALTHANDSAFETY", + "A constraint whose objective is to ensure satisfaction of a health and safety provision.", + ), + ( + "MERGECONFLICT", + "MERGECONFLICT", + "A constraint whose objective is to resolve a conflict such as merging data from multiple sources.", + ), + ( + "MODELVIEW", + "MODELVIEW", + "A constraint whose objective is to ensure data conforms to a model view definition.", + ), + ( + "PARAMETER", + "PARAMETER", + "A constraint whose objective is to calculate a value based on other referenced values.", + ), + ( + "REQUIREMENT", + "REQUIREMENT", + "A constraint whose objective is to ensure satisfaction of a project requirement provision.", + ), + ( + "SPECIFICATION", + "SPECIFICATION", + "A constraint whose objective is to ensure satisfaction of a specification provision.", + ), + ( + "TRIGGERCONDITION", + "TRIGGERCONDITION", + "A constraint whose objective is to indicate a limiting value beyond which the condition of an object requires a particular form of attention.", + ), + ("USERDEFINED", "USERDEFINED", ""), + ("NOTDEFINED", "NOTDEFINED", ""), + ], + name="Qualifier", + ) + user_defined_qualifier: StringProperty(name="Custom Qualifier") class BcfTopic(PropertyGroup): - name: StringProperty(name='Name') + name: StringProperty(name="Name") class BcfTopicLabel(PropertyGroup): - name: StringProperty(name='Name') + name: StringProperty(name="Name") class BcfTopicLink(PropertyGroup): - name: StringProperty(name='Name') + name: StringProperty(name="Name") class BcfTopicFile(PropertyGroup): - name: StringProperty(name='Name') - reference: StringProperty(name='Reference') - date: StringProperty(name='Date') - is_external: BoolProperty(name='Is External') - ifc_project: StringProperty(name='IFC Project') - ifc_spatial: StringProperty(name='IFC Spatial') + name: StringProperty(name="Name") + reference: StringProperty(name="Reference") + date: StringProperty(name="Date") + is_external: BoolProperty(name="Is External") + ifc_project: StringProperty(name="IFC Project") + ifc_spatial: StringProperty(name="IFC Spatial") class BcfTopicDocumentReference(PropertyGroup): - name: StringProperty(name='Reference') - description: StringProperty(name='Description') - guid: StringProperty(name='GUID') - is_external: BoolProperty(name='Is External') + name: StringProperty(name="Reference") + description: StringProperty(name="Description") + guid: StringProperty(name="GUID") + is_external: BoolProperty(name="Is External") class BcfTopicRelatedTopic(PropertyGroup): - name: StringProperty(name='Name') - guid: StringProperty(name='GUID') + name: StringProperty(name="Name") + guid: StringProperty(name="GUID") def refreshBcfTopic(self, context): RefreshBcfTopic.refresh(context) -class RefreshBcfTopic(): +class RefreshBcfTopic: props: None topic: None @classmethod def refresh(cls, context): import bcfplugin + global bcfviewpoints_enum cls.props = bpy.context.scene.BCFProperties @@ -802,20 +922,20 @@ class RefreshBcfTopic(): cls.props.topic_priority = cls.topic.priority cls.props.topic_stage = cls.topic.stage if cls.topic.date: - cls.props.topic_creation_date = cls.topic.date.strftime('%a %Y-%m-%d %H:%S') + cls.props.topic_creation_date = cls.topic.date.strftime("%a %Y-%m-%d %H:%S") else: - cls.props.topic_creation_date = '' + cls.props.topic_creation_date = "" cls.props.topic_creation_author = cls.topic.author if cls.topic.modDate: - cls.props.topic_modified_date = cls.topic.modDate.strftime('%a %Y-%m-%d %H:%S') + cls.props.topic_modified_date = cls.topic.modDate.strftime("%a %Y-%m-%d %H:%S") else: - cls.props.topic_modified_date = '' + cls.props.topic_modified_date = "" cls.props.topic_modified_author = cls.topic.modAuthor cls.props.topic_assigned_to = cls.topic.assignee if cls.topic.dueDate: - cls.props.topic_due_date = cls.topic.dueDate.strftime('%a %Y-%m-%d %H:%S') + cls.props.topic_due_date = cls.topic.dueDate.strftime("%a %Y-%m-%d %H:%S") else: - cls.props.topic_due_date = '' + cls.props.topic_due_date = "" cls.props.topic_description = cls.topic.description @classmethod @@ -829,13 +949,14 @@ class RefreshBcfTopic(): @classmethod def load_topic_files(cls): import bcfplugin + while len(cls.props.topic_files) > 0: cls.props.topic_files.remove(0) files = bcfplugin.getRelevantIfcFiles(cls.topic) for f in files: new = cls.props.topic_files.add() new.name = f.filename - new.date = f.time.strftime('%a %Y-%m-%d %H:%S') + new.date = f.time.strftime("%a %Y-%m-%d %H:%S") new.reference = f.reference.uri new.ifc_project = f.ifcProjectId new.ifc_spatial = f.ifcSpatialStructureElement @@ -876,6 +997,7 @@ class RefreshBcfTopic(): @classmethod def load_related_topics(cls): import bcfplugin + while len(cls.props.topic_related_topics) > 0: cls.props.topic_related_topics.remove(0) for t in cls.topic.relatedTopics: @@ -886,27 +1008,29 @@ class RefreshBcfTopic(): @classmethod def load_viewpoints(cls): import bcfplugin + bcfviewpoints_enum.clear() bcf.BcfStore.viewpoints = bcfplugin.getViewpoints(cls.topic, realViewpoint=False) for i, viewpoint in enumerate(bcf.BcfStore.viewpoints): - bcfviewpoints_enum.append((str(i), 'View {}'.format(i + 1), '')) + bcfviewpoints_enum.append((str(i), "View {}".format(i + 1), "")) @classmethod def load_comments(cls): import bcfplugin + bcf.BcfStore.comments = bcfplugin.getComments(cls.topic) - comments = bpy.data.texts.get('BCF Comments') + comments = bpy.data.texts.get("BCF Comments") if comments: comments.clear() else: - comments = bpy.data.texts.new('BCF Comments') + comments = bpy.data.texts.new("BCF Comments") for i, comment in enumerate(bcf.BcfStore.comments): - comments.write('# Comment {} - {}\n'.format(i + 1, comment[1].xmlId)) - comments.write('# From: {} on {}\n'.format(comment[1].author, comment[1].date)) + comments.write("# Comment {} - {}\n".format(i + 1, comment[1].xmlId)) + comments.write("# From: {} on {}\n".format(comment[1].author, comment[1].date)) if comment[1].modDate: - comments.write('# Modified by {} on {}\n'.format(comment[1].modAuthor, comment[1].modDate)) + comments.write("# Modified by {} on {}\n".format(comment[1].modAuthor, comment[1].modDate)) comments.write(comment[1].comment) - comments.write('\n\n-----\n\n') + comments.write("\n\n-----\n\n") def getBcfViewpoints(self, context): @@ -918,156 +1042,188 @@ class PropertySetTemplate(PropertyGroup): global_id: StringProperty(name="Global ID") name: StringProperty(name="Name") description: StringProperty(name="Description") - template_type: EnumProperty(items=[ - ('PSET_TYPEDRIVENONLY', 'Pset - IfcTypeObject', - 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('PSET_TYPEDRIVENOVERRIDE', 'Pset - IfcTypeObject - Override', - 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('PSET_OCCURRENCEDRIVEN', 'Pset - IfcObject', - 'The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), - ('PSET_PERFORMANCEDRIVEN', 'Pset - IfcPerformanceHistory', - 'The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.'), - ('QTO_TYPEDRIVENONLY', 'Qto - IfcTypeObject', - 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.'), - ('QTO_TYPEDRIVENOVERRIDE', 'Qto - IfcTypeObject - Override', - 'The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.'), - ('QTO_OCCURRENCEDRIVEN', 'Qto - IfcObject', - 'The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.'), - ('NOTDEFINED', 'Not defined', - 'No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.') - ], name="Template Type") + template_type: EnumProperty( + items=[ + ( + "PSET_TYPEDRIVENONLY", + "Pset - IfcTypeObject", + "The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.", + ), + ( + "PSET_TYPEDRIVENOVERRIDE", + "Pset - IfcTypeObject - Override", + "The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.", + ), + ( + "PSET_OCCURRENCEDRIVEN", + "Pset - IfcObject", + "The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.", + ), + ( + "PSET_PERFORMANCEDRIVEN", + "Pset - IfcPerformanceHistory", + "The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.", + ), + ( + "QTO_TYPEDRIVENONLY", + "Qto - IfcTypeObject", + "The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.", + ), + ( + "QTO_TYPEDRIVENOVERRIDE", + "Qto - IfcTypeObject - Override", + "The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.", + ), + ( + "QTO_OCCURRENCEDRIVEN", + "Qto - IfcObject", + "The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.", + ), + ( + "NOTDEFINED", + "Not defined", + "No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.", + ), + ], + name="Template Type", + ) applicable_entity: StringProperty(name="Applicable Entity") class PropertyTemplate(PropertyGroup): - global_id: StringProperty(name='Global ID') - name: StringProperty(name='Name') - description: StringProperty(name='Description') - primary_measure_type: EnumProperty(items=[ - (x, x, '') for x in [ - 'IfcInteger', - 'IfcReal', - 'IfcBoolean', - 'IfcIdentifier', - 'IfcText', - 'IfcLabel', - 'IfcLogical', - 'IfcDateTime', - 'IfcDate', - 'IfcTime', - 'IfcDuration', - 'IfcTimeStamp', - - 'IfcPositiveInteger', - 'IfcBinary', - 'IfcVolumeMeasure', - 'IfcTimeMeasure', - 'IfcThermodynamicTemperatureMeasure', - 'IfcSolidAngleMeasure', - 'IfcPositiveRatioMeasure', - 'IfcRatioMeasure', - 'IfcPositivePlaneAngleMeasure', - 'IfcPlaneAngleMeasure', - 'IfcParameterValue', - 'IfcNumericMeasure', - 'IfcMassMeasure', - 'IfcPositiveLengthMeasure', - 'IfcLengthMeasure', - 'IfcElectricCurrentMeasure', - 'IfcDescriptiveMeasure', - 'IfcCountMeasure', - 'IfcContextDependentMeasure', - 'IfcAreaMeasure', - 'IfcAmountOfSubstanceMeasure', - 'IfcLuminousIntensityMeasure', - 'IfcNormalisedRatioMeasure', - 'IfcComplexNumber', - 'IfcNonNegativeLengthMeasure', - - 'IfcAbsorbedDoseMeasure', - 'IfcAccelerationMeasure', - 'IfcAngularVelocityMeasure', - 'IfcAreaDensityMeasure', - 'IfcCompoundPlaneAngleMeasure', - 'IfcCurvatureMeasure', - 'IfcDoseEquivalentMeasure', - 'IfcDynamicViscosityMeasure', - 'IfcElectricCapacitanceMeasure', - 'IfcElectricChargeMeasure', - 'IfcElectricConductanceMeasure', - 'IfcElectricResistanceMeasure', - 'IfcElectricVoltageMeasure', - 'IfcEnergyMeasure', - 'IfcForceMeasure', - 'IfcFrequencyMeasure', - 'IfcHeatFluxDensityMeasure', - 'IfcHeatingValueMeasure', - 'IfcIlluminanceMeasure', - 'IfcInductanceMeasure', - 'IfcIntegerCountRateMeasure', - 'IfcIonConcentrationMeasure', - 'IfcIsothermalMoistureCapacityMeasure', - 'IfcKinematicViscosityMeasure', - 'IfcLinearForceMeasure', - 'IfcLinearMomentMeasure', - 'IfcLinearStiffnessMeasure', - 'IfcLinearVelocityMeasure', - 'IfcLuminousFluxMeasure', - 'IfcLuminousIntensityDistributionMeasure', - 'IfcMagneticFluxDensityMeasure', - 'IfcMagneticFluxMeasure', - 'IfcMassDensityMeasure', - 'IfcMassFlowRateMeasure', - 'IfcMassPerLengthMeasure', - 'IfcModulusOfElasticityMeasure', - 'IfcModulusOfLinearSubgradeReactionMeasure', - 'IfcModulusOfRotationalSubgradeReactionMeasure', - 'IfcModulusOfSubgradeReactionMeasure', - 'IfcMoistureDiffusivityMeasure', - 'IfcMolecularWeightMeasure', - 'IfcMomentOfInertiaMeasure', - 'IfcMonetaryMeasure', - 'IfcPHMeasure', - 'IfcPlanarForceMeasure', - 'IfcPowerMeasure', - 'IfcPressureMeasure', - 'IfcRadioActivityMeasure', - 'IfcRotationalFrequencyMeasure', - 'IfcRotationalMassMeasure', - 'IfcRotationalStiffnessMeasure', - 'IfcSectionModulusMeasure', - 'IfcSectionalAreaIntegralMeasure', - 'IfcShearModulusMeasure', - 'IfcSoundPowerLevelMeasure', - 'IfcSoundPowerMeasure', - 'IfcSoundPressureLevelMeasure', - 'IfcSoundPressureMeasure', - 'IfcSpecificHeatCapacityMeasure', - 'IfcTemperatureGradientMeasure', - 'IfcTemperatureRateOfChangeMeasure', - 'IfcThermalAdmittanceMeasure', - 'IfcThermalConductivityMeasure', - 'IfcThermalExpansionCoefficientMeasure', - 'IfcThermalResistanceMeasure', - 'IfcThermalTransmittanceMeasure', - 'IfcTorqueMeasure', - 'IfcVaporPermeabilityMeasure', - 'IfcVolumetricFlowRateMeasure', - 'IfcWarpingConstantMeasure', - 'IfcWarpingMomentMeasure', - ] - ], name='Primary Measure Type') + global_id: StringProperty(name="Global ID") + name: StringProperty(name="Name") + description: StringProperty(name="Description") + primary_measure_type: EnumProperty( + items=[ + (x, x, "") + for x in [ + "IfcInteger", + "IfcReal", + "IfcBoolean", + "IfcIdentifier", + "IfcText", + "IfcLabel", + "IfcLogical", + "IfcDateTime", + "IfcDate", + "IfcTime", + "IfcDuration", + "IfcTimeStamp", + "IfcPositiveInteger", + "IfcBinary", + "IfcVolumeMeasure", + "IfcTimeMeasure", + "IfcThermodynamicTemperatureMeasure", + "IfcSolidAngleMeasure", + "IfcPositiveRatioMeasure", + "IfcRatioMeasure", + "IfcPositivePlaneAngleMeasure", + "IfcPlaneAngleMeasure", + "IfcParameterValue", + "IfcNumericMeasure", + "IfcMassMeasure", + "IfcPositiveLengthMeasure", + "IfcLengthMeasure", + "IfcElectricCurrentMeasure", + "IfcDescriptiveMeasure", + "IfcCountMeasure", + "IfcContextDependentMeasure", + "IfcAreaMeasure", + "IfcAmountOfSubstanceMeasure", + "IfcLuminousIntensityMeasure", + "IfcNormalisedRatioMeasure", + "IfcComplexNumber", + "IfcNonNegativeLengthMeasure", + "IfcAbsorbedDoseMeasure", + "IfcAccelerationMeasure", + "IfcAngularVelocityMeasure", + "IfcAreaDensityMeasure", + "IfcCompoundPlaneAngleMeasure", + "IfcCurvatureMeasure", + "IfcDoseEquivalentMeasure", + "IfcDynamicViscosityMeasure", + "IfcElectricCapacitanceMeasure", + "IfcElectricChargeMeasure", + "IfcElectricConductanceMeasure", + "IfcElectricResistanceMeasure", + "IfcElectricVoltageMeasure", + "IfcEnergyMeasure", + "IfcForceMeasure", + "IfcFrequencyMeasure", + "IfcHeatFluxDensityMeasure", + "IfcHeatingValueMeasure", + "IfcIlluminanceMeasure", + "IfcInductanceMeasure", + "IfcIntegerCountRateMeasure", + "IfcIonConcentrationMeasure", + "IfcIsothermalMoistureCapacityMeasure", + "IfcKinematicViscosityMeasure", + "IfcLinearForceMeasure", + "IfcLinearMomentMeasure", + "IfcLinearStiffnessMeasure", + "IfcLinearVelocityMeasure", + "IfcLuminousFluxMeasure", + "IfcLuminousIntensityDistributionMeasure", + "IfcMagneticFluxDensityMeasure", + "IfcMagneticFluxMeasure", + "IfcMassDensityMeasure", + "IfcMassFlowRateMeasure", + "IfcMassPerLengthMeasure", + "IfcModulusOfElasticityMeasure", + "IfcModulusOfLinearSubgradeReactionMeasure", + "IfcModulusOfRotationalSubgradeReactionMeasure", + "IfcModulusOfSubgradeReactionMeasure", + "IfcMoistureDiffusivityMeasure", + "IfcMolecularWeightMeasure", + "IfcMomentOfInertiaMeasure", + "IfcMonetaryMeasure", + "IfcPHMeasure", + "IfcPlanarForceMeasure", + "IfcPowerMeasure", + "IfcPressureMeasure", + "IfcRadioActivityMeasure", + "IfcRotationalFrequencyMeasure", + "IfcRotationalMassMeasure", + "IfcRotationalStiffnessMeasure", + "IfcSectionModulusMeasure", + "IfcSectionalAreaIntegralMeasure", + "IfcShearModulusMeasure", + "IfcSoundPowerLevelMeasure", + "IfcSoundPowerMeasure", + "IfcSoundPressureLevelMeasure", + "IfcSoundPressureMeasure", + "IfcSpecificHeatCapacityMeasure", + "IfcTemperatureGradientMeasure", + "IfcTemperatureRateOfChangeMeasure", + "IfcThermalAdmittanceMeasure", + "IfcThermalConductivityMeasure", + "IfcThermalExpansionCoefficientMeasure", + "IfcThermalResistanceMeasure", + "IfcThermalTransmittanceMeasure", + "IfcTorqueMeasure", + "IfcVaporPermeabilityMeasure", + "IfcVolumetricFlowRateMeasure", + "IfcWarpingConstantMeasure", + "IfcWarpingMomentMeasure", + ] + ], + name="Primary Measure Type", + ) class Address(PropertyGroup): - name: StringProperty(name="Name", default='IfcPostalAddress') # Stores IfcPostalAddress or IfcTelecomAddress - purpose: EnumProperty(items=[ - ('OFFICE', 'OFFICE', 'An office address.'), - ('SITE', 'SITE', 'A site address.'), - ('HOME', 'HOME', 'A home address.'), - ('DISTRIBUTIONPOINT', 'DISTRIBUTIONPOINT', 'A postal distribution point address.'), - ('USERDEFINED', 'USERDEFINED', 'A user defined address type to be provided.'), - ], name='Purpose') + name: StringProperty(name="Name", default="IfcPostalAddress") # Stores IfcPostalAddress or IfcTelecomAddress + purpose: EnumProperty( + items=[ + ("OFFICE", "OFFICE", "An office address."), + ("SITE", "SITE", "A site address."), + ("HOME", "HOME", "A home address."), + ("DISTRIBUTIONPOINT", "DISTRIBUTIONPOINT", "A postal distribution point address."), + ("USERDEFINED", "USERDEFINED", "A user defined address type to be provided."), + ], + name="Purpose", + ) description: StringProperty(name="Description") user_defined_purpose: StringProperty(name="Custom Purpose") @@ -1088,31 +1244,34 @@ class Address(PropertyGroup): class Role(PropertyGroup): - name: EnumProperty(items=[ - ('SUPPLIER', 'SUPPLIER', ''), - ('MANUFACTURER', 'MANUFACTURER', ''), - ('CONTRACTOR', 'CONTRACTOR', ''), - ('SUBCONTRACTOR', 'SUBCONTRACTOR', ''), - ('ARCHITECT', 'ARCHITECT', ''), - ('STRUCTURALENGINEER', 'STRUCTURALENGINEER', ''), - ('COSTENGINEER', 'COSTENGINEER', ''), - ('CLIENT', 'CLIENT', ''), - ('BUILDINGOWNER', 'BUILDINGOWNER', ''), - ('BUILDINGOPERATOR', 'BUILDINGOPERATOR', ''), - ('MECHANICALENGINEER', 'MECHANICALENGINEER', ''), - ('ELECTRICALENGINEER', 'ELECTRICALENGINEER', ''), - ('PROJECTMANAGER', 'PROJECTMANAGER', ''), - ('FACILITIESMANAGER', 'FACILITIESMANAGER', ''), - ('CIVILENGINEER', 'CIVILENGINEER', ''), - ('COMMISSIONINGENGINEER', 'COMMISSIONINGENGINEER', ''), - ('ENGINEER', 'ENGINEER', ''), - ('OWNER', 'OWNER', ''), - ('CONSULTANT', 'CONSULTANT', ''), - ('CONSTRUCTIONMANAGER', 'CONSTRUCTIONMANAGER', ''), - ('FIELDCONSTRUCTIONMANAGER', 'FIELDCONSTRUCTIONMANAGER', ''), - ('RESELLER', 'RESELLER', ''), - ('USERDEFINED', 'USERDEFINED', ''), - ], name='Name') + name: EnumProperty( + items=[ + ("SUPPLIER", "SUPPLIER", ""), + ("MANUFACTURER", "MANUFACTURER", ""), + ("CONTRACTOR", "CONTRACTOR", ""), + ("SUBCONTRACTOR", "SUBCONTRACTOR", ""), + ("ARCHITECT", "ARCHITECT", ""), + ("STRUCTURALENGINEER", "STRUCTURALENGINEER", ""), + ("COSTENGINEER", "COSTENGINEER", ""), + ("CLIENT", "CLIENT", ""), + ("BUILDINGOWNER", "BUILDINGOWNER", ""), + ("BUILDINGOPERATOR", "BUILDINGOPERATOR", ""), + ("MECHANICALENGINEER", "MECHANICALENGINEER", ""), + ("ELECTRICALENGINEER", "ELECTRICALENGINEER", ""), + ("PROJECTMANAGER", "PROJECTMANAGER", ""), + ("FACILITIESMANAGER", "FACILITIESMANAGER", ""), + ("CIVILENGINEER", "CIVILENGINEER", ""), + ("COMMISSIONINGENGINEER", "COMMISSIONINGENGINEER", ""), + ("ENGINEER", "ENGINEER", ""), + ("OWNER", "OWNER", ""), + ("CONSULTANT", "CONSULTANT", ""), + ("CONSTRUCTIONMANAGER", "CONSTRUCTIONMANAGER", ""), + ("FIELDCONSTRUCTIONMANAGER", "FIELDCONSTRUCTIONMANAGER", ""), + ("RESELLER", "RESELLER", ""), + ("USERDEFINED", "USERDEFINED", ""), + ], + name="Name", + ) user_defined_role: StringProperty(name="Custom Role") description: StringProperty(name="Description") @@ -1169,9 +1328,9 @@ class ClassificationView(PropertyGroup): def root(self): data = self.raw_data for crumb in self.crumbs: - data = data['children'].get(crumb.name) + data = data["children"].get(crumb.name) if not data: - raise TypeError('Cannot resolve crumb path') + raise TypeError("Cannot resolve crumb path") return data @root.setter @@ -1179,58 +1338,54 @@ class ClassificationView(PropertyGroup): if rt == None: self.crumbs.clear() self.children.clear() - elif rt == '': + elif rt == "": if self.crumbs: self.crumbs.remove(len(self.crumbs) - 1) self.children.clear() - for child in self.root['children'].keys(): + for child in self.root["children"].keys(): self.children.add().name = child else: data = self.root - if rt in data['children'].keys(): + if rt in data["children"].keys(): self.crumbs.add().name = rt self.children.clear() - for child in data['children'][rt]['children'].keys(): + for child in data["children"][rt]["children"].keys(): self.children.add().name = child def draw_stub(self, context, layout): if not self.children: - op = layout.operator('bim.change_classification_level', text="@Toplevel") + op = layout.operator("bim.change_classification_level", text="@Toplevel") else: - op = layout.operator('bim.change_classification_level', text=self.root['name']) + op = layout.operator("bim.change_classification_level", text=self.root["name"]) op.path_sid = "%r" % self.id_data op.path_lst = self.path_from_id() - op.path_itm = '' - layout.template_list('BIM_UL_classifications', - self.path_from_id(), self, 'children', self, 'active_index') + op.path_itm = "" + layout.template_list("BIM_UL_classifications", self.path_from_id(), self, "children", self, "active_index") # Monkey-patched, just to keep registration in one block -ClassificationView.__annotations__['crumbs'] = \ - bpy.props.CollectionProperty(type=StrProperty) -ClassificationView.__annotations__['children'] = \ - bpy.props.CollectionProperty(type=StrProperty) +ClassificationView.__annotations__["crumbs"] = bpy.props.CollectionProperty(type=StrProperty) +ClassificationView.__annotations__["children"] = bpy.props.CollectionProperty(type=StrProperty) class BIMProperties(PropertyGroup): - schema_dir: StringProperty(default=os.path.join(cwd, 'schema') + os.path.sep, name="Schema Directory") - data_dir: StringProperty(default=os.path.join(cwd, 'data') + os.path.sep, name="Data Directory") + schema_dir: StringProperty(default=os.path.join(cwd, "schema") + os.path.sep, name="Schema Directory") + data_dir: StringProperty(default=os.path.join(cwd, "data") + os.path.sep, name="Data Directory") ifc_file: StringProperty(name="IFC File") ifc_cache: StringProperty(name="IFC Cache") audit_ifc_class: EnumProperty(items=getIfcClasses, name="Audit Class") ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses) ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes) - ifc_predefined_type: EnumProperty( - items=getIfcPredefinedTypes, - name="Predefined Type", default=None) + ifc_predefined_type: EnumProperty(items=getIfcPredefinedTypes, name="Predefined Type", default=None) ifc_userdefined_type: StringProperty(name="Userdefined Type") - export_schema: EnumProperty(items=[('IFC4', 'IFC4', ''), ('IFC2X3', 'IFC2X3', '')], name='IFC Schema') - export_json_version: EnumProperty(items=[('4', '4', ''), ('5a', '5a', '')], name='IFC JSON Version') + export_schema: EnumProperty(items=[("IFC4", "IFC4", ""), ("IFC2X3", "IFC2X3", "")], name="IFC Schema") + export_json_version: EnumProperty(items=[("4", "4", ""), ("5a", "5a", "")], name="IFC JSON Version") export_json_compact: BoolProperty(name="Export Compact IFCJSON", default=False) export_has_representations: BoolProperty(name="Export Representations", default=True) export_should_guess_quantities: BoolProperty(name="Export with Guessed Quantities", default=False) - export_should_use_presentation_style_assignment: BoolProperty(name="Export with Presentation Style Assignment", - default=False) + export_should_use_presentation_style_assignment: BoolProperty( + name="Export with Presentation Style Assignment", default=False + ) export_should_force_faceted_brep: BoolProperty(name="Export with Faceted Breps", default=False) import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False) import_should_ignore_building_coordinates: BoolProperty(name="Import Ignoring Building Coordinates", default=False) @@ -1240,8 +1395,9 @@ class BIMProperties(PropertyGroup): import_should_import_opening_elements: BoolProperty(name="Import Opening Elements", default=False) import_should_import_spaces: BoolProperty(name="Import Spaces", default=False) import_should_auto_set_workarounds: BoolProperty(name="Automatically Set Vendor Workarounds", default=True) - import_should_treat_styled_item_as_material: BoolProperty(name="Import Treating Styled Item as Material", - default=False) + import_should_treat_styled_item_as_material: BoolProperty( + name="Import Treating Styled Item as Material", default=False + ) import_should_use_legacy: BoolProperty(name="Import with Legacy Importer", default=False) import_should_import_native: BoolProperty(name="Import Native Representations", default=False) import_export_should_roundtrip_native: BoolProperty(name="Roundtrip Native Representations", default=False) @@ -1257,14 +1413,14 @@ class BIMProperties(PropertyGroup): import_angular_tolerance: FloatProperty(name="Import Angular Tolerance", default=0.5) import_should_allow_non_element_aggregates: BoolProperty(name="Import Non-Element Aggregates", default=False) import_should_offset_model: BoolProperty(name="Import and Offset Model", default=False) - import_model_offset_coordinates: StringProperty(name="Model Offset Coordinates", default='0,0,0') + import_model_offset_coordinates: StringProperty(name="Model Offset Coordinates", default="0,0,0") qa_reject_element_reason: StringProperty(name="Element Rejection Reason") person: EnumProperty(items=getPersons, name="Person") organisation: EnumProperty(items=getOrganisations, name="Organisation") people: CollectionProperty(name="People", type=Person) organisations: CollectionProperty(name="Organisations", type=Organisation) - active_person_index: IntProperty(name='Active Person Index') - active_organisation_index: IntProperty(name='Active Organisation Index') + active_person_index: IntProperty(name="Active Person Index") + active_organisation_index: IntProperty(name="Active Organisation Index") has_georeferencing: BoolProperty(name="Has Georeferencing", default=False) has_library: BoolProperty(name="Has Project Library", default=False) search_regex: BoolProperty(name="Search With Regex", default=False) @@ -1275,17 +1431,17 @@ class BIMProperties(PropertyGroup): search_pset_name: StringProperty(name="Search Pset Name") search_prop_name: StringProperty(name="Search Prop Name") search_pset_value: StringProperty(name="Search Pset Value") - features_dir: StringProperty(default='', name="Features Directory", update=refreshFeaturesFiles) + features_dir: StringProperty(default="", name="Features Directory", update=refreshFeaturesFiles) features_file: EnumProperty(items=getFeaturesFiles, name="Features File", update=refreshScenarios) scenario: EnumProperty(items=getScenarios, name="Scenario") - cobie_ifc_file: StringProperty(default='', name="COBie IFC File") - cobie_types: StringProperty(default='.COBieType', name="COBie Types") - cobie_components: StringProperty(default='.COBie', name="COBie Components") - cobie_json_file: StringProperty(default='', name="COBie JSON File") - diff_json_file: StringProperty(default='', name="Diff JSON File") - diff_old_file: StringProperty(default='', name="Diff Old IFC File") - diff_new_file: StringProperty(default='', name="Diff New IFC File") - diff_relationships: StringProperty(default='', name="Diff Relationships") + cobie_ifc_file: StringProperty(default="", name="COBie IFC File") + cobie_types: StringProperty(default=".COBieType", name="COBie Types") + cobie_components: StringProperty(default=".COBie", name="COBie Components") + cobie_json_file: StringProperty(default="", name="COBie JSON File") + diff_json_file: StringProperty(default="", name="Diff JSON File") + diff_old_file: StringProperty(default="", name="Diff Old IFC File") + diff_new_file: StringProperty(default="", name="Diff New IFC File") + diff_relationships: StringProperty(default="", name="Diff Relationships") aggregate_class: EnumProperty(items=getIfcClasses, name="Aggregate Class") aggregate_name: StringProperty(name="Aggregate Name") classification: EnumProperty(items=getClassifications, name="Classification", update=refreshReferences) @@ -1293,102 +1449,118 @@ class BIMProperties(PropertyGroup): classifications: CollectionProperty(name="Classifications", type=Classification) has_model_context: BoolProperty(name="Has Model Context", default=True) has_plan_context: BoolProperty(name="Has Plan Context", default=True) - model_subcontexts: CollectionProperty(name='Model Subcontexts', type=Subcontext) - plan_subcontexts: CollectionProperty(name='Plan Subcontexts', type=Subcontext) - available_contexts: EnumProperty(items=[('Model', 'Model', ''), ('Plan', 'Plan', '')], name="Available Contexts") + model_subcontexts: CollectionProperty(name="Model Subcontexts", type=Subcontext) + plan_subcontexts: CollectionProperty(name="Plan Subcontexts", type=Subcontext) + available_contexts: EnumProperty(items=[("Model", "Model", ""), ("Plan", "Plan", "")], name="Available Contexts") available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts") available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views") classification_references: PointerProperty(type=ClassificationView) - pset_template_files: EnumProperty(items=getPsetTemplateFiles, name="Pset Template Files", - update=refreshPropertySetTemplates) + pset_template_files: EnumProperty( + items=getPsetTemplateFiles, name="Pset Template Files", update=refreshPropertySetTemplates + ) property_set_templates: EnumProperty(items=getPropertySetTemplates, name="Pset Template Files") active_property_set_template: PointerProperty(type=PropertySetTemplate) - property_templates: CollectionProperty(name='Property Templates', type=PropertyTemplate) + property_templates: CollectionProperty(name="Property Templates", type=PropertyTemplate) should_section_selected_objects: BoolProperty(name="Section Selected Objects", default=False) - section_plane_colour: FloatVectorProperty(name='Temporary Section Cutaway Colour', subtype='COLOR', - default=(1, 0, 0), min=0.0, max=1.0) - ifc_import_filter: EnumProperty(items=[ - ('NONE', 'None', ''), - ('WHITELIST', 'Whitelist', ''), - ('BLACKLIST', 'Blacklist', ''), - ], name='Import Filter') - ifc_selector: StringProperty(default='', name='IFC Selector') - csv_attributes: CollectionProperty(name='CSV Attributes', type=StrProperty) - document_information: CollectionProperty(name='Document Information', type=DocumentInformation) - active_document_information_index: IntProperty(name='Active Document Information Index') - document_references: CollectionProperty(name='Document References', type=DocumentReference) - active_document_reference_index: IntProperty(name='Active Document Reference Index') - clash_sets: CollectionProperty(name='Clash Sets', type=ClashSet) - active_clash_set_index: IntProperty(name='Active Clash Set Index') - constraints: CollectionProperty(name='Constraints', type=Constraint) - active_constraint_index: IntProperty(name='Active Constraint Index') + section_plane_colour: FloatVectorProperty( + name="Temporary Section Cutaway Colour", subtype="COLOR", default=(1, 0, 0), min=0.0, max=1.0 + ) + ifc_import_filter: EnumProperty( + items=[("NONE", "None", ""), ("WHITELIST", "Whitelist", ""), ("BLACKLIST", "Blacklist", ""), ], + name="Import Filter", + ) + ifc_selector: StringProperty(default="", name="IFC Selector") + csv_attributes: CollectionProperty(name="CSV Attributes", type=StrProperty) + document_information: CollectionProperty(name="Document Information", type=DocumentInformation) + active_document_information_index: IntProperty(name="Active Document Information Index") + document_references: CollectionProperty(name="Document References", type=DocumentReference) + active_document_reference_index: IntProperty(name="Active Document Reference Index") + clash_sets: CollectionProperty(name="Clash Sets", type=ClashSet) + active_clash_set_index: IntProperty(name="Active Clash Set Index") + constraints: CollectionProperty(name="Constraints", type=Constraint) + active_constraint_index: IntProperty(name="Active Constraint Index") ifc_patch_recipes: EnumProperty(items=getIfcPatchRecipes, name="Recipes") - ifc_patch_input: StringProperty(default='', name='IFC Patch Input IFC') - ifc_patch_output: StringProperty(default='', name='IFC Patch Output IFC') - ifc_patch_args: StringProperty(default='', name='Arguments') - qto_result: StringProperty(default='', name='Qto Result') - area_unit: EnumProperty(items=[ - ('square centimeters', 'square centimeters', ''), - ('square feet', 'square feet', ''), - ('square inches', 'square inches', ''), - ('square kilometers', 'square kilometers', ''), - ('SQUARE_METRE', 'square meters', ''), - ('square miles', 'square miles', ''), - ('square millimeters', 'square millimeters', ''), - ('square yards', 'square yards', ''), - ], name='IFC Area Unit') - volume_unit: EnumProperty(items=[ - ('cubic centimeters', 'cubic centimeters', ''), - ('cubic feet', 'cubic feet', ''), - ('cubic inches', 'cubic inches', ''), - ('CUBIC_METRE', 'cubic meters', ''), - ('cubic millimeters', 'cubic millimeters', ''), - ('cubic yards', 'cubic yards', ''), - ], name='IFC Volume Unit') - metric_precision: FloatProperty(default=0, name='Drawing Metric Precision') - imperial_precision: EnumProperty(items=[ - ('NONE', 'No rounding', ''), - ('1', 'Nearest 1"', ''), - ('1/2', 'Nearest 1/2"', ''), - ('1/4', 'Nearest 1/4"', ''), - ('1/8', 'Nearest 1/8"', ''), - ('1/16', 'Nearest 1/16"', ''), - ('1/32', 'Nearest 1/32"', ''), - ('1/64', 'Nearest 1/64"', ''), - ('1/128', 'Nearest 1/128"', ''), - ('1/256', 'Nearest 1/256"', ''), - ], name='Drawing Imperial Precision') - override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, - max=1.0, size=4) + ifc_patch_input: StringProperty(default="", name="IFC Patch Input IFC") + ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC") + ifc_patch_args: StringProperty(default="", name="Arguments") + qto_result: StringProperty(default="", name="Qto Result") + area_unit: EnumProperty( + default="SQUARE_METRE", + items=[ + ("MILLI/SQUARE_METRE", "Square Millimetre", ""), + ("CENTI/SQUARE_METRE", "Square Centimetre", ""), + ("SQUARE_METRE", "Square Metre", ""), + ("KILO/SQUARE_METRE", "Square Kilometre", ""), + ("square inch", "Square Inch", ""), + ("square foot", "Square Foot", ""), + ("square yard", "Square Yard", ""), + ("square mile", "Square Mile", ""), + ], + name="IFC Area Unit", + ) + volume_unit: EnumProperty( + default="CUBIC_METRE", + items=[ + ("MILLI/CUBIC_METRE", "Cubic Millimetre", ""), + ("CENTI/CUBIC_METRE", "Cubic Centimetre", ""), + ("CUBIC_METRE", "Cubic Metre", ""), + ("KILO/CUBIC_METRE", "Cubic Kilometre", ""), + ("cubic inch", "Cubic Inch", ""), + ("cubic foot", "Cubic Foot", ""), + ("cubic yard", "Cubic Yard", ""), + ], + name="IFC Volume Unit", + ) + metric_precision: FloatProperty(default=0, name="Drawing Metric Precision") + imperial_precision: EnumProperty( + items=[ + ("NONE", "No rounding", ""), + ("1", 'Nearest 1"', ""), + ("1/2", 'Nearest 1/2"', ""), + ("1/4", 'Nearest 1/4"', ""), + ("1/8", 'Nearest 1/8"', ""), + ("1/16", 'Nearest 1/16"', ""), + ("1/32", 'Nearest 1/32"', ""), + ("1/64", 'Nearest 1/64"', ""), + ("1/128", 'Nearest 1/128"', ""), + ("1/256", 'Nearest 1/256"', ""), + ], + name="Drawing Imperial Precision", + ) + override_colour: FloatVectorProperty( + name="Override Colour", subtype="COLOR", default=(1, 0, 0, 1), min=0.0, max=1.0, size=4 + ) + + # presentation_layer: CollectionProperty(name="Presentation Layers", type=PresentationLayer) class BCFProperties(PropertyGroup): - bcf_file: StringProperty(default='', name='BCF File') - topics: CollectionProperty(name='BCF Topics', type=BcfTopic) - active_topic_index: IntProperty(name='Active BCF Topic Index', update=refreshBcfTopic) - viewpoints: EnumProperty(items=getBcfViewpoints, name='BCF Viewpoints') - topic_guid: StringProperty(default='', name='Topic GUID') - topic_type: StringProperty(default='', name='Topic Type') - topic_status: StringProperty(default='', name='Topic Status') - topic_priority: StringProperty(default='', name='Topic Priority') - topic_stage: StringProperty(default='', name='Topic Stage') - topic_creation_date: StringProperty(default='', name='Topic Date') - topic_creation_author: StringProperty(default='', name='Topic Author') - topic_modified_date: StringProperty(default='', name='Topic Modified Date') - topic_modified_author: StringProperty(default='', name='Topic Modified By') - topic_assigned_to: StringProperty(default='', name='Topic Assigned To') - topic_due_date: StringProperty(default='', name='Topic Due Date') - topic_description: StringProperty(default='', name='Topic Description') - topic_labels: CollectionProperty(name='BCF Topic Labels', type=BcfTopicLabel) - topic_files: CollectionProperty(name='BCF Topic Files', type=BcfTopicFile) - topic_links: CollectionProperty(name='BCF Topic Links', type=BcfTopicLink) - topic_has_snippet: BoolProperty(name='BCF Topic Has Snippet', default=False) - topic_snippet_reference: StringProperty(name='BIM Snippet Reference') - topic_snippet_schema: StringProperty(name='BIM Snippet Schema') - topic_snippet_type: StringProperty(name='BIM Snippet Type') - topic_snippet_is_external: BoolProperty(name='Is BIM Snippet External') - topic_document_references: CollectionProperty(name='BCF Topic Document References', type=BcfTopicDocumentReference) - topic_related_topics: CollectionProperty(name='BCF Topic Related Topics', type=BcfTopicRelatedTopic) + bcf_file: StringProperty(default="", name="BCF File") + topics: CollectionProperty(name="BCF Topics", type=BcfTopic) + active_topic_index: IntProperty(name="Active BCF Topic Index", update=refreshBcfTopic) + viewpoints: EnumProperty(items=getBcfViewpoints, name="BCF Viewpoints") + topic_guid: StringProperty(default="", name="Topic GUID") + topic_type: StringProperty(default="", name="Topic Type") + topic_status: StringProperty(default="", name="Topic Status") + topic_priority: StringProperty(default="", name="Topic Priority") + topic_stage: StringProperty(default="", name="Topic Stage") + topic_creation_date: StringProperty(default="", name="Topic Date") + topic_creation_author: StringProperty(default="", name="Topic Author") + topic_modified_date: StringProperty(default="", name="Topic Modified Date") + topic_modified_author: StringProperty(default="", name="Topic Modified By") + topic_assigned_to: StringProperty(default="", name="Topic Assigned To") + topic_due_date: StringProperty(default="", name="Topic Due Date") + topic_description: StringProperty(default="", name="Topic Description") + topic_labels: CollectionProperty(name="BCF Topic Labels", type=BcfTopicLabel) + topic_files: CollectionProperty(name="BCF Topic Files", type=BcfTopicFile) + topic_links: CollectionProperty(name="BCF Topic Links", type=BcfTopicLink) + topic_has_snippet: BoolProperty(name="BCF Topic Has Snippet", default=False) + topic_snippet_reference: StringProperty(name="BIM Snippet Reference") + topic_snippet_schema: StringProperty(name="BIM Snippet Schema") + topic_snippet_type: StringProperty(name="BIM Snippet Type") + topic_snippet_is_external: BoolProperty(name="Is BIM Snippet External") + topic_document_references: CollectionProperty(name="BCF Topic Document References", type=BcfTopicDocumentReference) + topic_related_topics: CollectionProperty(name="BCF Topic Related Topics", type=BcfTopicRelatedTopic) class MapConversion(PropertyGroup): @@ -1446,39 +1618,35 @@ class GlobalId(PropertyGroup): class BoundaryCondition(PropertyGroup): - name: EnumProperty(items=getBoundaryConditionClasses, name='Boundary Type', - update=refreshBoundaryConditionAttributes) - attributes: CollectionProperty(name="Attributes", type=Attribute) - - -class PresentationLayer(PropertyGroup): - name: EnumProperty(items=getPresentationLayerClasses, name='Presentation Layer', - update=refreshPresentationLayerAttributes) + name: EnumProperty( + items=getBoundaryConditionClasses, name="Boundary Type", update=refreshBoundaryConditionAttributes + ) attributes: CollectionProperty(name="Attributes", type=Attribute) class BIMObjectProperties(PropertyGroup): global_ids: CollectionProperty(name="GlobalIds", type=GlobalId) attributes: CollectionProperty(name="Attributes", type=Attribute) - relating_type: PointerProperty(name='Type Product', type=bpy.types.Object) - relating_structure: PointerProperty(name='Spatial Container', type=bpy.types.Object) + relating_type: PointerProperty(name="Type Product", type=bpy.types.Object) + relating_structure: PointerProperty(name="Spatial Container", type=bpy.types.Object) psets: CollectionProperty(name="Psets", type=PsetQto) qtos: CollectionProperty(name="Qtos", type=PsetQto) applicable_attributes: EnumProperty(items=getApplicableAttributes, name="Attribute Names") document_references: CollectionProperty(name="Document References", type=DocumentReference) - active_document_reference_index: IntProperty(name='Active Document Reference Index') - constraints: CollectionProperty(name='Constraints', type=Constraint) - active_constraint_index: IntProperty(name='Active Constraint Index') + active_document_reference_index: IntProperty(name="Active Document Reference Index") + constraints: CollectionProperty(name="Constraints", type=Constraint) + active_constraint_index: IntProperty(name="Active Constraint Index") classifications: CollectionProperty(name="Classifications", type=ClassificationReference) material_type: EnumProperty(items=getMaterialTypes, name="Material Type") - pset_name: EnumProperty(items=getPsetNames, name='Pset Name') - qto_name: EnumProperty(items=getQtoNames, name='Qto Name') - has_boundary_condition: BoolProperty(name='Has Boundary Condition') - boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition) - structural_member_connection: PointerProperty(name='Structural Member Connection', type=bpy.types.Object) + pset_name: EnumProperty(items=getPsetNames, name="Pset Name") + qto_name: EnumProperty(items=getQtoNames, name="Qto Name") + has_boundary_condition: BoolProperty(name="Has Boundary Condition") + boundary_condition: PointerProperty(name="Boundary Condition", type=BoundaryCondition) + presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer) + structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object) representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext) # Address applies to IfcSite's SiteAddress and IfcBuilding's BuildingAddress - address: PointerProperty(name='Address', type=Address) + address: PointerProperty(name="Address", type=Address) class BIMDebugProperties(PropertyGroup): @@ -1495,8 +1663,8 @@ class BIMMaterialProperties(PropertyGroup): psets: CollectionProperty(name="Psets", type=PsetQto) attributes: CollectionProperty(name="Attributes", type=Attribute) applicable_attributes: EnumProperty(items=getApplicableMaterialAttributes, name="Attribute Names") - profile_def: EnumProperty(items=getProfileDef, name='Parameterized Profile Def', update=refreshProfileAttributes) - profile_attributes: CollectionProperty(name='Profile Attributes', type=Attribute) + profile_def: EnumProperty(items=getProfileDef, name="Parameterized Profile Def", update=refreshProfileAttributes) + profile_attributes: CollectionProperty(name="Profile Attributes", type=Attribute) class SweptSolid(PropertyGroup): @@ -1515,10 +1683,10 @@ class BIMMeshProperties(PropertyGroup): is_native: BoolProperty(name="Is Native", default=False) is_swept_solid: BoolProperty(name="Is Swept Solid") swept_solids: CollectionProperty(name="Swept Solids", type=SweptSolid) - is_parametric: BoolProperty(name='Is Parametric', default=False) - presentation_layer: StringProperty(name="Presentation Layer") + is_parametric: BoolProperty(name="Is Parametric", default=False) + presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer) geometry_type: StringProperty(name="Geometry Type") ifc_definition: StringProperty(name="IFC Definition") ifc_definition_id: IntProperty(name="IFC Definition ID") ifc_parameters: CollectionProperty(name="IFC Parameters", type=IfcParameter) - active_representation_item_index: IntProperty(name='Active Representation Item Index') + active_representation_item_index: IntProperty(name="Active Representation Item Index") diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index dfca8e7705..ccd4dd2be9 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -647,7 +647,10 @@ class BIM_PT_mesh(Panel): row.operator("bim.update_ifc_representation", icon="FILE_REFRESH", text="").index = index row = layout.row() - row.prop(props, "presentation_layer") + row.prop(props.presentation_layer, "name") + row.prop(props.presentation_layer, "description") + row.prop(props.presentation_layer, "identifier") + row.prop(props.presentation_layer, "layer_on") row = layout.row() row.prop(props, "is_parametric") diff --git a/test/input b/test/input index 828994fa4c..a75c92451c 160000 --- a/test/input +++ b/test/input @@ -1 +1 @@ -Subproject commit 828994fa4c7f28c6afd3f70a9ee9f07710482f8e +Subproject commit a75c92451c8e5b63641b57ed8216849b0121d33d From ae25d97307e1246a9d13833b1fe1a3388bb17231 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Tue, 3 Nov 2020 15:55:08 +0100 Subject: [PATCH 04/15] minor change [skip ci] --- .../blenderbim/bim/data/process.log | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/ifcblenderexport/blenderbim/bim/data/process.log diff --git a/src/ifcblenderexport/blenderbim/bim/data/process.log b/src/ifcblenderexport/blenderbim/bim/data/process.log deleted file mode 100644 index ce1ce1e1cd..0000000000 --- a/src/ifcblenderexport/blenderbim/bim/data/process.log +++ /dev/null @@ -1,71 +0,0 @@ -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Creating object #20=IfcProject('3UJCj26s8HwxY$cAzbL1eO',#5,'MyLayersProject',$,$,$,$,(#11),#19) -INFO:ImportIFC:Creating object #29=IfcSite('3U8zIK6s8HwvkacAzbL1eO',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) -INFO:ImportIFC:Creating object #96=IfcBuilding('3U9f4w6s8Hww4PcAzbL1eO',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) -INFO:ImportIFC:Creating object #89=IfcBeamType('3UK2QY6s8HwwC4cAzbL1eO',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) -INFO:ImportIFC:Creating object #113=IfcBeam('3U9wAe6s8HwxBEcAzbL1eO',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) -INFO:ImportIFC:Creating object #140=IfcPlate('3UA0KC6s8Hww2NcAzbL1eO',#5,'Web1','Web1',$,#124,#139,$,$) -INFO:ImportIFC:Creating object #161=IfcPlate('3UAJrs6s8HwvWrcAzbL1eO',#5,'Web2','Web2',$,#145,#160,$,$) -INFO:ImportIFC:Creating object #182=IfcPlate('3UAOk86s8Hwxy4cAzbL1eO',#5,'Fla1','Fla1',$,#166,#181,$,$) -INFO:ImportIFC:Creating object #203=IfcPlate('3UATfS6s8HwxrxcAzbL1eO',#5,'Fla2','Fla2',$,#187,#202,$,$) -INFO:ImportIFC:Import finished in 0.06 seconds -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) -INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) -INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) -INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) -INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) -INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) -INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) -INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) -INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) -INFO:ImportIFC:Import finished in 0.07 seconds -INFO:ExportIFC:Starting export -INFO:ExportIFC:Export finished in 0.05 seconds -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) -INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) -INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) -INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) -INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) -INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) -INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) -INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) -INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) -INFO:ImportIFC:Import finished in 0.04 seconds -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) -INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) -INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) -INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) -INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) -INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) -INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) -INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) -INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) -INFO:ImportIFC:Import finished in 0.04 seconds -INFO:ImportIFC:Starting import -INFO:ImportIFC:loading file C:\Temp\ifc_files\MyLayerTest.ifc -INFO:ImportIFC:Creating object #20=IfcProject('0vsj5v738Hwv$Tw2f4ZOUQ',#5,'MyLayersProject',$,$,$,$,(#11),#19) -INFO:ImportIFC:Creating object #29=IfcSite('0vePem738HwvrHw2f4ZOUQ',#5,'MySite',$,$,#28,$,$,.ELEMENT.,$,$,$,$,$) -INFO:ImportIFC:Creating object #96=IfcBuilding('0ve$o7738Hww36w2f4ZOUQ',#5,'MyBldg',$,$,#95,$,$,.ELEMENT.,$,$,$) -INFO:ImportIFC:Creating object #89=IfcBeamType('0vuVaV738HwuIfw2f4ZOUQ',#5,'BG300x200x10x20','BG300x200x10x20',$,$,$,$,$,.BEAM.) -INFO:ImportIFC:Creating object #113=IfcBeam('0vgC5T738Hwwy1w2f4ZOUQ',#5,'MyBeam','BG300x200x10x20','Beam',#109,#112,'MyBeam',$) -INFO:ImportIFC:Creating object #140=IfcPlate('0vgoEG738Hwx97w2f4ZOUQ',#5,'Web1','Web1',$,#124,#139,$,$) -INFO:ImportIFC:Creating object #161=IfcPlate('0vhONr738Hwubhw2f4ZOUQ',#5,'Web2','Web2',$,#145,#160,$,$) -INFO:ImportIFC:Creating object #182=IfcPlate('0vh_X3738HwvTFw2f4ZOUQ',#5,'Fla1','Fla1',$,#166,#181,$,$) -INFO:ImportIFC:Creating object #203=IfcPlate('0viafN738Hwuj8w2f4ZOUQ',#5,'Fla2','Fla2',$,#187,#202,$,$) -INFO:ImportIFC:Import finished in 0.04 seconds -INFO:ExportIFC:Starting export From aed4706e4c93150c6cba75cd36e6ccf9776133a8 Mon Sep 17 00:00:00 2001 From: ofskrand Date: Wed, 4 Nov 2020 08:52:20 +0100 Subject: [PATCH 05/15] updated ui with Presentation Layer --- .../blenderbim/bim/__init__.py | 1 + src/ifcblenderexport/blenderbim/bim/ui.py | 37 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 0c05eb6154..1296a667b1 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -278,6 +278,7 @@ if bpy is not None: ui.BIM_PT_debug, ui.BIM_PT_material, ui.BIM_PT_mesh, + ui.BIM_PT_presentation, ui.BIM_PT_object, ui.BIM_PT_object_psets, ui.BIM_PT_object_qto, diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 57f834eaac..c3536cb59e 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -650,12 +650,6 @@ class BIM_PT_mesh(Panel): row.prop(ifc_parameter, "value", text="") row.operator("bim.update_ifc_representation", icon="FILE_REFRESH", text="").index = index - row = layout.row() - row.prop(props.presentation_layer, "name") - row.prop(props.presentation_layer, "description") - row.prop(props.presentation_layer, "identifier") - row.prop(props.presentation_layer, "layer_on") - row = layout.row() row.prop(props, "is_parametric") row = layout.row() @@ -683,6 +677,37 @@ class BIM_PT_mesh(Panel): row.prop(props, "swept_solids") +class BIM_PT_presentation(Panel): + bl_label = "IFC Presentation Layers" + bl_idname = "BIM_PT_presentation" + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "data" + + @classmethod + def poll(cls, context): + return ( + context.active_object is not None + and context.active_object.type == "MESH" + and hasattr(context.active_object.data, "BIMMeshProperties") + ) + + def draw(self, context): + if not context.active_object.data: + return + layout = self.layout + props = context.active_object.data.BIMMeshProperties + + row = layout.row(align=True) + row.prop(props.presentation_layer, "name") + row = layout.row() + row.prop(props.presentation_layer, "description") + row = layout.row() + row.prop(props.presentation_layer, "identifier") + row = layout.row() + row.prop(props.presentation_layer, "layer_on") + + class BIM_PT_material(Panel): bl_label = "IFC Materials" bl_idname = "BIM_PT_material" From 9560211307710956a6e8987417636a0d9660b6d7 Mon Sep 17 00:00:00 2001 From: ofskrand Date: Thu, 5 Nov 2020 07:57:24 +0100 Subject: [PATCH 06/15] debugging collection property --- src/ifcblenderexport/blenderbim/bim/prop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 8d30d61d18..86f3793401 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1527,8 +1527,8 @@ class BIMProperties(PropertyGroup): override_colour: FloatVectorProperty( name="Override Colour", subtype="COLOR", default=(1, 0, 0, 1), min=0.0, max=1.0, size=4 ) + presentation_layers: CollectionProperty(name="Presentation Layers", type=PresentationLayer) - # presentation_layer: CollectionProperty(name="Presentation Layers", type=PresentationLayer) class BCFProperties(PropertyGroup): From 5009371e0f5b8dc995b5c926430a940f89697121 Mon Sep 17 00:00:00 2001 From: ofskrand Date: Thu, 5 Nov 2020 13:54:20 +0100 Subject: [PATCH 07/15] Ran into error when attempting to append EnumProperty. How is that done? --- .../blenderbim/bim/__init__.py | 9 +- .../blenderbim/bim/operator.py | 159 ++++++++++++------ src/ifcblenderexport/blenderbim/bim/prop.py | 2 + src/ifcblenderexport/blenderbim/bim/ui.py | 115 ++++++++++--- 4 files changed, 207 insertions(+), 78 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 96b8bf7bbd..ef9e00d2ff 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -199,6 +199,9 @@ if bpy is not None: operator.SetViewportShadowFromSun, operator.SetNorthOffset, operator.GetNorthOffset, + operator.AddPresentationLayer, + operator.AddToPresentationLayer, + operator.RemovePresentationLayer, operator.AddDrawingStyleAttribute, operator.RemoveDrawingStyleAttribute, operator.CopyPropertyToSelection, @@ -235,6 +238,7 @@ if bpy is not None: prop.BcfTopicDocumentReference, prop.BcfTopicRelatedTopic, prop.Subcontext, + prop.PresentationLayer, prop.BIMProperties, prop.BIMDebugProperties, prop.BCFProperties, @@ -245,7 +249,6 @@ if bpy is not None: prop.Attribute, prop.IfcParameter, prop.BoundaryCondition, - prop.PresentationLayer, prop.PsetQto, prop.GlobalId, prop.RepresentationItem, @@ -275,6 +278,7 @@ if bpy is not None: ui.BIM_PT_qa, ui.BIM_PT_library, ui.BIM_PT_gis, + ui.BIM_PT_presentation_layers, ui.BIM_PT_diff, ui.BIM_PT_cobie, ui.BIM_PT_patch, @@ -282,7 +286,7 @@ if bpy is not None: ui.BIM_PT_debug, ui.BIM_PT_material, ui.BIM_PT_mesh, - ui.BIM_PT_presentation, + ui.BIM_PT_presentation_layer_data, ui.BIM_PT_object, ui.BIM_PT_object_material, ui.BIM_PT_object_psets, @@ -301,6 +305,7 @@ if bpy is not None: ui.BIM_UL_generic, ui.BIM_UL_clash_sets, ui.BIM_UL_constraints, + ui.BIM_UL_presentation_layers, ui.BIM_UL_document_information, ui.BIM_UL_document_references, ui.BIM_UL_topics, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index c4d60a6711..a35953fa27 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -55,8 +55,8 @@ def set_active_camera_resolution(scene): if not scene.camera or "/" not in scene.camera.name or not scene.DocProperties.drawings: return if ( - scene.render.resolution_x != scene.camera.data.BIMCameraProperties.raster_x - or scene.render.resolution_y != scene.camera.data.BIMCameraProperties.raster_y + scene.render.resolution_x != scene.camera.data.BIMCameraProperties.raster_x + or scene.render.resolution_y != scene.camera.data.BIMCameraProperties.raster_y ): scene.render.resolution_x = scene.camera.data.BIMCameraProperties.raster_x scene.render.resolution_y = scene.camera.data.BIMCameraProperties.raster_y @@ -145,8 +145,9 @@ class SelectGlobalId(bpy.types.Operator): for obj in bpy.context.visible_objects: index = obj.BIMObjectProperties.attributes.find("GlobalId") if ( - index != -1 - and obj.BIMObjectProperties.attributes[index].string_value == bpy.context.scene.BIMProperties.global_id + index != -1 + and obj.BIMObjectProperties.attributes[ + index].string_value == bpy.context.scene.BIMProperties.global_id ): obj.select_set(True) break @@ -167,9 +168,9 @@ class SelectAttribute(bpy.types.Operator): continue value = object.BIMObjectProperties.attributes[index].string_value if ( - bpy.context.scene.BIMProperties.search_regex - and bpy.context.scene.BIMProperties.search_ignorecase - and re.search(search_value, value, flags=re.IGNORECASE) + bpy.context.scene.BIMProperties.search_regex + and bpy.context.scene.BIMProperties.search_ignorecase + and re.search(search_value, value, flags=re.IGNORECASE) ): object.select_set(True) elif bpy.context.scene.BIMProperties.search_regex and re.search(search_value, value): @@ -200,9 +201,9 @@ class SelectPset(bpy.types.Operator): continue value = object.BIMObjectProperties.psets[pset_index].properties[prop_index].string_value if ( - bpy.context.scene.BIMProperties.search_regex - and bpy.context.scene.BIMProperties.search_ignorecase - and re.search(search_value, value, flags=re.IGNORECASE) + bpy.context.scene.BIMProperties.search_regex + and bpy.context.scene.BIMProperties.search_ignorecase + and re.search(search_value, value, flags=re.IGNORECASE) ): object.select_set(True) elif bpy.context.scene.BIMProperties.search_regex and re.search(search_value, value): @@ -301,9 +302,9 @@ class SelectClass(bpy.types.Operator): def execute(self, context): for object in bpy.context.visible_objects: if ( - "/" in object.name - and object.name[0:3] == "Ifc" - and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class + "/" in object.name + and object.name[0:3] == "Ifc" + and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class ): object.select_set(True) return {"FINISHED"} @@ -316,19 +317,19 @@ class SelectType(bpy.types.Operator): def execute(self, context): for object in bpy.context.visible_objects: if ( - "/" in object.name - and object.name[0:3] == "Ifc" - and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class - and "PredefinedType" in object.BIMObjectProperties.attributes - and object.BIMObjectProperties.attributes["PredefinedType"].string_value - == bpy.context.scene.BIMProperties.ifc_predefined_type + "/" in object.name + and object.name[0:3] == "Ifc" + and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class + and "PredefinedType" in object.BIMObjectProperties.attributes + and object.BIMObjectProperties.attributes["PredefinedType"].string_value + == bpy.context.scene.BIMProperties.ifc_predefined_type ): if bpy.context.scene.BIMProperties.ifc_predefined_type != "USERDEFINED": object.select_set(True) elif ( - "ObjectType" in object.BIMObjectProperties.attributes - and object.BIMObjectProperties.attributes["ObjectType"].string_value - == bpy.context.scene.BIMProperties.ifc_userdefined_type + "ObjectType" in object.BIMObjectProperties.attributes + and object.BIMObjectProperties.attributes["ObjectType"].string_value + == bpy.context.scene.BIMProperties.ifc_userdefined_type ): object.select_set(True) return {"FINISHED"} @@ -423,8 +424,8 @@ class QAHelper: is_in_scenario = False for source_line in source: if ( - "Scenario: " in source_line - and bpy.context.scene.BIMProperties.scenario == source_line.strip()[len("Scenario: ") :] + "Scenario: " in source_line + and bpy.context.scene.BIMProperties.scenario == source_line.strip()[len("Scenario: "):] ): is_in_scenario = True elif is_in_scenario: @@ -715,7 +716,7 @@ class ActivateBcfViewpoint(bpy.types.Operator): def hex_to_rgb(self, value): value = value.lstrip("#") lv = len(value) - t = tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3)) + t = tuple(int(value[i: i + lv // 3], 16) for i in range(0, lv, lv // 3)) return [t[0] / 255.0, t[1] / 255.0, t[2] / 255.0, 1] @@ -2394,12 +2395,12 @@ class CutSection(bpy.types.Operator): obj.hide_set(True) for obj in bpy.context.visible_objects: if ( - not obj.data - or isinstance(obj.data, bpy.types.Camera) - or "IfcGrid/" in obj.name - or "IfcGridAxis/" in obj.name - or "IfcOpeningElement/" in obj.name - or self.does_obj_have_target_view_representation(obj, camera) + not obj.data + or isinstance(obj.data, bpy.types.Camera) + or "IfcGrid/" in obj.name + or "IfcGridAxis/" in obj.name + or "IfcOpeningElement/" in obj.name + or self.does_obj_have_target_view_representation(obj, camera) ): previous_visibility[obj.name] = obj.hide_get() obj.hide_set(True) @@ -2544,8 +2545,8 @@ class ActivateView(bpy.types.Operator): # We assume a convention that the 'Views' collection is directly # in the project collection if ( - "Views" in project_collection.children - and collection.name in project_collection.children["Views"].children + "Views" in project_collection.children + and collection.name in project_collection.children["Views"].children ): project_collection.children["Views"].children[collection.name].hide_viewport = True bpy.data.collections.get(collection.name).hide_render = True @@ -2604,9 +2605,9 @@ class SwitchContext(bpy.types.Operator): has_context = False for context in self.obj.BIMObjectProperties.representation_contexts: if ( - context.context == self.context - and context.name == self.subcontext - and context.target_view == self.target_view + context.context == self.context + and context.name == self.subcontext + and context.target_view == self.target_view ): has_context = True break @@ -2633,16 +2634,16 @@ class SwitchContext(bpy.types.Operator): for rep in element.Representation.Representations: if ( - rep.ContextOfItems.is_a("IfcGeometricRepresentationSubContext") - and rep.ContextOfItems.ContextType == self.context - and rep.ContextOfItems.ContextIdentifier == self.subcontext - and rep.ContextOfItems.TargetView == self.target_view + rep.ContextOfItems.is_a("IfcGeometricRepresentationSubContext") + and rep.ContextOfItems.ContextType == self.context + and rep.ContextOfItems.ContextIdentifier == self.subcontext + and rep.ContextOfItems.TargetView == self.target_view ): break elif ( - rep.ContextOfItems.is_a("IfcGeometricRepresentationContext") - and rep.ContextOfItems.ContextType == self.context - and rep.ContextOfItems.ContextIdentifier == self.subcontext + rep.ContextOfItems.is_a("IfcGeometricRepresentationContext") + and rep.ContextOfItems.ContextType == self.context + and rep.ContextOfItems.ContextIdentifier == self.subcontext ): break @@ -2977,7 +2978,8 @@ class AddSectionPlane(bpy.types.Operator): section.show_in_front = True if bpy.context.active_object.select_get() and isinstance(bpy.context.active_object.data, bpy.types.Camera): section.matrix_world = ( - bpy.context.active_object.matrix_world @ Euler((radians(180.0), 0.0, 0.0), "XYZ").to_matrix().to_4x4() + bpy.context.active_object.matrix_world @ Euler((radians(180.0), 0.0, 0.0), + "XYZ").to_matrix().to_4x4() ) else: section.rotation_euler = Euler((radians(180.0), 0.0, 0.0), "XYZ") @@ -3394,12 +3396,12 @@ class GenerateReferences(bpy.types.Operator): if self.camera.data.BIMCameraProperties.raster_x > self.camera.data.BIMCameraProperties.raster_y: width = self.camera.data.ortho_scale height = ( - width / self.camera.data.BIMCameraProperties.raster_x * self.camera.data.BIMCameraProperties.raster_y + width / self.camera.data.BIMCameraProperties.raster_x * self.camera.data.BIMCameraProperties.raster_y ) else: height = self.camera.data.ortho_scale width = ( - height / self.camera.data.BIMCameraProperties.raster_y * self.camera.data.BIMCameraProperties.raster_x + height / self.camera.data.BIMCameraProperties.raster_y * self.camera.data.BIMCameraProperties.raster_x ) level_obj = annotation.Annotator.get_annotation_obj("Section Level", "curve") @@ -3585,9 +3587,9 @@ class PushRepresentation(bpy.types.Operator): def is_current_context(self, element): return ( - element.ContextType == self.context - and element.ContextIdentifier == self.subcontext - and element.TargetView == self.target_view + element.ContextType == self.context + and element.ContextIdentifier == self.subcontext + and element.TargetView == self.target_view ) @@ -3678,7 +3680,7 @@ class GuessQuantity(bpy.types.Operator): elif bpy.context.scene.unit_settings.system == "METRIC": if bpy.context.scene.unit_settings.length_unit == "METERS": return None, "METRE" - return bpy.context.scene.unit_settings.length_unit[0 : -len("METERS")], "METRE" + return bpy.context.scene.unit_settings.length_unit[0: -len("METERS")], "METRE" class ExecuteBIMTester(bpy.types.Operator): @@ -3909,7 +3911,7 @@ class ActivateDrawingStyle(bpy.types.Operator): def execute(self, context): if context.scene.camera.data.BIMCameraProperties.active_drawing_style_index < len( - bpy.context.scene.DocProperties.drawing_styles + bpy.context.scene.DocProperties.drawing_styles ): self.drawing_style = bpy.context.scene.DocProperties.drawing_styles[ context.scene.camera.data.BIMCameraProperties.active_drawing_style_index @@ -4187,7 +4189,7 @@ class SetViewportShadowFromSun(bpy.types.Operator): # The vector used for the light direction is a bit funny mat = Matrix(((-1.0, 0.0, 0.0, 0.0), (0.0, 0, 1.0, 0.0), (-0.0, -1.0, 0, 0.0), (0.0, 0.0, 0.0, 1.0))) context.scene.display.light_direction = mat.inverted() @ ( - context.active_object.matrix_world.to_quaternion() @ Vector((0, 0, -1)) + context.active_object.matrix_world.to_quaternion() @ Vector((0, 0, -1)) ) return {"FINISHED"} @@ -4217,6 +4219,57 @@ class GetNorthOffset(bpy.types.Operator): return {"FINISHED"} +class AddToPresentationLayer(bpy.types.Operator): + bl_idname = "bim.add_to_presentation_layer" + bl_label = "Add To Presentation Layer" + index: bpy.props.IntProperty() + guid: bpy.props.StringProperty() + + def execute(self, context): + presentation_layers = bpy.context.scene.BIMProperties.presentation_layers + new = presentation_layers[self.index] + new.assigned_items.items.append(self.guid) + + return {"FINISHED"} + + +class AddPresentationLayer(bpy.types.Operator): + bl_idname = "bim.add_presentation_layer" + bl_label = "Add Presentation Layer" + + _name = 'New Presentation Layer' + descript = 'A Description' + identifier = 'Something' + assigned_items = bpy.props.EnumProperty(items=[]) + layer_on = True + layer_frozen = False + layer_blocked = False + layer_styles = bpy.props.EnumProperty(items=[]) + + def execute(self, context): + new = bpy.context.scene.BIMProperties.presentation_layers.add() + new.name = self._name + new.description = self.descript + new.identifier = self.identifier + new.layer_on = self.layer_on + new.layer_frozen = self.layer_frozen + new.layer_blocked = self.layer_blocked + # new.assigned_items = self.assigned_items + # new.layer_styles = self.layer_styles + + return {"FINISHED"} + + +class RemovePresentationLayer(bpy.types.Operator): + bl_idname = "bim.remove_presentation_layer" + bl_label = "Remove Presentation Layer" + index: bpy.props.IntProperty() + + def execute(self, context): + bpy.context.scene.BIMProperties.presentation_layers.remove(self.index) + return {"FINISHED"} + + class AddDrawingStyleAttribute(bpy.types.Operator): bl_idname = "bim.add_drawing_style_attribute" bl_label = "Add Drawing Style Attribute" @@ -4266,7 +4319,7 @@ class SelectHighPolygonMeshes(bpy.types.Operator): results = {} for obj in bpy.data.objects: if not isinstance(obj.data, bpy.types.Mesh) or len(obj.data.polygons) < int( - bpy.context.scene.BIMDebugProperties.number_of_polygons + bpy.context.scene.BIMDebugProperties.number_of_polygons ): continue try: diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 7b3740b069..a61c1ac813 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1555,6 +1555,7 @@ class BIMProperties(PropertyGroup): override_colour: FloatVectorProperty( name="Override Colour", subtype="COLOR", default=(1, 0, 0, 1), min=0.0, max=1.0, size=4 ) + active_presentation_layer_index: IntProperty(name="Active Presentation Layer Index") presentation_layers: CollectionProperty(name="Presentation Layers", type=PresentationLayer) @@ -1671,6 +1672,7 @@ class BIMObjectProperties(PropertyGroup): qto_name: EnumProperty(items=getQtoNames, name="Qto Name") has_boundary_condition: BoolProperty(name="Has Boundary Condition") boundary_condition: PointerProperty(name="Boundary Condition", type=BoundaryCondition) + active_presentation_layer_index: IntProperty(name="Active Presentation Layer Index") presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer) structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object) representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 7253ce1e6a..fe452b55ad 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -219,11 +219,11 @@ class BIM_PT_object_qto(Panel): row.prop(prop, "name", text="") row.prop(prop, "string_value", text="") if ( - "length" in prop.name.lower() - or "width" in prop.name.lower() - or "height" in prop.name.lower() - or "depth" in prop.name.lower() - or "perimeter" in prop.name.lower() + "length" in prop.name.lower() + or "width" in prop.name.lower() + or "height" in prop.name.lower() + or "depth" in prop.name.lower() + or "perimeter" in prop.name.lower() ): op = row.operator("bim.guess_quantity", icon="IPO_EASE_IN_OUT", text="") op.qto_index = index @@ -670,9 +670,9 @@ class BIM_PT_mesh(Panel): @classmethod def poll(cls, context): return ( - context.active_object is not None - and context.active_object.type == "MESH" - and hasattr(context.active_object.data, "BIMMeshProperties") + context.active_object is not None + and context.active_object.type == "MESH" + and hasattr(context.active_object.data, "BIMMeshProperties") ) def draw(self, context): @@ -726,7 +726,7 @@ class BIM_PT_mesh(Panel): row.prop(props, "swept_solids") -class BIM_PT_presentation(Panel): +class BIM_PT_presentation_layer_data(Panel): bl_label = "IFC Presentation Layers" bl_idname = "BIM_PT_presentation" bl_space_type = "PROPERTIES" @@ -736,25 +736,39 @@ class BIM_PT_presentation(Panel): @classmethod def poll(cls, context): return ( - context.active_object is not None - and context.active_object.type == "MESH" - and hasattr(context.active_object.data, "BIMMeshProperties") + context.active_object is not None + and context.active_object.type == "MESH" + and hasattr(context.active_object.data, "BIMMeshProperties") ) def draw(self, context): if not context.active_object.data: return layout = self.layout - props = context.active_object.data.BIMMeshProperties + curr_props = context.active_object.data.BIMMeshProperties.presentation_layer - row = layout.row(align=True) - row.prop(props.presentation_layer, "name") - row = layout.row() - row.prop(props.presentation_layer, "description") - row = layout.row() - row.prop(props.presentation_layer, "identifier") - row = layout.row() - row.prop(props.presentation_layer, "layer_on") + # if len(curr_props.values()) > 0: + + layout.row(align=True).prop(curr_props, "name") + layout.row().prop(curr_props, "description") + layout.row().prop(curr_props, "identifier") + layout.row().prop(curr_props, "layer_on") + layout.row().prop(curr_props, "layer_frozen") + layout.row().prop(curr_props, "layer_blocked") + layout.row().prop(curr_props, "layer_styles") + + props = context.scene.BIMProperties + cur_elem = bpy.context.active_object.BIMObjectProperties + if props.presentation_layers: + layout.template_list("BIM_UL_presentation_layers", "", props, "presentation_layers", props, + "active_presentation_layer_index") + pres_layer = props.presentation_layers[props.active_presentation_layer_index] + if pres_layer.name in bpy.context.scene.BIMProperties.presentation_layers: + op = layout.row().operator("bim.add_to_presentation_layer") + op.index = props.active_presentation_layer_index + op.guid = cur_elem.attributes['GlobalId'].string_value + else: + layout.label(text="Presentation Layer is invalid") class BIM_PT_material(Panel): @@ -873,6 +887,52 @@ class BIM_PT_gis(Panel): row.operator("bim.set_north_offset") +class BIM_PT_presentation_layers(Panel): + bl_label = "IFC Presentation Layers" + bl_idname = "BIM_PT_presentation_layer" + bl_options = {"DEFAULT_CLOSED"} + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "scene" + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + props = context.scene.BIMProperties + + layout.row().prop(props, "presentation_layers") + layout.row().operator("bim.add_presentation_layer") + + if props.presentation_layers: + layout.template_list("BIM_UL_presentation_layers", "", props, "presentation_layers", props, + "active_presentation_layer_index") + pres_layer = props.presentation_layers[props.active_presentation_layer_index] + + row = layout.row(align=True) + row.prop(pres_layer, "name") + if pres_layer.name in bpy.context.scene.BIMProperties.presentation_layers: + pres_layer = bpy.context.scene.BIMProperties.presentation_layers[pres_layer.name] + row.operator( + "bim.remove_presentation_layer", icon="X", text="" + ).index = props.active_presentation_layer_index + row = layout.row() + row.prop(pres_layer, "description") + row = layout.row() + row.prop(pres_layer, "assigned_items") + row = layout.row() + row.prop(pres_layer, "identifier") + row = layout.row() + row.prop(pres_layer, "layer_on") + row = layout.row() + row.prop(pres_layer, "layer_frozen") + row = layout.row() + row.prop(pres_layer, "layer_blocked") + row = layout.row() + row.prop(pres_layer, "layer_styles") + else: + layout.label(text="Presentation Layer is invalid") + + class BIM_PT_drawings(Panel): bl_label = "SVG Drawings" bl_idname = "BIM_PT_drawings" @@ -1576,7 +1636,7 @@ class BIM_PT_bcf(Panel): layout.label(text="Document References:") for index, doc in enumerate(props.topic_document_references): row = layout.row(align=True) - row.prop(doc, "name", text=f"File {index+1} URI") + row.prop(doc, "name", text=f"File {index + 1} URI") if doc.is_external: row.operator("bim.open_bcf_document_reference", icon="URL", text="").data = "{}/{}".format( props.topic_guid, index @@ -1586,7 +1646,7 @@ class BIM_PT_bcf(Panel): props.topic_guid, index ) row = layout.row(align=True) - row.prop(doc, "description", text=f"File {index+1} Description:") + row.prop(doc, "description", text=f"File {index + 1} Description:") layout.label(text="Related Topics:") for topic in props.topic_related_topics: @@ -1933,6 +1993,15 @@ class BIM_UL_constraints(bpy.types.UIList): layout.label(text="", translate=False) +class BIM_UL_presentation_layers(bpy.types.UIList): + def draw_item(self, context, layout, data, item, icon, active_data, active_propname): + ob = data + if item: + layout.prop(item, "name", text="", emboss=False) + else: + layout.label(text="", translate=False) + + class BIM_UL_document_information(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): ob = data From 87e25cc597febdc366abf8d204b7ab62bd8df156 Mon Sep 17 00:00:00 2001 From: ofskrand Date: Thu, 5 Nov 2020 16:32:49 +0100 Subject: [PATCH 08/15] Attempt to simplifying assigned items pointer. Stuck on read only --- src/ifcblenderexport/blenderbim/bim/operator.py | 10 ++-------- src/ifcblenderexport/blenderbim/bim/prop.py | 1 - src/ifcblenderexport/blenderbim/bim/ui.py | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index a35953fa27..e1a8fe02c4 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -4226,10 +4226,8 @@ class AddToPresentationLayer(bpy.types.Operator): guid: bpy.props.StringProperty() def execute(self, context): - presentation_layers = bpy.context.scene.BIMProperties.presentation_layers - new = presentation_layers[self.index] - new.assigned_items.items.append(self.guid) - + bpy.context.active_object.BIMObjectProperties.presentation_layer = \ + bpy.context.scene.BIMProperties.presentation_layers[self.index] return {"FINISHED"} @@ -4240,11 +4238,9 @@ class AddPresentationLayer(bpy.types.Operator): _name = 'New Presentation Layer' descript = 'A Description' identifier = 'Something' - assigned_items = bpy.props.EnumProperty(items=[]) layer_on = True layer_frozen = False layer_blocked = False - layer_styles = bpy.props.EnumProperty(items=[]) def execute(self, context): new = bpy.context.scene.BIMProperties.presentation_layers.add() @@ -4254,8 +4250,6 @@ class AddPresentationLayer(bpy.types.Operator): new.layer_on = self.layer_on new.layer_frozen = self.layer_frozen new.layer_blocked = self.layer_blocked - # new.assigned_items = self.assigned_items - # new.layer_styles = self.layer_styles return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index a61c1ac813..1c204019b7 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -779,7 +779,6 @@ class ClashSet(PropertyGroup): class PresentationLayer(PropertyGroup): name: StringProperty(name="Name") description: StringProperty(name="Description") - assigned_items: EnumProperty(items=[], name="AssignedItems") identifier: StringProperty(name="Identifier") layer_on: BoolProperty(name="LayerOn", default=True) layer_frozen: BoolProperty(name="LayerFrozen") diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index fe452b55ad..c3b42c756a 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -917,8 +917,8 @@ class BIM_PT_presentation_layers(Panel): ).index = props.active_presentation_layer_index row = layout.row() row.prop(pres_layer, "description") - row = layout.row() - row.prop(pres_layer, "assigned_items") + # row = layout.row() + # row.prop(pres_layer, "assigned_items") row = layout.row() row.prop(pres_layer, "identifier") row = layout.row() From 9a385c2118c5970f3d46a771375e3745c5f4be13 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Fri, 6 Nov 2020 16:53:42 +0100 Subject: [PATCH 09/15] minor improvements --- .../blenderbim/bim/export_ifc.py | 72 ++++++++++--------- .../blenderbim/bim/operator.py | 8 ++- src/ifcblenderexport/blenderbim/bim/ui.py | 33 +++++---- 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/export_ifc.py b/src/ifcblenderexport/blenderbim/bim/export_ifc.py index 98a6d8d94a..e6086060a3 100644 --- a/src/ifcblenderexport/blenderbim/bim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/export_ifc.py @@ -404,7 +404,7 @@ class IfcParser: ) if obj.instance_type == "COLLECTION" and self.is_a_rel_aggregates( - self.get_ifc_class(obj.instance_collection.name) + self.get_ifc_class(obj.instance_collection.name) ): self.rel_aggregates[self.product_index] = obj.name @@ -434,7 +434,7 @@ class IfcParser: elif obj.BIMObjectProperties.material_type == "IfcMaterialLayerSet": self.rel_associates_material_layer_set[self.product_index] = obj.BIMObjectProperties.material_set elif obj.BIMObjectProperties.material_type == "IfcMaterialProfileSet": - pass # TODO + pass # TODO return product @@ -980,7 +980,11 @@ class IfcParser: def load_presentation_layer_assignments(self): for representation in self.representations.values(): if representation["presentation_layer"]: - self.presentation_layer_assignments.setdefault(representation["presentation_layer"], []).append( + pl = representation["presentation_layer"] + print('Presentation load: ', pl.name) + defaults = [[], pl.description, pl.identifier, pl.layer_on, pl.layer_frozen, pl.layer_blocked, + pl.layer_styles] + self.presentation_layer_assignments.setdefault(pl.name, defaults)[0].append( representation ) @@ -999,9 +1003,9 @@ class IfcParser: def prevent_data_name_duplicates(self, product): if ( - product["raw"].data - and bpy.data.meshes.get(product["raw"].data.name) - and bpy.data.curves.get(product["raw"].data.name) + product["raw"].data + and bpy.data.meshes.get(product["raw"].data.name) + and bpy.data.curves.get(product["raw"].data.name) ): product["raw"].data.name += "~" @@ -1074,7 +1078,8 @@ class IfcParser: "Model/Box/MODEL_VIEW/{}".format(mesh_name.split("/")[3]) ] = self.get_representation(obj.data, obj, "Model", "Box", "MODEL_VIEW") elif ( - context_prefix == "Model/Body/MODEL_VIEW" and obj.data and not self.is_mesh_context_sensitive(obj.data.name) + context_prefix == "Model/Body/MODEL_VIEW" and obj.data and not self.is_mesh_context_sensitive( + obj.data.name) ): self.append_default_representation(obj) elif context_prefix == "Model/Body/MODEL_VIEW" and self.is_point_cloud(obj): @@ -1245,15 +1250,15 @@ class IfcParser: return children for reference, element in enumerate(self.spatial_structure_elements): if ( # A convention is established that spatial elements may be - # an object placed in a collection of the same name - element["raw"].name == element["raw"].users_collection[0].name - and element["raw"].users_collection[0].name - in [c.name for c in bpy.data.collections[parent["raw"].name].children] + # an object placed in a collection of the same name + element["raw"].name == element["raw"].users_collection[0].name + and element["raw"].users_collection[0].name + in [c.name for c in bpy.data.collections[parent["raw"].name].children] ) or ( # We allow finer grain spatial elements such as IfcSpace to - # break the convention to prevent collection overload in Blender - element["raw"].name != element["raw"].users_collection[0].name - and element["raw"].users_collection[0].name - in [o.name for o in bpy.data.collections[parent["raw"].name].objects] + # break the convention to prevent collection overload in Blender + element["raw"].name != element["raw"].users_collection[0].name + and element["raw"].users_collection[0].name + in [o.name for o in bpy.data.collections[parent["raw"].name].objects] ): children.append({"reference": reference, "children": self.get_spatial_structure_elements_tree(element)}) return children @@ -1311,7 +1316,7 @@ class IfcParser: def is_a_type(self, class_name): return (class_name[0:3] == "Ifc" and class_name[-4:] == "Type") or ( - class_name[0:3] == "Ifc" and class_name[-5:] == "Style" + class_name[0:3] == "Ifc" and class_name[-5:] == "Style" ) @@ -1388,10 +1393,10 @@ class IfcExporter: self.file.wrapped_data.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file) self.file.wrapped_data.header.file_name.time_stamp = ( datetime.datetime.utcnow() - .replace(tzinfo=datetime.timezone.utc) - .astimezone() - .replace(microsecond=0) - .isoformat() + .replace(tzinfo=datetime.timezone.utc) + .astimezone() + .replace(microsecond=0) + .isoformat() ) self.file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version) self.file.wrapped_data.header.file_name.originating_system = "{} {}".format( @@ -1415,10 +1420,10 @@ class IfcExporter: [ str(x) for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] + addon.bl_info.get("version", (-1, -1, -1)) + for addon in addon_utils.modules() + if addon.bl_info["name"] == "BlenderBIM" + ][0] ] ) @@ -1613,8 +1618,8 @@ class IfcExporter: def create_document_references(self): for reference in self.ifc_parser.document_references.values(): if ( - reference["referenced_document"] - and reference["referenced_document"] in self.ifc_parser.document_information + reference["referenced_document"] + and reference["referenced_document"] in self.ifc_parser.document_information ): reference["attributes"]["ReferencedDocument"] = self.ifc_parser.document_information[ reference["referenced_document"] @@ -2023,9 +2028,11 @@ class IfcExporter: return self.file.createIfcStyledItem(representation_item, [surface_style], item["attributes"]["Name"]) def create_presentation_layer_assignments(self): - for name, assigned_items in self.ifc_parser.presentation_layer_assignments.items(): + for name, props in self.ifc_parser.presentation_layer_assignments.items(): + assigned_items, description, identifier, layer_on, layer_frozen, layer_blocked, layer_styles = props + print('Presentation Export: ', name, assigned_items) self.file.createIfcPresentationLayerAssignment( - name, None, [i["ifc"].MappedRepresentation for i in assigned_items], None + name, description, [i["ifc"].MappedRepresentation for i in assigned_items], identifier ) def create_materials(self): @@ -2101,9 +2108,9 @@ class IfcExporter: def get_rendering_attributes(self, material): if ( - not material.use_nodes - or not hasattr(material.node_tree, "nodes") - or "Principled BSDF" not in material.node_tree.nodes + not material.use_nodes + or not hasattr(material.node_tree, "nodes") + or "Principled BSDF" not in material.node_tree.nodes ): return {} bsdf = material.node_tree.nodes["Principled BSDF"] @@ -3330,7 +3337,8 @@ class IfcExporter: tmp_file = os.path.join(unzipped_path, tmp_name) self.file.write(tmp_file) with zipfile.ZipFile( - self.ifc_export_settings.output_file, mode="w", compression=zipfile.ZIP_DEFLATED, compresslevel=9 + self.ifc_export_settings.output_file, mode="w", compression=zipfile.ZIP_DEFLATED, + compresslevel=9 ) as zf: zf.write(tmp_file) elif extension == "ifc": diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index abd3fbbb88..d5c924320b 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -4284,11 +4284,13 @@ class AddToPresentationLayer(bpy.types.Operator): bl_idname = "bim.add_to_presentation_layer" bl_label = "Add To Presentation Layer" index: bpy.props.IntProperty() - guid: bpy.props.StringProperty() def execute(self, context): - bpy.context.active_object.BIMObjectProperties.presentation_layer = \ - bpy.context.scene.BIMProperties.presentation_layers[self.index] + name = bpy.context.scene.BIMProperties.presentation_layers[self.index].name + bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name + + print(f'Adding "{self.index} - {name}" to "{bpy.context.scene.BIMProperties.name}"') + return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index be7f813026..90ddfb31d8 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -785,28 +785,27 @@ class BIM_PT_presentation_layer_data(Panel): if not context.active_object.data: return layout = self.layout - curr_props = context.active_object.data.BIMMeshProperties.presentation_layer + elem_props = context.active_object.data.BIMMeshProperties.presentation_layer + scene_props = context.scene.BIMProperties - # if len(curr_props.values()) > 0: + if elem_props.name != '': + layout.row(align=True).prop(elem_props, "name") + layout.row().prop(elem_props, "description") + layout.row().prop(elem_props, "identifier") + layout.row().prop(elem_props, "layer_on") + layout.row().prop(elem_props, "layer_frozen") + layout.row().prop(elem_props, "layer_blocked") + layout.row().prop(elem_props, "layer_styles") + else: + layout.label(text='Not included in any presentation layer') - layout.row(align=True).prop(curr_props, "name") - layout.row().prop(curr_props, "description") - layout.row().prop(curr_props, "identifier") - layout.row().prop(curr_props, "layer_on") - layout.row().prop(curr_props, "layer_frozen") - layout.row().prop(curr_props, "layer_blocked") - layout.row().prop(curr_props, "layer_styles") - - props = context.scene.BIMProperties - cur_elem = bpy.context.active_object.BIMObjectProperties - if props.presentation_layers: - layout.template_list("BIM_UL_presentation_layers", "", props, "presentation_layers", props, + if scene_props.presentation_layers: + layout.template_list("BIM_UL_presentation_layers", "", scene_props, "presentation_layers", scene_props, "active_presentation_layer_index") - pres_layer = props.presentation_layers[props.active_presentation_layer_index] + pres_layer = scene_props.presentation_layers[scene_props.active_presentation_layer_index] if pres_layer.name in bpy.context.scene.BIMProperties.presentation_layers: op = layout.row().operator("bim.add_to_presentation_layer") - op.index = props.active_presentation_layer_index - op.guid = cur_elem.attributes['GlobalId'].string_value + op.index = scene_props.active_presentation_layer_index else: layout.label(text="Presentation Layer is invalid") From a1cbf9a055df94446bc7dde2e580b69d1abae23c Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Sun, 8 Nov 2020 13:52:20 +0100 Subject: [PATCH 10/15] minor improvements in ui,export and operator --- .../blenderbim/bim/__init__.py | 1 + .../blenderbim/bim/export_ifc.py | 105 ++++++++++-------- .../blenderbim/bim/operator.py | 50 ++++++--- src/ifcblenderexport/blenderbim/bim/prop.py | 4 +- src/ifcblenderexport/blenderbim/bim/ui.py | 26 +++-- 5 files changed, 114 insertions(+), 72 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index b696551ffb..7998d73aaa 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -206,6 +206,7 @@ if bpy is not None: operator.AddPresentationLayer, operator.AddToPresentationLayer, operator.RemovePresentationLayer, + operator.UpdatePresentationLayer, operator.AddDrawingStyleAttribute, operator.RemoveDrawingStyleAttribute, operator.CopyPropertyToSelection, diff --git a/src/ifcblenderexport/blenderbim/bim/export_ifc.py b/src/ifcblenderexport/blenderbim/bim/export_ifc.py index e6086060a3..8ad5f9a3d2 100644 --- a/src/ifcblenderexport/blenderbim/bim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/export_ifc.py @@ -404,7 +404,7 @@ class IfcParser: ) if obj.instance_type == "COLLECTION" and self.is_a_rel_aggregates( - self.get_ifc_class(obj.instance_collection.name) + self.get_ifc_class(obj.instance_collection.name) ): self.rel_aggregates[self.product_index] = obj.name @@ -434,7 +434,7 @@ class IfcParser: elif obj.BIMObjectProperties.material_type == "IfcMaterialLayerSet": self.rel_associates_material_layer_set[self.product_index] = obj.BIMObjectProperties.material_set elif obj.BIMObjectProperties.material_type == "IfcMaterialProfileSet": - pass # TODO + pass # TODO return product @@ -981,12 +981,10 @@ class IfcParser: for representation in self.representations.values(): if representation["presentation_layer"]: pl = representation["presentation_layer"] - print('Presentation load: ', pl.name) - defaults = [[], pl.description, pl.identifier, pl.layer_on, pl.layer_frozen, pl.layer_blocked, - pl.layer_styles] - self.presentation_layer_assignments.setdefault(pl.name, defaults)[0].append( - representation - ) + if pl.name == '': + continue + print("Presentation load: ", pl.name) + self.presentation_layer_assignments.setdefault(pl.name, []).append(representation) def load_representations(self): if not self.ifc_export_settings.has_representations: @@ -1003,9 +1001,9 @@ class IfcParser: def prevent_data_name_duplicates(self, product): if ( - product["raw"].data - and bpy.data.meshes.get(product["raw"].data.name) - and bpy.data.curves.get(product["raw"].data.name) + product["raw"].data + and bpy.data.meshes.get(product["raw"].data.name) + and bpy.data.curves.get(product["raw"].data.name) ): product["raw"].data.name += "~" @@ -1078,8 +1076,7 @@ class IfcParser: "Model/Box/MODEL_VIEW/{}".format(mesh_name.split("/")[3]) ] = self.get_representation(obj.data, obj, "Model", "Box", "MODEL_VIEW") elif ( - context_prefix == "Model/Body/MODEL_VIEW" and obj.data and not self.is_mesh_context_sensitive( - obj.data.name) + context_prefix == "Model/Body/MODEL_VIEW" and obj.data and not self.is_mesh_context_sensitive(obj.data.name) ): self.append_default_representation(obj) elif context_prefix == "Model/Body/MODEL_VIEW" and self.is_point_cloud(obj): @@ -1119,9 +1116,7 @@ class IfcParser: "is_native": mesh.BIMMeshProperties.is_native if hasattr(mesh, "BIMMeshProperties") else False, "is_swept_solid": mesh.BIMMeshProperties.is_swept_solid if hasattr(mesh, "BIMMeshProperties") else False, "is_generated": False, - "presentation_layer": mesh.BIMMeshProperties.presentation_layer - if hasattr(mesh, "BIMMeshProperties") - else None, + "presentation_layer": obj.BIMObjectProperties.presentation_layer if hasattr(obj, "BIMObjectProperties") else None, "attributes": {"Name": mesh.name}, } @@ -1250,15 +1245,15 @@ class IfcParser: return children for reference, element in enumerate(self.spatial_structure_elements): if ( # A convention is established that spatial elements may be - # an object placed in a collection of the same name - element["raw"].name == element["raw"].users_collection[0].name - and element["raw"].users_collection[0].name - in [c.name for c in bpy.data.collections[parent["raw"].name].children] + # an object placed in a collection of the same name + element["raw"].name == element["raw"].users_collection[0].name + and element["raw"].users_collection[0].name + in [c.name for c in bpy.data.collections[parent["raw"].name].children] ) or ( # We allow finer grain spatial elements such as IfcSpace to - # break the convention to prevent collection overload in Blender - element["raw"].name != element["raw"].users_collection[0].name - and element["raw"].users_collection[0].name - in [o.name for o in bpy.data.collections[parent["raw"].name].objects] + # break the convention to prevent collection overload in Blender + element["raw"].name != element["raw"].users_collection[0].name + and element["raw"].users_collection[0].name + in [o.name for o in bpy.data.collections[parent["raw"].name].objects] ): children.append({"reference": reference, "children": self.get_spatial_structure_elements_tree(element)}) return children @@ -1316,7 +1311,7 @@ class IfcParser: def is_a_type(self, class_name): return (class_name[0:3] == "Ifc" and class_name[-4:] == "Type") or ( - class_name[0:3] == "Ifc" and class_name[-5:] == "Style" + class_name[0:3] == "Ifc" and class_name[-5:] == "Style" ) @@ -1393,10 +1388,10 @@ class IfcExporter: self.file.wrapped_data.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file) self.file.wrapped_data.header.file_name.time_stamp = ( datetime.datetime.utcnow() - .replace(tzinfo=datetime.timezone.utc) - .astimezone() - .replace(microsecond=0) - .isoformat() + .replace(tzinfo=datetime.timezone.utc) + .astimezone() + .replace(microsecond=0) + .isoformat() ) self.file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version) self.file.wrapped_data.header.file_name.originating_system = "{} {}".format( @@ -1420,10 +1415,10 @@ class IfcExporter: [ str(x) for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] + addon.bl_info.get("version", (-1, -1, -1)) + for addon in addon_utils.modules() + if addon.bl_info["name"] == "BlenderBIM" + ][0] ] ) @@ -1618,8 +1613,8 @@ class IfcExporter: def create_document_references(self): for reference in self.ifc_parser.document_references.values(): if ( - reference["referenced_document"] - and reference["referenced_document"] in self.ifc_parser.document_information + reference["referenced_document"] + and reference["referenced_document"] in self.ifc_parser.document_information ): reference["attributes"]["ReferencedDocument"] = self.ifc_parser.document_information[ reference["referenced_document"] @@ -2028,12 +2023,26 @@ class IfcExporter: return self.file.createIfcStyledItem(representation_item, [surface_style], item["attributes"]["Name"]) def create_presentation_layer_assignments(self): - for name, props in self.ifc_parser.presentation_layer_assignments.items(): - assigned_items, description, identifier, layer_on, layer_frozen, layer_blocked, layer_styles = props - print('Presentation Export: ', name, assigned_items) - self.file.createIfcPresentationLayerAssignment( - name, description, [i["ifc"].MappedRepresentation for i in assigned_items], identifier - ) + scene_props = bpy.context.scene.BIMProperties + for name, assigned_items in self.ifc_parser.presentation_layer_assignments.items(): + if name == '': + continue + pl = scene_props.presentation_layers[name] + print("Presentation Export: ", name, pl.identifier, pl.layer_on) + + with_style = False + if pl.layer_on is False: + with_style = True + + if with_style is False: + self.file.createIfcPresentationLayerAssignment( + name, pl.description, [i["ifc"].MappedRepresentation for i in assigned_items], pl.identifier + ) + else: + self.file.createIfcPresentationLayerWithStyle( + name, pl.description, [i["ifc"].MappedRepresentation for i in assigned_items], pl.identifier, + pl.layer_on, pl.layer_frozen, pl.layer_blocked, pl.layer_styles + ) def create_materials(self): for material in self.ifc_parser.materials.values(): @@ -2108,9 +2117,9 @@ class IfcExporter: def get_rendering_attributes(self, material): if ( - not material.use_nodes - or not hasattr(material.node_tree, "nodes") - or "Principled BSDF" not in material.node_tree.nodes + not material.use_nodes + or not hasattr(material.node_tree, "nodes") + or "Principled BSDF" not in material.node_tree.nodes ): return {} bsdf = material.node_tree.nodes["Principled BSDF"] @@ -3223,7 +3232,10 @@ class IfcExporter: return results def relate_spaces_to_boundary_elements(self): - for (relating_space_index, relationships,) in self.ifc_parser.rel_space_boundaries.items(): + for ( + relating_space_index, + relationships, + ) in self.ifc_parser.rel_space_boundaries.items(): for relationship in relationships: relationship["attributes"]["GlobalId"] = ifcopenshell.guid.new() relationship["attributes"]["RelatedBuildingElement"] = self.ifc_parser.products[ @@ -3337,8 +3349,7 @@ class IfcExporter: tmp_file = os.path.join(unzipped_path, tmp_name) self.file.write(tmp_file) with zipfile.ZipFile( - self.ifc_export_settings.output_file, mode="w", compression=zipfile.ZIP_DEFLATED, - compresslevel=9 + self.ifc_export_settings.output_file, mode="w", compression=zipfile.ZIP_DEFLATED, compresslevel=9 ) as zf: zf.write(tmp_file) elif extension == "ifc": diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index d5c924320b..04394361a5 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -4288,8 +4288,9 @@ class AddToPresentationLayer(bpy.types.Operator): def execute(self, context): name = bpy.context.scene.BIMProperties.presentation_layers[self.index].name bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name - - print(f'Adding "{self.index} - {name}" to "{bpy.context.scene.BIMProperties.name}"') + bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name + elem_name = bpy.context.active_object.BIMObjectProperties.attributes["Name"].string_value + print(f'Adding "({self.index} - {name})" to "{elem_name}"') return {"FINISHED"} @@ -4298,21 +4299,16 @@ class AddPresentationLayer(bpy.types.Operator): bl_idname = "bim.add_presentation_layer" bl_label = "Add Presentation Layer" - _name = 'New Presentation Layer' - descript = 'A Description' - identifier = 'Something' - layer_on = True - layer_frozen = False - layer_blocked = False - def execute(self, context): new = bpy.context.scene.BIMProperties.presentation_layers.add() - new.name = self._name - new.description = self.descript - new.identifier = self.identifier - new.layer_on = self.layer_on - new.layer_frozen = self.layer_frozen - new.layer_blocked = self.layer_blocked + + # Default values of a new presentation layer + new.name = "New Presentation Layer" + new.description = "A Description" + new.identifier = "Something" + new.layer_on = True + new.layer_frozen = False + new.layer_blocked = False return {"FINISHED"} @@ -4322,11 +4318,35 @@ class RemovePresentationLayer(bpy.types.Operator): bl_label = "Remove Presentation Layer" index: bpy.props.IntProperty() + def execute(self, context): bpy.context.scene.BIMProperties.presentation_layers.remove(self.index) return {"FINISHED"} +class UpdatePresentationLayer(bpy.types.Operator): + bl_idname = "bim.update_presentation_layer" + bl_label = "Update Presentation Layer" + index: bpy.props.IntProperty() + pl_name = bpy.props.StringProperty() + pl_description = bpy.props.StringProperty() + pl_identifier = bpy.props.StringProperty() + pl_layer_on = bpy.props.BoolProperty() + pl_layer_frozen = bpy.props.BoolProperty() + pl_layer_blocked = bpy.props.BoolProperty() + + def execute(self, context): + pl = bpy.context.scene.BIMProperties.presentation_layers[self.index] + pl.name = self.pl_name + pl.description = self.pl_description + pl.identifier = self.pl_identifier + pl.layer_on = self.pl_layer_on + pl.layer_frozen = self.pl_layer_frozen + pl.layer_blocked = self.pl_layer_blocked + + return {"FINISHED"} + + class AddDrawingStyleAttribute(bpy.types.Operator): bl_idname = "bim.add_drawing_style_attribute" bl_label = "Add Drawing Style Attribute" diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 7c4096a1e6..932b1041de 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -799,8 +799,8 @@ class PresentationLayer(PropertyGroup): description: StringProperty(name="Description") identifier: StringProperty(name="Identifier") layer_on: BoolProperty(name="LayerOn", default=True) - layer_frozen: BoolProperty(name="LayerFrozen") - layer_blocked: BoolProperty(name="LayerBlocked") + layer_frozen: BoolProperty(name="LayerFrozen", default=False) + layer_blocked: BoolProperty(name="LayerBlocked", default=False) layer_styles: EnumProperty(items=[], name="LayerStyles") diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 90ddfb31d8..e69490b3e6 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -788,7 +788,7 @@ class BIM_PT_presentation_layer_data(Panel): elem_props = context.active_object.data.BIMMeshProperties.presentation_layer scene_props = context.scene.BIMProperties - if elem_props.name != '': + if elem_props.name != "": layout.row(align=True).prop(elem_props, "name") layout.row().prop(elem_props, "description") layout.row().prop(elem_props, "identifier") @@ -797,11 +797,17 @@ class BIM_PT_presentation_layer_data(Panel): layout.row().prop(elem_props, "layer_blocked") layout.row().prop(elem_props, "layer_styles") else: - layout.label(text='Not included in any presentation layer') + layout.label(text="Not included in any presentation layer") if scene_props.presentation_layers: - layout.template_list("BIM_UL_presentation_layers", "", scene_props, "presentation_layers", scene_props, - "active_presentation_layer_index") + layout.template_list( + "BIM_UL_presentation_layers", + "", + scene_props, + "presentation_layers", + scene_props, + "active_presentation_layer_index", + ) pres_layer = scene_props.presentation_layers[scene_props.active_presentation_layer_index] if pres_layer.name in bpy.context.scene.BIMProperties.presentation_layers: op = layout.row().operator("bim.add_to_presentation_layer") @@ -950,8 +956,9 @@ class BIM_PT_presentation_layers(Panel): layout.row().operator("bim.add_presentation_layer") if props.presentation_layers: - layout.template_list("BIM_UL_presentation_layers", "", props, "presentation_layers", props, - "active_presentation_layer_index") + layout.template_list( + "BIM_UL_presentation_layers", "", props, "presentation_layers", props, "active_presentation_layer_index" + ) pres_layer = props.presentation_layers[props.active_presentation_layer_index] row = layout.row(align=True) @@ -963,8 +970,6 @@ class BIM_PT_presentation_layers(Panel): ).index = props.active_presentation_layer_index row = layout.row() row.prop(pres_layer, "description") - # row = layout.row() - # row.prop(pres_layer, "assigned_items") row = layout.row() row.prop(pres_layer, "identifier") row = layout.row() @@ -975,6 +980,11 @@ class BIM_PT_presentation_layers(Panel): row.prop(pres_layer, "layer_blocked") row = layout.row() row.prop(pres_layer, "layer_styles") + + op = layout.row().operator("bim.update_presentation_layer") + op.index = props.active_presentation_layer_index + op.pl_name = pres_layer.name + op.pl_description = pres_layer.description else: layout.label(text="Presentation Layer is invalid") From 9f86396edf94517ca5f21a07c68e4cf8b0e4fbb9 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Mon, 9 Nov 2020 13:34:55 +0100 Subject: [PATCH 11/15] Finished with creating, exporting Presentation Layer. Will start work on importing Presentation layer --- .../blenderbim/bim/__init__.py | 1 + .../blenderbim/bim/operator.py | 39 ++++++++++++++++--- src/ifcblenderexport/blenderbim/bim/ui.py | 38 +++++++++--------- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 7998d73aaa..a2df9ed70c 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -205,6 +205,7 @@ if bpy is not None: operator.GetNorthOffset, operator.AddPresentationLayer, operator.AddToPresentationLayer, + operator.RemoveFromPresentationLayer, operator.RemovePresentationLayer, operator.UpdatePresentationLayer, operator.AddDrawingStyleAttribute, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 04394361a5..2cfa233d4a 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -4286,11 +4286,30 @@ class AddToPresentationLayer(bpy.types.Operator): index: bpy.props.IntProperty() def execute(self, context): - name = bpy.context.scene.BIMProperties.presentation_layers[self.index].name - bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name - bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name - elem_name = bpy.context.active_object.BIMObjectProperties.attributes["Name"].string_value - print(f'Adding "({self.index} - {name})" to "{elem_name}"') + presentation_layer = bpy.context.scene.BIMProperties.presentation_layers[self.index] + + vl = bpy.context.scene.view_layers[presentation_layer.name] + + for el in bpy.context.selected_objects: + el.BIMObjectProperties.presentation_layer.name = presentation_layer.name + elem_name = el.BIMObjectProperties.attributes["Name"].string_value + + # TODO: I want to add the selected elements to a view layer. But how do you append objects to a view_layer? + # vl.objects.append(el) + + print(f'Adding "{elem_name}" to View/Presentation Layer "({self.index} - {presentation_layer.name})"') + + return {"FINISHED"} + + +class RemoveFromPresentationLayer(bpy.types.Operator): + bl_idname = "bim.remove_from_presentation_layer" + bl_label = "Remove Selected From Presentation Layer" + + def execute(self, context): + for el in bpy.context.selected_objects: + if el.BIMObjectProperties.presentation_layer.name != '': + el.BIMObjectProperties.presentation_layer.name = '' return {"FINISHED"} @@ -4318,9 +4337,12 @@ class RemovePresentationLayer(bpy.types.Operator): bl_label = "Remove Presentation Layer" index: bpy.props.IntProperty() - def execute(self, context): + pl = bpy.context.scene.BIMProperties.presentation_layers[self.index] + if pl.name not in bpy.context.scene.view_layers.keys(): + bpy.context.scene.view_layers.remove(pl.name) bpy.context.scene.BIMProperties.presentation_layers.remove(self.index) + return {"FINISHED"} @@ -4344,6 +4366,11 @@ class UpdatePresentationLayer(bpy.types.Operator): pl.layer_frozen = self.pl_layer_frozen pl.layer_blocked = self.pl_layer_blocked + if pl.name not in bpy.context.scene.view_layers.keys(): + new = bpy.context.scene.view_layers.new(pl.name) + # if pl.layer_on is False: + # bpy.context.scene.view_layers + return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index e69490b3e6..efe02f1739 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -259,11 +259,11 @@ class BIM_PT_object_qto(Panel): row.prop(prop, "name", text="") row.prop(prop, "string_value", text="") if ( - "length" in prop.name.lower() - or "width" in prop.name.lower() - or "height" in prop.name.lower() - or "depth" in prop.name.lower() - or "perimeter" in prop.name.lower() + "length" in prop.name.lower() + or "width" in prop.name.lower() + or "height" in prop.name.lower() + or "depth" in prop.name.lower() + or "perimeter" in prop.name.lower() ): op = row.operator("bim.guess_quantity", icon="IPO_EASE_IN_OUT", text="") op.qto_index = index @@ -710,9 +710,9 @@ class BIM_PT_mesh(Panel): @classmethod def poll(cls, context): return ( - context.active_object is not None - and context.active_object.type == "MESH" - and hasattr(context.active_object.data, "BIMMeshProperties") + context.active_object is not None + and context.active_object.type == "MESH" + and hasattr(context.active_object.data, "BIMMeshProperties") ) def draw(self, context): @@ -776,26 +776,21 @@ class BIM_PT_presentation_layer_data(Panel): @classmethod def poll(cls, context): return ( - context.active_object is not None - and context.active_object.type == "MESH" - and hasattr(context.active_object.data, "BIMMeshProperties") + context.active_object is not None + and context.active_object.type == "MESH" + and hasattr(context.active_object.data, "BIMMeshProperties") ) def draw(self, context): if not context.active_object.data: return layout = self.layout - elem_props = context.active_object.data.BIMMeshProperties.presentation_layer + elem_props = context.active_object.BIMObjectProperties.presentation_layer scene_props = context.scene.BIMProperties if elem_props.name != "": - layout.row(align=True).prop(elem_props, "name") - layout.row().prop(elem_props, "description") - layout.row().prop(elem_props, "identifier") - layout.row().prop(elem_props, "layer_on") - layout.row().prop(elem_props, "layer_frozen") - layout.row().prop(elem_props, "layer_blocked") - layout.row().prop(elem_props, "layer_styles") + layout.label(text=f'Object is part of Presentation layer "{elem_props.name}"') + layout.row().operator("bim.remove_from_presentation_layer") else: layout.label(text="Not included in any presentation layer") @@ -985,6 +980,11 @@ class BIM_PT_presentation_layers(Panel): op.index = props.active_presentation_layer_index op.pl_name = pres_layer.name op.pl_description = pres_layer.description + op.pl_identifier = pres_layer.identifier + op.pl_layer_on = pres_layer.layer_on + op.pl_layer_frozen = pres_layer.layer_frozen + op.pl_layer_blocked = pres_layer.layer_blocked + else: layout.label(text="Presentation Layer is invalid") From 26510de9e09cf6d8f4b41d8ca8a6dd16e272d2d2 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Mon, 9 Nov 2020 13:40:14 +0100 Subject: [PATCH 12/15] Cleaned up formatting to align with master v0.6 branch --- .../blenderbim/bim/operator.py | 112 +++++++++--------- src/ifcblenderexport/blenderbim/bim/prop.py | 39 +++--- src/ifcblenderexport/blenderbim/bim/ui.py | 4 +- 3 files changed, 76 insertions(+), 79 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 99b4bde62d..3ffb6a59c8 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -55,8 +55,8 @@ def set_active_camera_resolution(scene): if not scene.camera or "/" not in scene.camera.name or not scene.DocProperties.drawings: return if ( - scene.render.resolution_x != scene.camera.data.BIMCameraProperties.raster_x - or scene.render.resolution_y != scene.camera.data.BIMCameraProperties.raster_y + scene.render.resolution_x != scene.camera.data.BIMCameraProperties.raster_x + or scene.render.resolution_y != scene.camera.data.BIMCameraProperties.raster_y ): scene.render.resolution_x = scene.camera.data.BIMCameraProperties.raster_x scene.render.resolution_y = scene.camera.data.BIMCameraProperties.raster_y @@ -145,9 +145,8 @@ class SelectGlobalId(bpy.types.Operator): for obj in bpy.context.visible_objects: index = obj.BIMObjectProperties.attributes.find("GlobalId") if ( - index != -1 - and obj.BIMObjectProperties.attributes[ - index].string_value == bpy.context.scene.BIMProperties.global_id + index != -1 + and obj.BIMObjectProperties.attributes[index].string_value == bpy.context.scene.BIMProperties.global_id ): obj.select_set(True) break @@ -168,9 +167,9 @@ class SelectAttribute(bpy.types.Operator): continue value = object.BIMObjectProperties.attributes[index].string_value if ( - bpy.context.scene.BIMProperties.search_regex - and bpy.context.scene.BIMProperties.search_ignorecase - and re.search(search_value, value, flags=re.IGNORECASE) + bpy.context.scene.BIMProperties.search_regex + and bpy.context.scene.BIMProperties.search_ignorecase + and re.search(search_value, value, flags=re.IGNORECASE) ): object.select_set(True) elif bpy.context.scene.BIMProperties.search_regex and re.search(search_value, value): @@ -201,9 +200,9 @@ class SelectPset(bpy.types.Operator): continue value = object.BIMObjectProperties.psets[pset_index].properties[prop_index].string_value if ( - bpy.context.scene.BIMProperties.search_regex - and bpy.context.scene.BIMProperties.search_ignorecase - and re.search(search_value, value, flags=re.IGNORECASE) + bpy.context.scene.BIMProperties.search_regex + and bpy.context.scene.BIMProperties.search_ignorecase + and re.search(search_value, value, flags=re.IGNORECASE) ): object.select_set(True) elif bpy.context.scene.BIMProperties.search_regex and re.search(search_value, value): @@ -302,9 +301,9 @@ class SelectClass(bpy.types.Operator): def execute(self, context): for object in bpy.context.visible_objects: if ( - "/" in object.name - and object.name[0:3] == "Ifc" - and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class + "/" in object.name + and object.name[0:3] == "Ifc" + and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class ): object.select_set(True) return {"FINISHED"} @@ -317,19 +316,19 @@ class SelectType(bpy.types.Operator): def execute(self, context): for object in bpy.context.visible_objects: if ( - "/" in object.name - and object.name[0:3] == "Ifc" - and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class - and "PredefinedType" in object.BIMObjectProperties.attributes - and object.BIMObjectProperties.attributes["PredefinedType"].string_value - == bpy.context.scene.BIMProperties.ifc_predefined_type + "/" in object.name + and object.name[0:3] == "Ifc" + and object.name.split("/")[0] == bpy.context.scene.BIMProperties.ifc_class + and "PredefinedType" in object.BIMObjectProperties.attributes + and object.BIMObjectProperties.attributes["PredefinedType"].string_value + == bpy.context.scene.BIMProperties.ifc_predefined_type ): if bpy.context.scene.BIMProperties.ifc_predefined_type != "USERDEFINED": object.select_set(True) elif ( - "ObjectType" in object.BIMObjectProperties.attributes - and object.BIMObjectProperties.attributes["ObjectType"].string_value - == bpy.context.scene.BIMProperties.ifc_userdefined_type + "ObjectType" in object.BIMObjectProperties.attributes + and object.BIMObjectProperties.attributes["ObjectType"].string_value + == bpy.context.scene.BIMProperties.ifc_userdefined_type ): object.select_set(True) return {"FINISHED"} @@ -424,8 +423,8 @@ class QAHelper: is_in_scenario = False for source_line in source: if ( - "Scenario: " in source_line - and bpy.context.scene.BIMProperties.scenario == source_line.strip()[len("Scenario: "):] + "Scenario: " in source_line + and bpy.context.scene.BIMProperties.scenario == source_line.strip()[len("Scenario: ") :] ): is_in_scenario = True elif is_in_scenario: @@ -716,7 +715,7 @@ class ActivateBcfViewpoint(bpy.types.Operator): def hex_to_rgb(self, value): value = value.lstrip("#") lv = len(value) - t = tuple(int(value[i: i + lv // 3], 16) for i in range(0, lv, lv // 3)) + t = tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3)) return [t[0] / 255.0, t[1] / 255.0, t[2] / 255.0, 1] @@ -2395,12 +2394,12 @@ class CutSection(bpy.types.Operator): obj.hide_set(True) for obj in bpy.context.visible_objects: if ( - not obj.data - or isinstance(obj.data, bpy.types.Camera) - or "IfcGrid/" in obj.name - or "IfcGridAxis/" in obj.name - or "IfcOpeningElement/" in obj.name - or self.does_obj_have_target_view_representation(obj, camera) + not obj.data + or isinstance(obj.data, bpy.types.Camera) + or "IfcGrid/" in obj.name + or "IfcGridAxis/" in obj.name + or "IfcOpeningElement/" in obj.name + or self.does_obj_have_target_view_representation(obj, camera) ): previous_visibility[obj.name] = obj.hide_get() obj.hide_set(True) @@ -2545,8 +2544,8 @@ class ActivateView(bpy.types.Operator): # We assume a convention that the 'Views' collection is directly # in the project collection if ( - "Views" in project_collection.children - and collection.name in project_collection.children["Views"].children + "Views" in project_collection.children + and collection.name in project_collection.children["Views"].children ): project_collection.children["Views"].children[collection.name].hide_viewport = True bpy.data.collections.get(collection.name).hide_render = True @@ -2605,9 +2604,9 @@ class SwitchContext(bpy.types.Operator): has_context = False for context in self.obj.BIMObjectProperties.representation_contexts: if ( - context.context == self.context - and context.name == self.subcontext - and context.target_view == self.target_view + context.context == self.context + and context.name == self.subcontext + and context.target_view == self.target_view ): has_context = True break @@ -2634,16 +2633,16 @@ class SwitchContext(bpy.types.Operator): for rep in element.Representation.Representations: if ( - rep.ContextOfItems.is_a("IfcGeometricRepresentationSubContext") - and rep.ContextOfItems.ContextType == self.context - and rep.ContextOfItems.ContextIdentifier == self.subcontext - and rep.ContextOfItems.TargetView == self.target_view + rep.ContextOfItems.is_a("IfcGeometricRepresentationSubContext") + and rep.ContextOfItems.ContextType == self.context + and rep.ContextOfItems.ContextIdentifier == self.subcontext + and rep.ContextOfItems.TargetView == self.target_view ): break elif ( - rep.ContextOfItems.is_a("IfcGeometricRepresentationContext") - and rep.ContextOfItems.ContextType == self.context - and rep.ContextOfItems.ContextIdentifier == self.subcontext + rep.ContextOfItems.is_a("IfcGeometricRepresentationContext") + and rep.ContextOfItems.ContextType == self.context + and rep.ContextOfItems.ContextIdentifier == self.subcontext ): break @@ -2978,8 +2977,7 @@ class AddSectionPlane(bpy.types.Operator): section.show_in_front = True if bpy.context.active_object.select_get() and isinstance(bpy.context.active_object.data, bpy.types.Camera): section.matrix_world = ( - bpy.context.active_object.matrix_world @ Euler((radians(180.0), 0.0, 0.0), - "XYZ").to_matrix().to_4x4() + bpy.context.active_object.matrix_world @ Euler((radians(180.0), 0.0, 0.0), "XYZ").to_matrix().to_4x4() ) else: section.rotation_euler = Euler((radians(180.0), 0.0, 0.0), "XYZ") @@ -3396,12 +3394,12 @@ class GenerateReferences(bpy.types.Operator): if self.camera.data.BIMCameraProperties.raster_x > self.camera.data.BIMCameraProperties.raster_y: width = self.camera.data.ortho_scale height = ( - width / self.camera.data.BIMCameraProperties.raster_x * self.camera.data.BIMCameraProperties.raster_y + width / self.camera.data.BIMCameraProperties.raster_x * self.camera.data.BIMCameraProperties.raster_y ) else: height = self.camera.data.ortho_scale width = ( - height / self.camera.data.BIMCameraProperties.raster_y * self.camera.data.BIMCameraProperties.raster_x + height / self.camera.data.BIMCameraProperties.raster_y * self.camera.data.BIMCameraProperties.raster_x ) level_obj = annotation.Annotator.get_annotation_obj("Section Level", "curve") @@ -3587,9 +3585,9 @@ class PushRepresentation(bpy.types.Operator): def is_current_context(self, element): return ( - element.ContextType == self.context - and element.ContextIdentifier == self.subcontext - and element.TargetView == self.target_view + element.ContextType == self.context + and element.ContextIdentifier == self.subcontext + and element.TargetView == self.target_view ) @@ -3703,7 +3701,7 @@ class GuessQuantity(bpy.types.Operator): elif bpy.context.scene.unit_settings.system == "METRIC": if bpy.context.scene.unit_settings.length_unit == "METERS": return None, "METRE" - return bpy.context.scene.unit_settings.length_unit[0: -len("METERS")], "METRE" + return bpy.context.scene.unit_settings.length_unit[0 : -len("METERS")], "METRE" class ExecuteBIMTester(bpy.types.Operator): @@ -3934,7 +3932,7 @@ class ActivateDrawingStyle(bpy.types.Operator): def execute(self, context): if context.scene.camera.data.BIMCameraProperties.active_drawing_style_index < len( - bpy.context.scene.DocProperties.drawing_styles + bpy.context.scene.DocProperties.drawing_styles ): self.drawing_style = bpy.context.scene.DocProperties.drawing_styles[ context.scene.camera.data.BIMCameraProperties.active_drawing_style_index @@ -4288,7 +4286,7 @@ class SetViewportShadowFromSun(bpy.types.Operator): # The vector used for the light direction is a bit funny mat = Matrix(((-1.0, 0.0, 0.0, 0.0), (0.0, 0, 1.0, 0.0), (-0.0, -1.0, 0, 0.0), (0.0, 0.0, 0.0, 1.0))) context.scene.display.light_direction = mat.inverted() @ ( - context.active_object.matrix_world.to_quaternion() @ Vector((0, 0, -1)) + context.active_object.matrix_world.to_quaternion() @ Vector((0, 0, -1)) ) return {"FINISHED"} @@ -4346,8 +4344,8 @@ class RemoveFromPresentationLayer(bpy.types.Operator): def execute(self, context): for el in bpy.context.selected_objects: - if el.BIMObjectProperties.presentation_layer.name != '': - el.BIMObjectProperties.presentation_layer.name = '' + if el.BIMObjectProperties.presentation_layer.name != "": + el.BIMObjectProperties.presentation_layer.name = "" return {"FINISHED"} @@ -4461,7 +4459,7 @@ class SelectHighPolygonMeshes(bpy.types.Operator): results = {} for obj in bpy.data.objects: if not isinstance(obj.data, bpy.types.Mesh) or len(obj.data.polygons) < int( - bpy.context.scene.BIMDebugProperties.number_of_polygons + bpy.context.scene.BIMDebugProperties.number_of_polygons ): continue try: diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index db74a431d6..6aa3f6f59f 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -58,8 +58,8 @@ bcfviewpoints_enum = [] @persistent def setDefaultProperties(scene): if ( - bpy.context.scene.BIMProperties.has_model_context - and len(bpy.context.scene.BIMProperties.model_subcontexts) == 0 + bpy.context.scene.BIMProperties.has_model_context + and len(bpy.context.scene.BIMProperties.model_subcontexts) == 0 ): subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add() subcontext.name = "Body" @@ -170,9 +170,9 @@ def refreshPredefinedTypes(self, context): def getDiagramScales(self, context): global diagram_scales_enum if ( - len(diagram_scales_enum) < 1 - or (bpy.context.scene.unit_settings.system == "IMPERIAL" and len(diagram_scales_enum) == 13) - or (bpy.context.scene.unit_settings.system == "METRIC" and len(diagram_scales_enum) == 31) + len(diagram_scales_enum) < 1 + or (bpy.context.scene.unit_settings.system == "IMPERIAL" and len(diagram_scales_enum) == 13) + or (bpy.context.scene.unit_settings.system == "METRIC" and len(diagram_scales_enum) == 31) ): if bpy.context.scene.unit_settings.system == "IMPERIAL": diagram_scales_enum = [ @@ -290,15 +290,15 @@ def getIfcProducts(self, context): [ (e, e, "") for e in [ - "IfcElement", - "IfcElementType", - "IfcSpatialElement", - "IfcGroup", - "IfcStructural", - "IfcPositioningElement", - "IfcContext", - "IfcAnnotation", - ] + "IfcElement", + "IfcElementType", + "IfcSpatialElement", + "IfcGroup", + "IfcStructural", + "IfcPositioningElement", + "IfcContext", + "IfcAnnotation", + ] ] ) return products_enum @@ -374,7 +374,7 @@ def getTitleblocks(self, context): if len(titleblocks_enum) < 1: titleblocks_enum.clear() for filename in Path(os.path.join(context.scene.BIMProperties.data_dir, "templates", "titleblocks")).glob( - "*.svg" + "*.svg" ): f = str(filename.stem) titleblocks_enum.append((f, f, "")) @@ -398,7 +398,7 @@ def getScenarios(self, context): lines = feature_file.readlines() for line in lines: if "Scenario:" in line: - s = line.strip()[len("Scenario: "):] + s = line.strip()[len("Scenario: ") :] scenarios_enum.append((s, s, "")) return scenarios_enum @@ -666,7 +666,7 @@ class DrawingStyle(PropertyGroup): name: StringProperty(name="Name") raster_style: StringProperty(name="Raster Style") render_type: EnumProperty( - items=[("NONE", "None", ""), ("DEFAULT", "Default", ""), ("VIEWPORT", "Viewport", ""), ], + items=[("NONE", "None", ""), ("DEFAULT", "Default", ""), ("VIEWPORT", "Viewport", ""),], name="Render Type", default="VIEWPORT", ) @@ -739,7 +739,7 @@ class BIMTextProperties(PropertyGroup): name="Font Size", ) symbol: EnumProperty( - items=[("None", "None", ""), ("rectangle-tag", "Rectangle Tag", ""), ("door-tag", "Door Tag", ""), ], + items=[("None", "None", ""), ("rectangle-tag", "Rectangle Tag", ""), ("door-tag", "Door Tag", ""),], update=refreshFontSize, name="Symbol", ) @@ -1532,7 +1532,7 @@ class BIMProperties(PropertyGroup): name="Temporary Section Cutaway Colour", subtype="COLOR", default=(1, 0, 0), min=0.0, max=1.0 ) ifc_import_filter: EnumProperty( - items=[("NONE", "None", ""), ("WHITELIST", "Whitelist", ""), ("BLACKLIST", "Blacklist", ""), ], + items=[("NONE", "None", ""), ("WHITELIST", "Whitelist", ""), ("BLACKLIST", "Blacklist", ""),], name="Import Filter", ) ifc_selector: StringProperty(default="", name="IFC Selector") @@ -1603,7 +1603,6 @@ class BIMProperties(PropertyGroup): presentation_layers: CollectionProperty(name="Presentation Layers", type=PresentationLayer) - class BCFProperties(PropertyGroup): bcf_file: StringProperty(default="", name="BCF File") topics: CollectionProperty(name="BCF Topics", type=BcfTopic) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index dbc035671d..646d74948b 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -1717,7 +1717,7 @@ class BIM_PT_bcf(Panel): layout.label(text="Document References:") for index, doc in enumerate(props.topic_document_references): row = layout.row(align=True) - row.prop(doc, "name", text=f"File {index + 1} URI") + row.prop(doc, "name", text=f"File {index+1} URI") if doc.is_external: row.operator("bim.open_bcf_document_reference", icon="URL", text="").data = "{}/{}".format( props.topic_guid, index @@ -1727,7 +1727,7 @@ class BIM_PT_bcf(Panel): props.topic_guid, index ) row = layout.row(align=True) - row.prop(doc, "description", text=f"File {index + 1} Description:") + row.prop(doc, "description", text=f"File {index+1} Description:") layout.label(text="Related Topics:") for topic in props.topic_related_topics: From 2eae3a70d963a2037971b8d0c9f30c0ab003676d Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Mon, 9 Nov 2020 16:44:56 +0100 Subject: [PATCH 13/15] Added support for importing Presentation Layers from Ifc --- .../blenderbim/bim/import_ifc.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index 89f2024b91..ea583bc8eb 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -479,6 +479,7 @@ class IfcImporter: self.profile_code("Merging by colour") self.add_project_to_scene() self.profile_code("Add project to scene") + self.get_presentation_layers() if self.ifc_import_settings.should_clean_mesh and len(self.file.by_type("IfcElement")) < 10000: self.clean_mesh() self.profile_code("Mesh cleaning") @@ -1309,6 +1310,23 @@ class IfcImporter: self.type_collection.name ].hide_viewport = True + def get_presentation_layers(self): + for f in self.file.by_type("IfcPresentationLayerAssignment"): + new = bpy.context.scene.BIMProperties.presentation_layers.add() + new.name = f.Name + new.description = f.Description + new.identifier = f.Identifier + if f.is_a() == "IfcPresentationLayerWithStyle": + new.layer_on = f.LayerOn if f.LayerOn is not None else True + new.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False + new.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False + for item in f.AssignedItems: + guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId + for obj in bpy.context.selectable_objects: + global_id = obj.BIMObjectProperties.attributes.get("GlobalId") + if global_id and global_id.string_value == guid: + obj.BIMObjectProperties.presentation_layer.name = new.name + def clean_mesh(self): obj = None last_obj = None From aca90b38c86e59a96d3ca719ccd3e63af4769aee Mon Sep 17 00:00:00 2001 From: krande Date: Mon, 9 Nov 2020 18:08:03 +0100 Subject: [PATCH 14/15] further experimentation. Still not able to hide\unhide --- .../blenderbim/bim/import_ifc.py | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index ea583bc8eb..442da19e84 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -1312,20 +1312,38 @@ class IfcImporter: def get_presentation_layers(self): for f in self.file.by_type("IfcPresentationLayerAssignment"): - new = bpy.context.scene.BIMProperties.presentation_layers.add() - new.name = f.Name - new.description = f.Description - new.identifier = f.Identifier + pl = bpy.context.scene.BIMProperties.presentation_layers.add() + pl.name = f.Name + pl.description = f.Description + pl.identifier = f.Identifier if f.is_a() == "IfcPresentationLayerWithStyle": - new.layer_on = f.LayerOn if f.LayerOn is not None else True - new.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False - new.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False + pl.layer_on = f.LayerOn if f.LayerOn is not None else True + pl.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False + pl.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False + + if pl.name not in bpy.context.scene.view_layers.keys(): + vl = bpy.context.scene.view_layers.new(pl.name) + else: + vl = bpy.context.scene.view_layers[pl.name] + + if pl.name not in bpy.data.collections.keys(): + coll = bpy.data.collections.new(pl.name) + else: + coll = bpy.data.collections[pl.name] + + if pl.layer_on is False: + # vl.objects.data.layer_collection.collection.hide_viewport = True + # bpy.context.window.view_layer.layer_collection.children[pl.name].exclude = True + coll.hide_viewport = True + for item in f.AssignedItems: guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId for obj in bpy.context.selectable_objects: global_id = obj.BIMObjectProperties.attributes.get("GlobalId") if global_id and global_id.string_value == guid: - obj.BIMObjectProperties.presentation_layer.name = new.name + obj.BIMObjectProperties.presentation_layer.name = pl.name + # vl.objects.data.layer_collection.collection.objects.link(obj) + coll.objects.link(obj) def clean_mesh(self): obj = None From b9e34a107bdbc25c9b5b36e31e2df731d2c4fc30 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Fri, 13 Nov 2020 14:45:08 +0100 Subject: [PATCH 15/15] Prepare for pull request --- src/ifcblenderexport/blenderbim/__init__.py | 1 + .../blenderbim/bim/export_ifc.py | 6 +-- .../blenderbim/bim/import_ifc.py | 18 +-------- .../blenderbim/bim/operator.py | 40 +++++-------------- src/ifcblenderexport/blenderbim/bim/prop.py | 21 ---------- src/ifcblenderexport/blenderbim/bim/ui.py | 7 +--- 6 files changed, 14 insertions(+), 79 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/__init__.py b/src/ifcblenderexport/blenderbim/__init__.py index 2abfc7c739..e26493b051 100644 --- a/src/ifcblenderexport/blenderbim/__init__.py +++ b/src/ifcblenderexport/blenderbim/__init__.py @@ -18,6 +18,7 @@ import site cwd = os.path.dirname(os.path.realpath(__file__)) site.addsitedir(os.path.join(cwd, "libs", "site", "packages")) + # main import from .bim import * diff --git a/src/ifcblenderexport/blenderbim/bim/export_ifc.py b/src/ifcblenderexport/blenderbim/bim/export_ifc.py index c2cd93bcb6..811bffcb1e 100644 --- a/src/ifcblenderexport/blenderbim/bim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/export_ifc.py @@ -983,7 +983,6 @@ class IfcParser: pl = representation["presentation_layer"] if pl.name == '': continue - print("Presentation load: ", pl.name) self.presentation_layer_assignments.setdefault(pl.name, []).append(representation) def load_representations(self): @@ -3248,10 +3247,7 @@ class IfcExporter: return results def relate_spaces_to_boundary_elements(self): - for ( - relating_space_index, - relationships, - ) in self.ifc_parser.rel_space_boundaries.items(): + for (relating_space_index, relationships,) in self.ifc_parser.rel_space_boundaries.items(): for relationship in relationships: relationship["attributes"]["GlobalId"] = ifcopenshell.guid.new() relationship["attributes"]["RelatedBuildingElement"] = self.ifc_parser.products[ diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index 442da19e84..3b493438dc 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -1321,29 +1321,13 @@ class IfcImporter: pl.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False pl.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False - if pl.name not in bpy.context.scene.view_layers.keys(): - vl = bpy.context.scene.view_layers.new(pl.name) - else: - vl = bpy.context.scene.view_layers[pl.name] - - if pl.name not in bpy.data.collections.keys(): - coll = bpy.data.collections.new(pl.name) - else: - coll = bpy.data.collections[pl.name] - - if pl.layer_on is False: - # vl.objects.data.layer_collection.collection.hide_viewport = True - # bpy.context.window.view_layer.layer_collection.children[pl.name].exclude = True - coll.hide_viewport = True - for item in f.AssignedItems: guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId for obj in bpy.context.selectable_objects: global_id = obj.BIMObjectProperties.attributes.get("GlobalId") if global_id and global_id.string_value == guid: obj.BIMObjectProperties.presentation_layer.name = pl.name - # vl.objects.data.layer_collection.collection.objects.link(obj) - coll.objects.link(obj) + obj.hide_set(not pl.layer_on) def clean_mesh(self): obj = None diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 3ffb6a59c8..0a8dc72571 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -4324,15 +4324,12 @@ class AddToPresentationLayer(bpy.types.Operator): def execute(self, context): presentation_layer = bpy.context.scene.BIMProperties.presentation_layers[self.index] - vl = bpy.context.scene.view_layers[presentation_layer.name] - - for el in bpy.context.selected_objects: - el.BIMObjectProperties.presentation_layer.name = presentation_layer.name - elem_name = el.BIMObjectProperties.attributes["Name"].string_value - - # TODO: I want to add the selected elements to a view layer. But how do you append objects to a view_layer? - # vl.objects.append(el) + # vl = bpy.context.scene.view_layers[presentation_layer.name] + for obj in bpy.context.selected_objects: + obj.BIMObjectProperties.presentation_layer.name = presentation_layer.name + elem_name = obj.BIMObjectProperties.attributes["Name"].string_value + obj.hide_set(not presentation_layer.layer_on) print(f'Adding "{elem_name}" to View/Presentation Layer "({self.index} - {presentation_layer.name})"') return {"FINISHED"} @@ -4374,9 +4371,6 @@ class RemovePresentationLayer(bpy.types.Operator): index: bpy.props.IntProperty() def execute(self, context): - pl = bpy.context.scene.BIMProperties.presentation_layers[self.index] - if pl.name not in bpy.context.scene.view_layers.keys(): - bpy.context.scene.view_layers.remove(pl.name) bpy.context.scene.BIMProperties.presentation_layers.remove(self.index) return {"FINISHED"} @@ -4384,29 +4378,15 @@ class RemovePresentationLayer(bpy.types.Operator): class UpdatePresentationLayer(bpy.types.Operator): bl_idname = "bim.update_presentation_layer" - bl_label = "Update Presentation Layer" + bl_label = "Hide/Show selected Presentation Layer" index: bpy.props.IntProperty() - pl_name = bpy.props.StringProperty() - pl_description = bpy.props.StringProperty() - pl_identifier = bpy.props.StringProperty() - pl_layer_on = bpy.props.BoolProperty() - pl_layer_frozen = bpy.props.BoolProperty() - pl_layer_blocked = bpy.props.BoolProperty() def execute(self, context): pl = bpy.context.scene.BIMProperties.presentation_layers[self.index] - pl.name = self.pl_name - pl.description = self.pl_description - pl.identifier = self.pl_identifier - pl.layer_on = self.pl_layer_on - pl.layer_frozen = self.pl_layer_frozen - pl.layer_blocked = self.pl_layer_blocked - - if pl.name not in bpy.context.scene.view_layers.keys(): - new = bpy.context.scene.view_layers.new(pl.name) - # if pl.layer_on is False: - # bpy.context.scene.view_layers - + for obj in bpy.context.scene.objects: + if obj.BIMObjectProperties.presentation_layer.name == pl.name: + set_status = obj.hide_get() + obj.hide_set(not obj.hide_get()) return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 6aa3f6f59f..04cd1963d9 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -259,26 +259,6 @@ def refreshBoundaryConditionAttributes(self, context): new_attribute.name = attribute["name"] -def getPresentationLayerClasses(self, context): - return [ - (c, c, "") - for c in [ - "IfcPresentationLayerAssignment", - "IfcPresentationLayerWithStyle", - ] - ] - - -def refreshPresentationLayerAttributes(self, context): - while len(context.active_object.BIMObjectProperties.presentation_layer.attributes) > 0: - context.active_object.BIMObjectProperties.presentation_layer.attributes.remove(0) - for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.presentation_layer.name][ - "complex_attributes" - ]: - new_attribute = context.active_object.BIMObjectProperties.presentation_layer.attributes.add() - new_attribute.name = attribute["name"] - - def refreshActiveDrawingIndex(self, context): bpy.ops.bim.activate_view(drawing_index=context.scene.DocProperties.active_drawing_index) @@ -1705,7 +1685,6 @@ class BIMObjectProperties(PropertyGroup): qto_name: EnumProperty(items=getQtoNames, name="Qto Name") has_boundary_condition: BoolProperty(name="Has Boundary Condition") boundary_condition: PointerProperty(name="Boundary Condition", type=BoundaryCondition) - active_presentation_layer_index: IntProperty(name="Active Presentation Layer Index") presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer) structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object) representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 646d74948b..153011899e 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -1003,12 +1003,7 @@ class BIM_PT_presentation_layers(Panel): op = layout.row().operator("bim.update_presentation_layer") op.index = props.active_presentation_layer_index - op.pl_name = pres_layer.name - op.pl_description = pres_layer.description - op.pl_identifier = pres_layer.identifier - op.pl_layer_on = pres_layer.layer_on - op.pl_layer_frozen = pres_layer.layer_frozen - op.pl_layer_blocked = pres_layer.layer_blocked + else: layout.label(text="Presentation Layer is invalid")