mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
refactor using row in uy and util.classification.get_classifiation(reference)
This commit is contained in:
@@ -104,17 +104,7 @@ class ReferencesData:
|
|||||||
if element:
|
if element:
|
||||||
for reference in ifcopenshell.util.classification.get_references(element):
|
for reference in ifcopenshell.util.classification.get_references(element):
|
||||||
data = reference.get_info()
|
data = reference.get_info()
|
||||||
|
data["ifcClassificationReference"] = reference
|
||||||
if reference.ReferencedSource:
|
|
||||||
if reference.ReferencedSource.is_a("IfcClassification"):
|
|
||||||
data["ClassificationSystemName"] = reference.ReferencedSource.Name
|
|
||||||
elif reference.ReferencedSource.is_a("IfcClassificationReference"):
|
|
||||||
current = reference.ReferencedSource
|
|
||||||
while current.ReferencedSource and current.ReferencedSource.is_a("IfcClassificationReference"):
|
|
||||||
current = current.ReferencedSource
|
|
||||||
if current.ReferencedSource and current.ReferencedSource.is_a("IfcClassification"):
|
|
||||||
data["ClassificationSystemName"] = current.ReferencedSource.Name
|
|
||||||
|
|
||||||
del data["ReferencedSource"]
|
del data["ReferencedSource"]
|
||||||
results.append(data)
|
results.append(data)
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import bpy
|
|||||||
import bonsai.bim.helper
|
import bonsai.bim.helper
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
import bonsai.bim.module.classification.prop as classification_prop
|
import bonsai.bim.module.classification.prop as classification_prop
|
||||||
|
import ifcopenshell.util.classification
|
||||||
|
|
||||||
from bpy.types import Panel, UIList
|
from bpy.types import Panel, UIList
|
||||||
from bonsai.bim.module.classification.data import (
|
from bonsai.bim.module.classification.data import (
|
||||||
ClassificationsData,
|
ClassificationsData,
|
||||||
@@ -253,33 +255,28 @@ class ReferenceUI:
|
|||||||
def draw_reference_ui(self, reference: dict[str, Any]) -> None:
|
def draw_reference_ui(self, reference: dict[str, Any]) -> None:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
|
|
||||||
split = row.split(factor=0.3)
|
classification_entity = ifcopenshell.util.classification.get_classification(
|
||||||
col1 = split.column()
|
reference["ifcClassificationReference"]
|
||||||
split = split.split(factor=0.3)
|
)
|
||||||
col2 = split.column()
|
classification_name = classification_entity.Name if classification_entity else ""
|
||||||
split = split.split(factor=0.7)
|
row.label(text=classification_name, icon="OUTLINER_COLLECTION")
|
||||||
col3 = split.column()
|
|
||||||
col4 = split.column()
|
|
||||||
|
|
||||||
if reference.get("ClassificationSystemName"):
|
|
||||||
col1.label(text=reference["ClassificationSystemName"], icon="OUTLINER_COLLECTION")
|
|
||||||
else:
|
|
||||||
col1.label(text="")
|
|
||||||
|
|
||||||
if self.file.schema == "IFC2X3":
|
if self.file.schema == "IFC2X3":
|
||||||
name = reference["ItemReference"] or "No Identification"
|
name = reference["ItemReference"] or "No Identification"
|
||||||
else:
|
else:
|
||||||
name = reference["Identification"] or "No Identification"
|
name = reference["Identification"] or "No Identification"
|
||||||
col2.label(text=name, icon="ASSET_MANAGER")
|
row.label(text=name, icon="ASSET_MANAGER")
|
||||||
col3.label(text=reference["Name"] or "")
|
|
||||||
|
|
||||||
button_row = col4.row(align=True)
|
# Name
|
||||||
|
row.label(text=reference.get("Name") or "")
|
||||||
|
|
||||||
|
# Buttons
|
||||||
if reference["Location"]:
|
if reference["Location"]:
|
||||||
button_row.operator("bim.open_uri", icon="URL", text="").uri = reference["Location"]
|
row.operator("bim.open_uri", icon="URL", text="").uri = reference["Location"]
|
||||||
if not self.props.active_reference_id:
|
if not self.props.active_reference_id:
|
||||||
op = button_row.operator("bim.enable_editing_classification_reference", text="", icon="GREASEPENCIL")
|
op = row.operator("bim.enable_editing_classification_reference", text="", icon="GREASEPENCIL")
|
||||||
op.reference = reference["id"]
|
op.reference = reference["id"]
|
||||||
op = button_row.operator("bim.remove_classification_reference", text="", icon="X")
|
op = row.operator("bim.remove_classification_reference", text="", icon="X")
|
||||||
op.reference = reference["id"]
|
op.reference = reference["id"]
|
||||||
op.obj = self.obj
|
op.obj = self.obj
|
||||||
op.obj_type = self.data.obj_type
|
op.obj_type = self.data.obj_type
|
||||||
|
|||||||
Reference in New Issue
Block a user