mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +00:00
WIP finish refactoring owner module props. See #1222.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from . import ui, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.EnableEditingPerson,
|
operator.EnableEditingPerson,
|
||||||
@@ -22,6 +22,11 @@ classes = (
|
|||||||
operator.AddAddress,
|
operator.AddAddress,
|
||||||
operator.EditAddress,
|
operator.EditAddress,
|
||||||
operator.RemoveAddress,
|
operator.RemoveAddress,
|
||||||
|
prop.Role,
|
||||||
|
prop.Address,
|
||||||
|
prop.Person,
|
||||||
|
prop.Organisation,
|
||||||
|
prop.BIMOwnerProperties,
|
||||||
ui.BIM_PT_people,
|
ui.BIM_PT_people,
|
||||||
ui.BIM_PT_organisations,
|
ui.BIM_PT_organisations,
|
||||||
ui.BIM_PT_owner,
|
ui.BIM_PT_owner,
|
||||||
@@ -29,8 +34,8 @@ classes = (
|
|||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
pass
|
bpy.types.Scene.BIMOwnerProperties = bpy.props.PointerProperty(type=prop.BIMOwnerProperties)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
pass
|
del bpy.types.Scene.BIMOwnerProperties
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ class Data:
|
|||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
cls.people = {}
|
cls.people = {}
|
||||||
|
cls.organisations = {}
|
||||||
|
cls.addresses = {}
|
||||||
|
cls.roles = {}
|
||||||
for person in file.by_type("IfcPerson"):
|
for person in file.by_type("IfcPerson"):
|
||||||
data = person.get_info()
|
data = person.get_info()
|
||||||
data["is_engaged"] = bool(person.EngagedIn)
|
data["is_engaged"] = bool(person.EngagedIn)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class EnableEditingPerson(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
props.active_person_id = self.person_id
|
props.active_person_id = self.person_id
|
||||||
data = Data.people[self.person_id]
|
data = Data.people[self.person_id]
|
||||||
name = data["Id"] if self.file.schema == "IFC2X3" else data["Identification"]
|
name = data["Id"] if self.file.schema == "IFC2X3" else data["Identification"]
|
||||||
@@ -41,7 +41,7 @@ class DisableEditingPerson(bpy.types.Operator):
|
|||||||
bl_label = "Disable Editing Person"
|
bl_label = "Disable Editing Person"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.scene.BIMProperties.active_person_id = 0
|
context.scene.BIMOwnerProperties.active_person_id = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class EditPerson(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
attributes = {
|
attributes = {
|
||||||
"Identification": props.person.name or None,
|
"Identification": props.person.name or None,
|
||||||
"FamilyName": props.person.family_name or None,
|
"FamilyName": props.person.family_name or None,
|
||||||
@@ -100,7 +100,7 @@ class EnableEditingRole(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
props.active_role_id = self.role_id
|
props.active_role_id = self.role_id
|
||||||
data = Data.roles[self.role_id]
|
data = Data.roles[self.role_id]
|
||||||
props.role.name = data["Role"]
|
props.role.name = data["Role"]
|
||||||
@@ -114,7 +114,7 @@ class DisableEditingRole(bpy.types.Operator):
|
|||||||
bl_label = "Disable Editing Role"
|
bl_label = "Disable Editing Role"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.scene.BIMProperties.active_role_id = 0
|
context.scene.BIMOwnerProperties.active_role_id = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ class EditRole(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
attributes = {
|
attributes = {
|
||||||
"Role": props.role.name,
|
"Role": props.role.name,
|
||||||
"UserDefinedRole": props.role.user_defined_role if props.role.name == "USERDEFINED" else None,
|
"UserDefinedRole": props.role.user_defined_role if props.role.name == "USERDEFINED" else None,
|
||||||
@@ -184,7 +184,7 @@ class EnableEditingAddress(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
props.active_address_id = self.address_id
|
props.active_address_id = self.address_id
|
||||||
data = Data.addresses[self.address_id]
|
data = Data.addresses[self.address_id]
|
||||||
props.address.name = data["type"]
|
props.address.name = data["type"]
|
||||||
@@ -218,7 +218,7 @@ class DisableEditingAddress(bpy.types.Operator):
|
|||||||
bl_label = "Disable Editing Address"
|
bl_label = "Disable Editing Address"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.scene.BIMProperties.active_address_id = 0
|
context.scene.BIMOwnerProperties.active_address_id = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ class EditAddress(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
attributes = {
|
attributes = {
|
||||||
"Purpose": props.address.purpose,
|
"Purpose": props.address.purpose,
|
||||||
"UserDefinedPurpose": props.address.user_defined_purpose
|
"UserDefinedPurpose": props.address.user_defined_purpose
|
||||||
@@ -291,7 +291,7 @@ class EnableEditingOrganisation(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
props.active_organisation_id = self.organisation_id
|
props.active_organisation_id = self.organisation_id
|
||||||
data = Data.organisations[self.organisation_id]
|
data = Data.organisations[self.organisation_id]
|
||||||
identification = data["Id"] if self.file.schema == "IFC2X3" else data["Identification"]
|
identification = data["Id"] if self.file.schema == "IFC2X3" else data["Identification"]
|
||||||
@@ -306,7 +306,7 @@ class DisableEditingOrganisation(bpy.types.Operator):
|
|||||||
bl_label = "Disable Editing Organisation"
|
bl_label = "Disable Editing Organisation"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.scene.BIMProperties.active_organisation_id = 0
|
context.scene.BIMOwnerProperties.active_organisation_id = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ class EditOrganisation(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
attributes = {
|
attributes = {
|
||||||
"Identification": props.organisation.identification or None,
|
"Identification": props.organisation.identification or None,
|
||||||
"Name": props.organisation.name,
|
"Name": props.organisation.name,
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
import bpy
|
||||||
|
from blenderbim.bim.prop import StrProperty, Attribute
|
||||||
|
from blenderbim.bim.module.owner.data import Data
|
||||||
|
from bpy.types import PropertyGroup
|
||||||
|
from bpy.props import (
|
||||||
|
PointerProperty,
|
||||||
|
StringProperty,
|
||||||
|
EnumProperty,
|
||||||
|
BoolProperty,
|
||||||
|
IntProperty,
|
||||||
|
FloatProperty,
|
||||||
|
FloatVectorProperty,
|
||||||
|
CollectionProperty,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def getPersons(self, context):
|
||||||
|
if not Data.is_loaded:
|
||||||
|
Data.load()
|
||||||
|
results = []
|
||||||
|
for ifc_id, person in Data.people.items():
|
||||||
|
if "Id" in person:
|
||||||
|
identifier = person["Id"] or ""
|
||||||
|
else:
|
||||||
|
identifier = person["Identifier"] or ""
|
||||||
|
results.append((str(ifc_id), identifier, ""))
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def getOrganisations(self, context):
|
||||||
|
if not Data.is_loaded:
|
||||||
|
Data.load()
|
||||||
|
results = []
|
||||||
|
for ifc_id, organisation in Data.organisations.items():
|
||||||
|
results.append((str(ifc_id), organisation["Name"], ""))
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
class Address(PropertyGroup):
|
||||||
|
name: StringProperty(name="Name", default="IfcPostalAddress") # Stores IfcPostalAddress or IfcTelecomAddress
|
||||||
|
purpose: EnumProperty(
|
||||||
|
items=[
|
||||||
|
("None", "None", ""),
|
||||||
|
("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")
|
||||||
|
|
||||||
|
internal_location: StringProperty(name="Internal Location")
|
||||||
|
address_lines: StringProperty(name="Address")
|
||||||
|
postal_box: StringProperty(name="Postal Box")
|
||||||
|
town: StringProperty(name="Town")
|
||||||
|
region: StringProperty(name="Region")
|
||||||
|
postal_code: StringProperty(name="Postal Code")
|
||||||
|
country: StringProperty(name="Country")
|
||||||
|
|
||||||
|
telephone_numbers: StringProperty(name="Telephone Numbers")
|
||||||
|
facsimile_numbers: StringProperty(name="Facsimile Numbers")
|
||||||
|
pager_number: StringProperty(name="Pager Number")
|
||||||
|
electronic_mail_addresses: StringProperty(name="Emails")
|
||||||
|
www_home_page_url: StringProperty(name="Websites")
|
||||||
|
messaging_ids: StringProperty(name="IMs")
|
||||||
|
|
||||||
|
|
||||||
|
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",
|
||||||
|
)
|
||||||
|
user_defined_role: StringProperty(name="Custom Role")
|
||||||
|
description: StringProperty(name="Description")
|
||||||
|
|
||||||
|
|
||||||
|
class Organisation(PropertyGroup):
|
||||||
|
identification: StringProperty(name="Identification")
|
||||||
|
name: StringProperty(name="Name")
|
||||||
|
description: StringProperty(name="Description")
|
||||||
|
|
||||||
|
|
||||||
|
class Person(PropertyGroup):
|
||||||
|
name: StringProperty(name="Identification")
|
||||||
|
family_name: StringProperty(name="Family Name")
|
||||||
|
given_name: StringProperty(name="Given Name")
|
||||||
|
middle_names: StringProperty(name="Middle Names")
|
||||||
|
prefix_titles: StringProperty(name="Prefixes")
|
||||||
|
suffix_titles: StringProperty(name="Suffixes")
|
||||||
|
|
||||||
|
|
||||||
|
class BIMOwnerProperties(PropertyGroup):
|
||||||
|
person: PointerProperty(type=Person)
|
||||||
|
active_person_id: IntProperty(name="Active Person Id")
|
||||||
|
organisation: PointerProperty(type=Organisation)
|
||||||
|
active_organisation_id: IntProperty(name="Active Organisation Id")
|
||||||
|
role: PointerProperty(type=Role)
|
||||||
|
active_role_id: IntProperty(name="Active Role Id")
|
||||||
|
address: PointerProperty(type=Address)
|
||||||
|
active_address_id: IntProperty(name="Active Address Id")
|
||||||
|
user_person: EnumProperty(items=getPersons, name="Person")
|
||||||
|
user_organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
||||||
@@ -5,7 +5,7 @@ from blenderbim.bim.ifc import IfcStore
|
|||||||
|
|
||||||
|
|
||||||
def draw_roles_ui(box, assigned_object_id, roles):
|
def draw_roles_ui(box, assigned_object_id, roles):
|
||||||
props = bpy.context.scene.BIMProperties
|
props = bpy.context.scene.BIMOwnerProperties
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text="Roles")
|
row.label(text="Roles")
|
||||||
row.operator("bim.add_role", icon="ADD", text="").assigned_object_id = assigned_object_id
|
row.operator("bim.add_role", icon="ADD", text="").assigned_object_id = assigned_object_id
|
||||||
@@ -31,7 +31,7 @@ def draw_roles_ui(box, assigned_object_id, roles):
|
|||||||
|
|
||||||
|
|
||||||
def draw_addresses_ui(box, assigned_object_id, addresses, file):
|
def draw_addresses_ui(box, assigned_object_id, addresses, file):
|
||||||
props = bpy.context.scene.BIMProperties
|
props = bpy.context.scene.BIMOwnerProperties
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text="Addresses")
|
row.label(text="Addresses")
|
||||||
op = row.operator("bim.add_address", icon="LINK_BLEND", text="")
|
op = row.operator("bim.add_address", icon="LINK_BLEND", text="")
|
||||||
@@ -110,7 +110,7 @@ class BIM_PT_people(Panel):
|
|||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
self.layout.use_property_split = True
|
self.layout.use_property_split = True
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
|
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.operator("bim.add_person", icon="ADD")
|
row.operator("bim.add_person", icon="ADD")
|
||||||
@@ -169,7 +169,7 @@ class BIM_PT_organisations(Panel):
|
|||||||
|
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
self.layout.use_property_split = True
|
self.layout.use_property_split = True
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
|
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.operator("bim.add_organisation", icon="ADD")
|
row.operator("bim.add_organisation", icon="ADD")
|
||||||
@@ -216,7 +216,7 @@ class BIM_PT_owner(Panel):
|
|||||||
Data.load()
|
Data.load()
|
||||||
|
|
||||||
self.layout.use_property_split = True
|
self.layout.use_property_split = True
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMOwnerProperties
|
||||||
|
|
||||||
if not Data.people:
|
if not Data.people:
|
||||||
self.layout.label(text="No people found.")
|
self.layout.label(text="No people found.")
|
||||||
|
|||||||
@@ -284,30 +284,6 @@ def getAttributeEnumValues(self, context):
|
|||||||
return [(e, e, "") for e in json.loads(self.enum_items)]
|
return [(e, e, "") for e in json.loads(self.enum_items)]
|
||||||
|
|
||||||
|
|
||||||
def getPersons(self, context):
|
|
||||||
from blenderbim.bim.module.owner.data import Data
|
|
||||||
if not Data.is_loaded:
|
|
||||||
Data.load()
|
|
||||||
results = []
|
|
||||||
for ifc_id, person in Data.people.items():
|
|
||||||
if "Id" in person:
|
|
||||||
identifier = person["Id"] or ""
|
|
||||||
else:
|
|
||||||
identifier = person["Identifier"] or ""
|
|
||||||
results.append((str(ifc_id), identifier, ""))
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
def getOrganisations(self, context):
|
|
||||||
from blenderbim.bim.module.owner.data import Data
|
|
||||||
if not Data.is_loaded:
|
|
||||||
Data.load()
|
|
||||||
results = []
|
|
||||||
for ifc_id, organisation in Data.organisations.items():
|
|
||||||
results.append((str(ifc_id), organisation["Name"], ""))
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
def getIfcPatchRecipes(self, context):
|
def getIfcPatchRecipes(self, context):
|
||||||
global ifcpatchrecipes_enum
|
global ifcpatchrecipes_enum
|
||||||
if len(ifcpatchrecipes_enum) < 1:
|
if len(ifcpatchrecipes_enum) < 1:
|
||||||
@@ -1057,10 +1033,6 @@ class BIMProperties(PropertyGroup):
|
|||||||
import_should_offset_model: BoolProperty(name="Import and Offset Model", 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")
|
||||||
|
|
||||||
# TODO: move into owner module
|
|
||||||
user_person: EnumProperty(items=getPersons, name="Person")
|
|
||||||
user_organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
|
||||||
|
|
||||||
has_georeferencing: BoolProperty(name="Has Georeferencing", default=False)
|
has_georeferencing: BoolProperty(name="Has Georeferencing", default=False)
|
||||||
has_library: BoolProperty(name="Has Project Library", default=False)
|
has_library: BoolProperty(name="Has Project Library", default=False)
|
||||||
search_regex: BoolProperty(name="Search With Regex", default=False)
|
search_regex: BoolProperty(name="Search With Regex", default=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user