mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Owner UI - further decouple data.py from Blender entities
This commit is contained in:
@@ -144,30 +144,28 @@ class OwnerData:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"user_person": cls.get_user_person(),
|
"user_person": cls.user_person(),
|
||||||
"user_organisation": cls.get_user_organisation(),
|
"user_organisation": cls.user_organisation(),
|
||||||
"users": cls.get_users(),
|
"users": cls.users(),
|
||||||
}
|
}
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_user_person(cls) -> tool.Blender.BLENDER_ENUM_ITEMS:
|
def user_person(cls) -> tool.Blender.BLENDER_ENUM_ITEMS:
|
||||||
return [(str(p.id()), p[0] or "Unnamed", "") for p in tool.Ifc.get().by_type("IfcPerson")]
|
return [(str(p.id()), p[0] or "Unnamed", "") for p in tool.Ifc.get().by_type("IfcPerson")]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_user_organisation(cls) -> tool.Blender.BLENDER_ENUM_ITEMS:
|
def user_organisation(cls) -> tool.Blender.BLENDER_ENUM_ITEMS:
|
||||||
return [(str(p.id()), p[0] or "Unnamed", "") for p in tool.Ifc.get().by_type("IfcOrganization")]
|
return [(str(p.id()), p[0] or "Unnamed", "") for p in tool.Ifc.get().by_type("IfcOrganization")]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_users(cls) -> list[dict[str, Any]]:
|
def users(cls) -> list[dict[str, Any]]:
|
||||||
props = tool.Owner.get_owner_props()
|
|
||||||
results: list[dict[str, Any]] = []
|
results: list[dict[str, Any]] = []
|
||||||
for user in tool.Ifc.get().by_type("IfcPersonAndOrganization"):
|
for user in tool.Ifc.get().by_type("IfcPersonAndOrganization"):
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"id": user.id(),
|
"id": user.id(),
|
||||||
"label": "{} ({})".format(user.ThePerson[0] or "Unnamed", user.TheOrganization[0] or "Unnamed"),
|
"label": "{} ({})".format(user.ThePerson[0] or "Unnamed", user.TheOrganization[0] or "Unnamed"),
|
||||||
"is_active": props.active_user_id == user.id(),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ class BIM_PT_owner(bpy.types.Panel):
|
|||||||
|
|
||||||
for user in OwnerData.data["users"]:
|
for user in OwnerData.data["users"]:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if user["is_active"]:
|
if props.active_user_id == user["id"]:
|
||||||
row.label(text=user["label"], icon="USER")
|
row.label(text=user["label"], icon="USER")
|
||||||
row.operator("bim.clear_user", icon="KEYFRAME", text="").user = user["id"]
|
row.operator("bim.clear_user", icon="KEYFRAME", text="").user = user["id"]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user