mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
WIP implement most of the document module apart from object references. See #1222.
This commit is contained in:
@@ -21,6 +21,7 @@ if bpy is not None:
|
|||||||
"diff": None,
|
"diff": None,
|
||||||
"bimtester": None,
|
"bimtester": None,
|
||||||
"debug": None,
|
"debug": None,
|
||||||
|
"document": None,
|
||||||
"geometry": None,
|
"geometry": None,
|
||||||
"georeference": None,
|
"georeference": None,
|
||||||
"material": None,
|
"material": None,
|
||||||
@@ -74,14 +75,6 @@ if bpy is not None:
|
|||||||
operator.AssignConstraint,
|
operator.AssignConstraint,
|
||||||
operator.UnassignConstraint,
|
operator.UnassignConstraint,
|
||||||
operator.RemoveObjectConstraint,
|
operator.RemoveObjectConstraint,
|
||||||
operator.AddDocumentInformation,
|
|
||||||
operator.RemoveDocumentInformation,
|
|
||||||
operator.AssignDocumentInformation,
|
|
||||||
operator.AddDocumentReference,
|
|
||||||
operator.RemoveDocumentReference,
|
|
||||||
operator.AssignDocumentReference,
|
|
||||||
operator.UnassignDocumentReference,
|
|
||||||
operator.RemoveObjectDocumentReference,
|
|
||||||
operator.GenerateGlobalId,
|
operator.GenerateGlobalId,
|
||||||
operator.AddMaterialAttribute,
|
operator.AddMaterialAttribute,
|
||||||
operator.RemoveMaterialAttribute,
|
operator.RemoveMaterialAttribute,
|
||||||
@@ -177,8 +170,6 @@ if bpy is not None:
|
|||||||
prop.Variable,
|
prop.Variable,
|
||||||
prop.PropertySetTemplate,
|
prop.PropertySetTemplate,
|
||||||
prop.PropertyTemplate,
|
prop.PropertyTemplate,
|
||||||
prop.DocumentInformation,
|
|
||||||
prop.DocumentReference,
|
|
||||||
prop.ClashSource,
|
prop.ClashSource,
|
||||||
prop.ClashSet,
|
prop.ClashSet,
|
||||||
prop.SmartClashGroup,
|
prop.SmartClashGroup,
|
||||||
@@ -208,7 +199,6 @@ if bpy is not None:
|
|||||||
ui.BIM_PT_schedules,
|
ui.BIM_PT_schedules,
|
||||||
ui.BIM_PT_sheets,
|
ui.BIM_PT_sheets,
|
||||||
ui.BIM_PT_psets,
|
ui.BIM_PT_psets,
|
||||||
ui.BIM_PT_document_information,
|
|
||||||
ui.BIM_PT_constraints,
|
ui.BIM_PT_constraints,
|
||||||
ui.BIM_PT_search,
|
ui.BIM_PT_search,
|
||||||
ui.BIM_PT_ifcclash,
|
ui.BIM_PT_ifcclash,
|
||||||
@@ -217,7 +207,6 @@ if bpy is not None:
|
|||||||
ui.BIM_PT_patch,
|
ui.BIM_PT_patch,
|
||||||
ui.BIM_PT_mvd,
|
ui.BIM_PT_mvd,
|
||||||
ui.BIM_PT_presentation_layer_data,
|
ui.BIM_PT_presentation_layer_data,
|
||||||
ui.BIM_PT_documents,
|
|
||||||
ui.BIM_PT_constraint_relations,
|
ui.BIM_PT_constraint_relations,
|
||||||
ui.BIM_PT_object_structural,
|
ui.BIM_PT_object_structural,
|
||||||
ui.BIM_PT_camera,
|
ui.BIM_PT_camera,
|
||||||
@@ -232,8 +221,6 @@ if bpy is not None:
|
|||||||
ui.BIM_UL_clash_sets,
|
ui.BIM_UL_clash_sets,
|
||||||
ui.BIM_UL_smart_groups,
|
ui.BIM_UL_smart_groups,
|
||||||
ui.BIM_UL_constraints,
|
ui.BIM_UL_constraints,
|
||||||
ui.BIM_UL_document_information,
|
|
||||||
ui.BIM_UL_document_references,
|
|
||||||
ui.BIM_UL_topics,
|
ui.BIM_UL_topics,
|
||||||
ui.BIM_ADDON_preferences,
|
ui.BIM_ADDON_preferences,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -351,10 +351,6 @@ class IfcImporter:
|
|||||||
self.profile_code("Create project")
|
self.profile_code("Create project")
|
||||||
self.create_constraints()
|
self.create_constraints()
|
||||||
self.profile_code("Create constraints")
|
self.profile_code("Create constraints")
|
||||||
self.create_document_information()
|
|
||||||
self.profile_code("Create doc info")
|
|
||||||
self.create_document_references()
|
|
||||||
self.profile_code("Create doc refs")
|
|
||||||
self.create_spatial_hierarchy()
|
self.create_spatial_hierarchy()
|
||||||
self.profile_code("Create spatial hierarchy")
|
self.profile_code("Create spatial hierarchy")
|
||||||
self.create_type_products()
|
self.create_type_products()
|
||||||
@@ -691,7 +687,6 @@ class IfcImporter:
|
|||||||
obj = bpy.data.objects.new(self.get_name(element), mesh)
|
obj = bpy.data.objects.new(self.get_name(element), mesh)
|
||||||
obj.BIMObjectProperties.ifc_definition_id = element.id()
|
obj.BIMObjectProperties.ifc_definition_id = element.id()
|
||||||
self.material_creator.create(element, obj, mesh)
|
self.material_creator.create(element, obj, mesh)
|
||||||
self.add_element_document_relations(element, obj)
|
|
||||||
self.type_collection.objects.link(obj)
|
self.type_collection.objects.link(obj)
|
||||||
self.type_products[element.GlobalId] = obj
|
self.type_products[element.GlobalId] = obj
|
||||||
|
|
||||||
@@ -811,7 +806,6 @@ class IfcImporter:
|
|||||||
obj.matrix_world = self.apply_blender_offset_to_matrix(self.get_element_matrix(element))
|
obj.matrix_world = self.apply_blender_offset_to_matrix(self.get_element_matrix(element))
|
||||||
|
|
||||||
self.add_element_representation_items(element, obj)
|
self.add_element_representation_items(element, obj)
|
||||||
self.add_element_document_relations(element, obj)
|
|
||||||
self.add_opening_relation(element, obj)
|
self.add_opening_relation(element, obj)
|
||||||
self.added_data[element.GlobalId] = obj
|
self.added_data[element.GlobalId] = obj
|
||||||
|
|
||||||
@@ -1266,73 +1260,6 @@ class IfcImporter:
|
|||||||
if hasattr(element, value) and getattr(element, value):
|
if hasattr(element, value) and getattr(element, value):
|
||||||
setattr(constraint, key, getattr(element, value))
|
setattr(constraint, key, getattr(element, value))
|
||||||
|
|
||||||
def create_document_information(self):
|
|
||||||
for element in self.file.by_type("IfcDocumentInformation"):
|
|
||||||
info = bpy.context.scene.BIMProperties.document_information.add()
|
|
||||||
data_map = {
|
|
||||||
"name": "Identification",
|
|
||||||
"human_name": "Name",
|
|
||||||
"description": "Description",
|
|
||||||
"location": "Location",
|
|
||||||
"purpose": "Purpose",
|
|
||||||
"intended_use": "IntendedUse",
|
|
||||||
"scope": "Scope",
|
|
||||||
"revision": "Revision",
|
|
||||||
"creation_time": "CreationTime",
|
|
||||||
"last_revision_time": "LastRevisionTime",
|
|
||||||
"electronic_format": "ElectronicFormat",
|
|
||||||
"valid_from": "ValidFrom",
|
|
||||||
"valid_until": "ValidUntil",
|
|
||||||
"confidentiality": "Confidentiality",
|
|
||||||
"status": "Status",
|
|
||||||
}
|
|
||||||
if self.file.schema == "IFC2X3":
|
|
||||||
data_map["name"] = "DocumentId"
|
|
||||||
for key, value in data_map.items():
|
|
||||||
if hasattr(element, value) and getattr(element, value):
|
|
||||||
element_value = getattr(element, value)
|
|
||||||
if self.file.schema == "IFC2X3" and isinstance(element_value, ifcopenshell.entity_instance):
|
|
||||||
if element_value.is_a("IfcDateAndTime"):
|
|
||||||
element_value = self.convert_ifc_date_and_time_to_string(element_value)
|
|
||||||
elif element_value.is_a("IfcDocumentElectronicFormat"):
|
|
||||||
element_value = self.convert_ifc_document_electronic_format(element_value)
|
|
||||||
setattr(info, key, element_value)
|
|
||||||
|
|
||||||
# TODO Maybe a candidate for ifcopenshell.util?
|
|
||||||
def convert_ifc_date_and_time_to_string(self, element):
|
|
||||||
return datetime(
|
|
||||||
element.DateComponent.YearComponent,
|
|
||||||
element.DateComponent.MonthComponent,
|
|
||||||
element.DateComponent.DayComponent,
|
|
||||||
element.TimeComponent.HourComponent,
|
|
||||||
element.TimeComponent.MinuteComponent if element.TimeComponent.MinuteComponent else 0,
|
|
||||||
int(element.TimeComponent.SecondComponent) if element.TimeComponent.SecondComponent else 0,
|
|
||||||
).isoformat()
|
|
||||||
|
|
||||||
def convert_ifc_document_electronic_format(self, element):
|
|
||||||
if not element.MimeContentType or not element.MimeSubtype:
|
|
||||||
return ""
|
|
||||||
return "{}/{}".format(element.MimeContentType, element.MimeSubtype)
|
|
||||||
|
|
||||||
def create_document_references(self):
|
|
||||||
for element in self.file.by_type("IfcDocumentReference"):
|
|
||||||
reference = bpy.context.scene.BIMProperties.document_references.add()
|
|
||||||
data_map = {
|
|
||||||
"name": "Identification",
|
|
||||||
"human_name": "Name",
|
|
||||||
"location": "Location",
|
|
||||||
"description": "Description",
|
|
||||||
}
|
|
||||||
for key, value in data_map.items():
|
|
||||||
if hasattr(element, value) and getattr(element, value):
|
|
||||||
setattr(reference, key, getattr(element, value))
|
|
||||||
if self.file.schema == "IFC2X3":
|
|
||||||
if element.ReferenceToDocument:
|
|
||||||
reference.referenced_document = element.ReferenceToDocument[0].DocumentId
|
|
||||||
else:
|
|
||||||
if element.ReferencedDocument:
|
|
||||||
reference.referenced_document = element.ReferencedDocument.Identification
|
|
||||||
|
|
||||||
def create_spatial_hierarchy(self):
|
def create_spatial_hierarchy(self):
|
||||||
if self.project["ifc"].IsDecomposedBy:
|
if self.project["ifc"].IsDecomposedBy:
|
||||||
for rel_aggregate in self.project["ifc"].IsDecomposedBy:
|
for rel_aggregate in self.project["ifc"].IsDecomposedBy:
|
||||||
@@ -1388,7 +1315,6 @@ class IfcImporter:
|
|||||||
obj.users_collection[0].objects.unlink(obj)
|
obj.users_collection[0].objects.unlink(obj)
|
||||||
collection.objects.link(obj)
|
collection.objects.link(obj)
|
||||||
|
|
||||||
self.add_element_document_relations(element, obj)
|
|
||||||
self.aggregates[element.GlobalId] = obj
|
self.aggregates[element.GlobalId] = obj
|
||||||
self.aggregate_collections[rel_aggregate.id()] = collection
|
self.aggregate_collections[rel_aggregate.id()] = collection
|
||||||
|
|
||||||
@@ -1411,21 +1337,6 @@ class IfcImporter:
|
|||||||
objects_to_purge.append(obj)
|
objects_to_purge.append(obj)
|
||||||
bpy.ops.object.delete({"selected_objects": objects_to_purge})
|
bpy.ops.object.delete({"selected_objects": objects_to_purge})
|
||||||
|
|
||||||
def add_element_document_relations(self, element, obj):
|
|
||||||
for association in element.HasAssociations:
|
|
||||||
if association.is_a("IfcRelAssociatesDocument"):
|
|
||||||
reference = obj.BIMObjectProperties.document_references.add()
|
|
||||||
data_map = {
|
|
||||||
"name": "Identification",
|
|
||||||
"human_name": "Name",
|
|
||||||
"description": "Description",
|
|
||||||
"location": "Location",
|
|
||||||
}
|
|
||||||
attributes = {}
|
|
||||||
for key, value in data_map.items():
|
|
||||||
if hasattr(association.RelatingDocument, value) and getattr(association.RelatingDocument, value):
|
|
||||||
setattr(reference, key, getattr(association.RelatingDocument, value))
|
|
||||||
|
|
||||||
def relate_openings(self):
|
def relate_openings(self):
|
||||||
for global_id, opening in self.openings.items():
|
for global_id, opening in self.openings.items():
|
||||||
building_element_global_id = self.file.by_guid(global_id).VoidsElements[0].RelatingBuildingElement.GlobalId
|
building_element_global_id = self.file.by_guid(global_id).VoidsElements[0].RelatingBuildingElement.GlobalId
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import bpy
|
||||||
|
from . import ui, prop, operator
|
||||||
|
|
||||||
|
classes = (
|
||||||
|
operator.LoadInformation,
|
||||||
|
operator.LoadDocumentReferences,
|
||||||
|
operator.DisableDocumentEditingUI,
|
||||||
|
operator.EnableEditingDocument,
|
||||||
|
operator.DisableEditingDocument,
|
||||||
|
operator.AddInformation,
|
||||||
|
operator.AddDocumentReference,
|
||||||
|
operator.EditInformation,
|
||||||
|
operator.EditDocumentReference,
|
||||||
|
operator.RemoveDocument,
|
||||||
|
prop.Document,
|
||||||
|
prop.BIMDocumentProperties,
|
||||||
|
ui.BIM_PT_documents,
|
||||||
|
ui.BIM_UL_documents,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.types.Scene.BIMDocumentProperties = bpy.props.PointerProperty(type=prop.BIMDocumentProperties)
|
||||||
|
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
del bpy.types.Scene.BIMDocumentProperties
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, settings={}):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
id_attribute = "DocumentId" if self.file.schema == "IFC2X3" else "Identification"
|
||||||
|
return self.file.create_entity("IfcDocumentInformation", **{
|
||||||
|
id_attribute: ifcopenshell.guid.new(),
|
||||||
|
"Name": "Unnamed"
|
||||||
|
})
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, settings={}):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
id_attribute = "ItemReference" if self.file.schema == "IFC2X3" else "Identification"
|
||||||
|
return self.file.create_entity("IfcDocumentReference", **{
|
||||||
|
id_attribute: ifcopenshell.guid.new()
|
||||||
|
})
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.date
|
||||||
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class Data:
|
||||||
|
is_loaded = False
|
||||||
|
products = {}
|
||||||
|
references = {}
|
||||||
|
information = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls, product_id=None):
|
||||||
|
cls._file = IfcStore.get_file()
|
||||||
|
if not cls._file:
|
||||||
|
return
|
||||||
|
if product_id:
|
||||||
|
return cls.load_product(product_id)
|
||||||
|
cls.load_references()
|
||||||
|
cls.load_information()
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_product(cls, product_id):
|
||||||
|
product = cls._file.by_id(product_id)
|
||||||
|
cls.products[product_id] = []
|
||||||
|
if not product.HasAssociations:
|
||||||
|
return
|
||||||
|
for association in product.HasAssociations:
|
||||||
|
if association.is_a("IfcRelAssociatesDocument"):
|
||||||
|
cls.products[product_id].append(association.RelatingDocument.id())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_information(cls):
|
||||||
|
cls.information = {}
|
||||||
|
for information in cls._file.by_type("IfcDocumentInformation"):
|
||||||
|
data = information.get_info()
|
||||||
|
if cls._file.schema == "IFC2X3":
|
||||||
|
for attribute in ["CreationTime", "LastRevisionTime", "ValidFrom", "ValidUntil"]:
|
||||||
|
if data[attribute]:
|
||||||
|
data[attribute] = ifcopenshell.util.date.ifc2datetime(data[attribute]).isoformat()
|
||||||
|
if data["ElectronicFormat"]:
|
||||||
|
data["ElectronicFormat"] = "{}/{}".format(
|
||||||
|
information.ElectronicFormat.MimeContentType, information.ElectronicFormat.MimeSubtype
|
||||||
|
)
|
||||||
|
cls.information[information.id()] = data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_references(cls):
|
||||||
|
cls.references = {}
|
||||||
|
for reference in cls._file.by_type("IfcDocumentReference"):
|
||||||
|
data = reference.get_info()
|
||||||
|
if cls._file.schema == "IFC2X3":
|
||||||
|
if reference.ReferenceToDocument:
|
||||||
|
data["ReferencedDocument"] = reference.ReferenceToDocument[0].id()
|
||||||
|
elif reference.ReferencedDocument:
|
||||||
|
data["ReferencedDocument"] = reference.ReferencedDocument.id()
|
||||||
|
cls.references[reference.id()] = data
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, settings=None):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {
|
||||||
|
"information": None,
|
||||||
|
"attributes": {}
|
||||||
|
}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
for name, value in self.settings["attributes"].items():
|
||||||
|
setattr(self.settings["information"], name, value)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, settings=None):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {
|
||||||
|
"reference": None,
|
||||||
|
"attributes": {}
|
||||||
|
}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
for name, value in self.settings["attributes"].items():
|
||||||
|
setattr(self.settings["reference"], name, value)
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
import bpy
|
||||||
|
import json
|
||||||
|
import blenderbim.bim.module.document.add_information as add_information
|
||||||
|
import blenderbim.bim.module.document.add_reference as add_reference
|
||||||
|
import blenderbim.bim.module.document.edit_information as edit_information
|
||||||
|
import blenderbim.bim.module.document.edit_reference as edit_reference
|
||||||
|
import blenderbim.bim.module.document.remove_document as remove_document
|
||||||
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
from blenderbim.bim.module.document.data import Data
|
||||||
|
|
||||||
|
|
||||||
|
class LoadInformation(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.load_information"
|
||||||
|
bl_label = "Load Information"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
while len(props.documents) > 0:
|
||||||
|
props.documents.remove(0)
|
||||||
|
for information_id, information in Data.information.items():
|
||||||
|
new = props.documents.add()
|
||||||
|
new.name = information["Name"] or "Unnamed"
|
||||||
|
new.identification = information["Identification"] or "*"
|
||||||
|
new.ifc_definition_id = information_id
|
||||||
|
props.is_editing = "information"
|
||||||
|
bpy.ops.bim.disable_editing_document()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class LoadDocumentReferences(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.load_document_references"
|
||||||
|
bl_label = "Load Document References"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
while len(props.documents) > 0:
|
||||||
|
props.documents.remove(0)
|
||||||
|
for reference_id, reference in Data.references.items():
|
||||||
|
new = props.documents.add()
|
||||||
|
new.name = reference["Name"] or "Unnamed"
|
||||||
|
new.identification = reference["Identification"] or "*"
|
||||||
|
new.ifc_definition_id = reference_id
|
||||||
|
props.is_editing = "reference"
|
||||||
|
bpy.ops.bim.disable_editing_document()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class DisableDocumentEditingUI(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.disable_document_editing_ui"
|
||||||
|
bl_label = "Disable Document Editing UI"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
context.scene.BIMDocumentProperties.is_editing = ""
|
||||||
|
bpy.ops.bim.disable_editing_document()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class EnableEditingDocument(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.enable_editing_document"
|
||||||
|
bl_label = "Enable Editing Document"
|
||||||
|
document: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
while len(props.document_attributes) > 0:
|
||||||
|
props.document_attributes.remove(0)
|
||||||
|
|
||||||
|
if props.is_editing == "information":
|
||||||
|
data = Data.information[self.document]
|
||||||
|
ifc_class = "IfcDocumentInformation"
|
||||||
|
elif props.is_editing == "reference":
|
||||||
|
data = Data.references[self.document]
|
||||||
|
ifc_class = "IfcDocumentReference"
|
||||||
|
|
||||||
|
for attribute in IfcStore.get_schema().declaration_by_name(ifc_class).all_attributes():
|
||||||
|
data_type = str(attribute.type_of_attribute)
|
||||||
|
if "<entity" in data_type:
|
||||||
|
continue
|
||||||
|
new = props.document_attributes.add()
|
||||||
|
new.name = attribute.name()
|
||||||
|
new.is_null = data[attribute.name()] is None
|
||||||
|
new.is_optional = attribute.optional()
|
||||||
|
if "<string>" in data_type:
|
||||||
|
new.string_value = "" if new.is_null else data[attribute.name()]
|
||||||
|
new.data_type = "string"
|
||||||
|
elif "<enumeration" in data_type:
|
||||||
|
new.enum_items = json.dumps(attribute.type_of_attribute().declared_type().enumeration_items())
|
||||||
|
new.data_type = "enum"
|
||||||
|
if data[attribute.name()]:
|
||||||
|
new.enum_value = data[attribute.name()]
|
||||||
|
props.active_document_id = self.document
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class DisableEditingDocument(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.disable_editing_document"
|
||||||
|
bl_label = "Disable Editing Document"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
context.scene.BIMDocumentProperties.active_document_id = 0
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddInformation(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_information"
|
||||||
|
bl_label = "Add Information"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
result = add_information.Usecase(IfcStore.get_file()).execute()
|
||||||
|
Data.load()
|
||||||
|
bpy.ops.bim.load_information()
|
||||||
|
bpy.ops.bim.enable_editing_document(document=result.id())
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddDocumentReference(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_document_reference"
|
||||||
|
bl_label = "Add Document Reference"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
result = add_reference.Usecase(IfcStore.get_file()).execute()
|
||||||
|
Data.load()
|
||||||
|
bpy.ops.bim.load_document_references()
|
||||||
|
bpy.ops.bim.enable_editing_document(document=result.id())
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class EditInformation(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.edit_information"
|
||||||
|
bl_label = "Edit Information"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
attributes = {}
|
||||||
|
for attribute in props.document_attributes:
|
||||||
|
if attribute.is_null:
|
||||||
|
attributes[attribute.name] = None
|
||||||
|
elif attribute.enum_items:
|
||||||
|
attributes[attribute.name] = attribute.enum_value
|
||||||
|
else:
|
||||||
|
attributes[attribute.name] = attribute.string_value
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
edit_information.Usecase(
|
||||||
|
self.file, {"information": self.file.by_id(props.active_document_id), "attributes": attributes}
|
||||||
|
).execute()
|
||||||
|
Data.load()
|
||||||
|
bpy.ops.bim.load_information()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class EditDocumentReference(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.edit_document_reference"
|
||||||
|
bl_label = "Edit Document Reference"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
attributes = {}
|
||||||
|
for attribute in props.document_attributes:
|
||||||
|
if attribute.is_null:
|
||||||
|
attributes[attribute.name] = None
|
||||||
|
else:
|
||||||
|
attributes[attribute.name] = attribute.string_value
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
edit_reference.Usecase(
|
||||||
|
self.file, {"reference": self.file.by_id(props.active_document_id), "attributes": attributes}
|
||||||
|
).execute()
|
||||||
|
Data.load()
|
||||||
|
bpy.ops.bim.load_document_references()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveDocument(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.remove_document"
|
||||||
|
bl_label = "Remove Document"
|
||||||
|
document: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.BIMDocumentProperties
|
||||||
|
self.file = IfcStore.get_file()
|
||||||
|
remove_document.Usecase(self.file, {"document": self.file.by_id(self.document)}).execute()
|
||||||
|
Data.load()
|
||||||
|
if props.is_editing == "information":
|
||||||
|
bpy.ops.bim.load_information()
|
||||||
|
elif props.is_editing == "reference":
|
||||||
|
bpy.ops.bim.load_document_references()
|
||||||
|
return {"FINISHED"}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import bpy
|
||||||
|
from blenderbim.bim.prop import StrProperty, Attribute
|
||||||
|
from bpy.types import PropertyGroup
|
||||||
|
from bpy.props import (
|
||||||
|
PointerProperty,
|
||||||
|
StringProperty,
|
||||||
|
EnumProperty,
|
||||||
|
BoolProperty,
|
||||||
|
IntProperty,
|
||||||
|
FloatProperty,
|
||||||
|
FloatVectorProperty,
|
||||||
|
CollectionProperty,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Document(PropertyGroup):
|
||||||
|
name: StringProperty(name="Name")
|
||||||
|
identification: StringProperty(name="Identification")
|
||||||
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
|
|
||||||
|
|
||||||
|
class BIMDocumentProperties(PropertyGroup):
|
||||||
|
document_attributes: CollectionProperty(name="Document Attributes", type=Attribute)
|
||||||
|
active_document_id: IntProperty(name="Active Document Id")
|
||||||
|
documents: CollectionProperty(name="Documents", type=Document)
|
||||||
|
active_document_index: IntProperty(name="Active Document Index")
|
||||||
|
is_editing: StringProperty(name="Is Editing")
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, settings=None):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {"document": None}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
self.file.remove(self.settings["document"])
|
||||||
|
for rel in self.file.by_type("IfcRelAssociatesDocument"):
|
||||||
|
if not rel.RelatingDocument:
|
||||||
|
self.file.remove(rel)
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
from bpy.types import Panel, UIList
|
||||||
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
from blenderbim.bim.module.document.data import Data
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_documents(Panel):
|
||||||
|
bl_label = "IFC Documents"
|
||||||
|
bl_idname = "BIM_PT_documents"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "scene"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return IfcStore.get_file()
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
if not Data.is_loaded:
|
||||||
|
Data.load()
|
||||||
|
|
||||||
|
self.props = context.scene.BIMDocumentProperties
|
||||||
|
|
||||||
|
if not self.props.is_editing or self.props.is_editing == "information":
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text="{} Documents Found".format(len(Data.information)))
|
||||||
|
if self.props.is_editing == "information":
|
||||||
|
row.operator("bim.disable_document_editing_ui", text="", icon="CHECKMARK")
|
||||||
|
row.operator("bim.add_information", text="", icon="ADD")
|
||||||
|
else:
|
||||||
|
row.operator("bim.load_information", text="", icon="GREASEPENCIL")
|
||||||
|
|
||||||
|
if not self.props.is_editing or self.props.is_editing == "reference":
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text="{} References Found".format(len(Data.references)))
|
||||||
|
if self.props.is_editing == "reference":
|
||||||
|
row.operator("bim.disable_document_editing_ui", text="", icon="CHECKMARK")
|
||||||
|
row.operator("bim.add_document_reference", text="", icon="ADD")
|
||||||
|
else:
|
||||||
|
row.operator("bim.load_document_references", text="", icon="GREASEPENCIL")
|
||||||
|
|
||||||
|
if self.props.is_editing:
|
||||||
|
self.layout.template_list(
|
||||||
|
"BIM_UL_documents",
|
||||||
|
"",
|
||||||
|
self.props,
|
||||||
|
"documents",
|
||||||
|
self.props,
|
||||||
|
"active_document_index",
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.props.active_document_id:
|
||||||
|
self.draw_editable_ui(context)
|
||||||
|
return
|
||||||
|
|
||||||
|
def draw_editable_ui(self, context):
|
||||||
|
for attribute in self.props.document_attributes:
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
if attribute.data_type == "string":
|
||||||
|
row.prop(attribute, "string_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "enum":
|
||||||
|
row.prop(attribute, "enum_value", text=attribute.name)
|
||||||
|
if attribute.is_optional:
|
||||||
|
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_UL_documents(UIList):
|
||||||
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
|
if item:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text=item.identification)
|
||||||
|
row.label(text=item.name)
|
||||||
|
if context.scene.BIMDocumentProperties.active_document_id == item.ifc_definition_id:
|
||||||
|
if context.scene.BIMDocumentProperties.is_editing == "information":
|
||||||
|
row.operator("bim.edit_information", text="", icon="CHECKMARK")
|
||||||
|
elif context.scene.BIMDocumentProperties.is_editing == "reference":
|
||||||
|
row.operator("bim.edit_document_reference", text="", icon="CHECKMARK")
|
||||||
|
row.operator("bim.disable_editing_document", text="", icon="X")
|
||||||
|
elif context.scene.BIMDocumentProperties.active_document_id:
|
||||||
|
row.operator("bim.remove_document", text="", icon="X").document = item.ifc_definition_id
|
||||||
|
else:
|
||||||
|
op = row.operator("bim.enable_editing_document", text="", icon="GREASEPENCIL")
|
||||||
|
op.document = item.ifc_definition_id
|
||||||
|
row.operator("bim.remove_document", text="", icon="X").document = item.ifc_definition_id
|
||||||
@@ -442,111 +442,6 @@ class RemoveObjectConstraint(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class AddDocumentInformation(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.add_document_information"
|
|
||||||
bl_label = "Add Document Information"
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
info = bpy.context.scene.BIMProperties.document_information.add()
|
|
||||||
info.name = "New Document ID"
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveDocumentInformation(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.remove_document_information"
|
|
||||||
bl_label = "Remove Document Information"
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.scene.BIMProperties.document_information.remove(self.index)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class AssignDocumentInformation(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.assign_document_information"
|
|
||||||
bl_label = "Assign Document Information"
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
reference = bpy.context.scene.BIMProperties.document_references[self.index]
|
|
||||||
index = bpy.context.scene.BIMProperties.active_document_information_index
|
|
||||||
info = bpy.context.scene.BIMProperties.document_information
|
|
||||||
if index < len(info):
|
|
||||||
reference.referenced_document = info[index].name
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class AddDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.add_document_reference"
|
|
||||||
bl_label = "Add Document Reference"
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
document = bpy.context.scene.BIMProperties.document_references.add()
|
|
||||||
document.name = "New Document Reference ID"
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.remove_document_reference"
|
|
||||||
bl_label = "Remove Document Reference"
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.scene.BIMProperties.document_references.remove(self.index)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveObjectDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.remove_object_document_reference"
|
|
||||||
bl_label = "Remove Object Document Reference"
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.active_object.BIMObjectProperties.document_references.remove(self.index)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class AssignDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.assign_document_reference"
|
|
||||||
bl_label = "Assign Document Reference"
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
identification = bpy.context.scene.BIMProperties.document_references[
|
|
||||||
bpy.context.scene.BIMProperties.active_document_reference_index
|
|
||||||
].name
|
|
||||||
for obj in bpy.context.selected_objects:
|
|
||||||
if obj.BIMObjectProperties.document_references.get(identification):
|
|
||||||
continue
|
|
||||||
reference = obj.BIMObjectProperties.document_references.add()
|
|
||||||
reference.name = identification
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class UnassignDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.unassign_document_reference"
|
|
||||||
bl_label = "Unassign Document Reference"
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
identification = bpy.context.scene.BIMProperties.document_references[
|
|
||||||
bpy.context.scene.BIMProperties.active_document_reference_index
|
|
||||||
].name
|
|
||||||
for obj in bpy.context.selected_objects:
|
|
||||||
index = obj.BIMObjectProperties.document_references.find(identification)
|
|
||||||
if index >= 0:
|
|
||||||
obj.BIMObjectProperties.document_references.remove(index)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveObjectDocumentReference(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.remove_object_document_reference"
|
|
||||||
bl_label = "Remove Object Document Reference"
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.active_object.BIMObjectProperties.document_references.remove(self.index)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class GenerateGlobalId(bpy.types.Operator):
|
class GenerateGlobalId(bpy.types.Operator):
|
||||||
bl_idname = "bim.generate_global_id"
|
bl_idname = "bim.generate_global_id"
|
||||||
bl_label = "Regenerate GlobalId"
|
bl_label = "Regenerate GlobalId"
|
||||||
|
|||||||
@@ -557,57 +557,6 @@ class BIMTextProperties(PropertyGroup):
|
|||||||
variables: CollectionProperty(name="Variables", type=Variable)
|
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",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentReference(PropertyGroup):
|
|
||||||
location: StringProperty(name="Location")
|
|
||||||
name: StringProperty(name="Identification")
|
|
||||||
human_name: StringProperty(name="Name")
|
|
||||||
description: StringProperty(name="Description")
|
|
||||||
referenced_document: StringProperty(name="Referenced Document")
|
|
||||||
|
|
||||||
|
|
||||||
class ClashSource(PropertyGroup):
|
class ClashSource(PropertyGroup):
|
||||||
name: StringProperty(name="File")
|
name: StringProperty(name="File")
|
||||||
selector: StringProperty(name="Selector")
|
selector: StringProperty(name="Selector")
|
||||||
@@ -975,10 +924,6 @@ class BIMProperties(PropertyGroup):
|
|||||||
name="Import Filter",
|
name="Import Filter",
|
||||||
)
|
)
|
||||||
ifc_selector: StringProperty(default="", name="IFC Selector")
|
ifc_selector: StringProperty(default="", name="IFC Selector")
|
||||||
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")
|
|
||||||
blender_clash_set_a: CollectionProperty(name="Blender Clash Set A", type=StrProperty)
|
blender_clash_set_a: CollectionProperty(name="Blender Clash Set A", type=StrProperty)
|
||||||
blender_clash_set_b: CollectionProperty(name="Blender Clash Set B", type=StrProperty)
|
blender_clash_set_b: CollectionProperty(name="Blender Clash Set B", type=StrProperty)
|
||||||
clash_sets: CollectionProperty(name="Clash Sets", type=ClashSet)
|
clash_sets: CollectionProperty(name="Clash Sets", type=ClashSet)
|
||||||
@@ -1094,8 +1039,6 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
relating_structure: PointerProperty(name="Spatial Container", type=bpy.types.Object)
|
relating_structure: PointerProperty(name="Spatial Container", type=bpy.types.Object)
|
||||||
psets: CollectionProperty(name="Psets", type=PsetQto)
|
psets: CollectionProperty(name="Psets", type=PsetQto)
|
||||||
qtos: CollectionProperty(name="Qtos", type=PsetQto)
|
qtos: CollectionProperty(name="Qtos", type=PsetQto)
|
||||||
document_references: CollectionProperty(name="Document References", type=DocumentReference)
|
|
||||||
active_document_reference_index: IntProperty(name="Active Document Reference Index")
|
|
||||||
constraints: CollectionProperty(name="Constraints", type=Constraint)
|
constraints: CollectionProperty(name="Constraints", type=Constraint)
|
||||||
active_constraint_index: IntProperty(name="Active Constraint Index")
|
active_constraint_index: IntProperty(name="Active Constraint Index")
|
||||||
has_boundary_condition: BoolProperty(name="Has Boundary Condition")
|
has_boundary_condition: BoolProperty(name="Has Boundary Condition")
|
||||||
|
|||||||
@@ -37,100 +37,6 @@ class BIM_PT_object_structural(Panel):
|
|||||||
row.prop(props, "structural_member_connection")
|
row.prop(props, "structural_member_connection")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_document_information(Panel):
|
|
||||||
bl_label = "IFC Documents"
|
|
||||||
bl_idname = "BIM_PT_document_information"
|
|
||||||
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
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.operator("bim.add_document_information")
|
|
||||||
|
|
||||||
if props.document_information:
|
|
||||||
layout.template_list(
|
|
||||||
"BIM_UL_document_information",
|
|
||||||
"",
|
|
||||||
props,
|
|
||||||
"document_information",
|
|
||||||
props,
|
|
||||||
"active_document_information_index",
|
|
||||||
)
|
|
||||||
|
|
||||||
if props.active_document_information_index < len(props.document_information):
|
|
||||||
information = props.document_information[props.active_document_information_index]
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.prop(information, "name")
|
|
||||||
row.operator(
|
|
||||||
"bim.remove_document_information", icon="X", text=""
|
|
||||||
).index = props.active_document_information_index
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "human_name")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "description")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "location")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "purpose")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "intended_use")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "scope")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "revision")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "creation_time")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "last_revision_time")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "electronic_format")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "valid_from")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "valid_until")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "confidentiality")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(information, "status")
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.operator("bim.add_document_reference")
|
|
||||||
|
|
||||||
if props.document_references:
|
|
||||||
layout.template_list(
|
|
||||||
"BIM_UL_document_references", "", props, "document_references", props, "active_document_reference_index"
|
|
||||||
)
|
|
||||||
|
|
||||||
if props.active_document_reference_index < len(props.document_references):
|
|
||||||
reference = props.document_references[props.active_document_reference_index]
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.prop(reference, "name")
|
|
||||||
row.operator(
|
|
||||||
"bim.remove_document_reference", icon="X", text=""
|
|
||||||
).index = props.active_document_reference_index
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "human_name")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "location")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "description")
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.prop(reference, "referenced_document")
|
|
||||||
row.operator(
|
|
||||||
"bim.assign_document_information", icon="LINKED", text=""
|
|
||||||
).index = props.active_document_reference_index
|
|
||||||
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.operator("bim.assign_document_reference", text="Assign Reference")
|
|
||||||
row.operator("bim.unassign_document_reference", text="Unassign Reference")
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_constraints(Panel):
|
class BIM_PT_constraints(Panel):
|
||||||
bl_label = "IFC Constraints"
|
bl_label = "IFC Constraints"
|
||||||
bl_idname = "BIM_PT_constraints"
|
bl_idname = "BIM_PT_constraints"
|
||||||
@@ -175,51 +81,6 @@ class BIM_PT_constraints(Panel):
|
|||||||
row.operator("bim.unassign_constraint", text="Unassign Constraint")
|
row.operator("bim.unassign_constraint", text="Unassign Constraint")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_documents(Panel):
|
|
||||||
bl_label = "IFC Documents"
|
|
||||||
bl_idname = "BIM_PT_documents"
|
|
||||||
bl_options = {"DEFAULT_CLOSED"}
|
|
||||||
bl_space_type = "PROPERTIES"
|
|
||||||
bl_region_type = "WINDOW"
|
|
||||||
bl_context = "object"
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.use_property_split = True
|
|
||||||
props = context.active_object.BIMObjectProperties
|
|
||||||
|
|
||||||
if not props.document_references:
|
|
||||||
layout.label(text="No documents found")
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.operator("bim.fetch_object_passport")
|
|
||||||
|
|
||||||
if props.document_references:
|
|
||||||
layout.template_list(
|
|
||||||
"BIM_UL_document_references", "", props, "document_references", props, "active_document_reference_index"
|
|
||||||
)
|
|
||||||
|
|
||||||
if props.active_document_reference_index < len(props.document_references):
|
|
||||||
reference = props.document_references[props.active_document_reference_index]
|
|
||||||
row = layout.row(align=True)
|
|
||||||
row.prop(reference, "name")
|
|
||||||
if reference.name in bpy.context.scene.BIMProperties.document_references:
|
|
||||||
reference = bpy.context.scene.BIMProperties.document_references[reference.name]
|
|
||||||
row.operator(
|
|
||||||
"bim.remove_object_document_reference", icon="X", text=""
|
|
||||||
).index = props.active_document_reference_index
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "human_name")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "location")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "description")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(reference, "referenced_document")
|
|
||||||
else:
|
|
||||||
layout.label(text="Reference is invalid")
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_constraint_relations(Panel):
|
class BIM_PT_constraint_relations(Panel):
|
||||||
bl_label = "IFC Constraints"
|
bl_label = "IFC Constraints"
|
||||||
bl_idname = "BIM_PT_constraint_relations"
|
bl_idname = "BIM_PT_constraint_relations"
|
||||||
@@ -911,24 +772,6 @@ class BIM_UL_constraints(bpy.types.UIList):
|
|||||||
layout.label(text="", translate=False)
|
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
|
|
||||||
if item:
|
|
||||||
layout.prop(item, "name", text="", emboss=False)
|
|
||||||
else:
|
|
||||||
layout.label(text="", translate=False)
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_document_references(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_ADDON_preferences(bpy.types.AddonPreferences):
|
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||||
bl_idname = "blenderbim"
|
bl_idname = "blenderbim"
|
||||||
svg2pdf_command: StringProperty(name="SVG to PDF Command", description="E.g. [['inkscape', svg, '-o', pdf]]")
|
svg2pdf_command: StringProperty(name="SVG to PDF Command", description="E.g. [['inkscape', svg, '-o', pdf]]")
|
||||||
|
|||||||
Reference in New Issue
Block a user