Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jul 7, 2024
1 parent 2f3f8f0 commit d58a352
Show file tree
Hide file tree
Showing 42 changed files with 616 additions and 256 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ Adjust the `README.md` as needed to fit the specifics of your project and its co

## Resources

- https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/content/introduction.htm
- https://github.com/buildingSMART/ifc-validation-data-model
44 changes: 44 additions & 0 deletions src/django-bim/enums/actor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

"""
Django BIM IFC Actor Enums Module
==================================
This module provides enumerations related to actors in the Building
Information Modeling (BIM) context using IFC (Industry Foundation Classes)
standards. Enumerations are used to standardize the data fields in models,
ensuring that entries conform to predefined options, enhancing data integrity
and interoperability in construction and architectural projects.
Enumerations included:
- `IfcAddressTypeEnum`: Defines the types of addresses that can be used to
specify location details in a structured manner. Examples include site
addresses, home addresses, delivery points, etc.
- `IfcRoleEnum`: Enumerates different roles that can be assigned to actors
within a building construction project, such as Architect, Engineer,
Contractor, etc. This helps in defining clear responsibilities and
permissions within project management systems.
These enums are particularly useful for developers working with Django models
that need to comply with IFC standards, providing a reliable and consistent
framework for data representation.
"""

# =============================================================================
# Imports
# =============================================================================

# Local enumeration modules
from .enum_ifc_address_type import IfcAddressTypeEnum
from .enum_ifc_role import IfcRoleEnum


# =============================================================================
# Public Interface
# =============================================================================

__all__ = [
"IfcAddressTypeEnum",
"IfcRoleEnum",
]
112 changes: 112 additions & 0 deletions src/django-bim/enums/actor/enum_ifc_address_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# -*- coding: utf-8 -*-


# =============================================================================
# Docstring
# =============================================================================

"""
Provides IFC Address Type Enum Class
====================================
This module defines the `IfcAddressTypeEnum` class, an enumeration of address
types according to the IFC standard. These address types are used to
categorize the addresses associated with entities like organizations or
persons involved in building projects. Proper use of these types ensures data
consistency across BIM applications.
For more information, refer to:
- https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcAddressTypeEnum.htm
- https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcaddresstypeenum.htm
""" # noqa E501


# =============================================================================
# Import
# =============================================================================

# Import | Standard Library
from enum import Enum

# Import | Libraries
from django.utils.translation import gettext_lazy as _

# Import | Local Modules


# =============================================================================
# Classes
# =============================================================================

class IfcAddressTypeEnum(Enum):
"""
IFC Address Type Enum Class
===========================
Enumeration for IfcAddressTypeEnum providing address types according to
the IFC standard.
Each member of this enumeration represents a specific type of address
that may be associated with various entities involved in a building
project.
Enum Members:
- DISTRIBUTIONPOINT: An address used specifically for sending or
receiving goods.
- HOME: The residential address of an individual.
- OFFICE: Typically the address of a business or administrative
entity.
- SITE: The location of a construction or project site.
- USERDEFINED: A type specified by the user when standard types do
not suffice.
- NOTDEFINED: Used when the address type is not defined among the
standard options.
"""

# Class | Enum Members
# =========================================================================

DISTRIBUTIONPOINT = _("Distribution Point")
HOME = _("Home")
OFFICE = _("Office")
SITE = _("Site")
USERDEFINED = _("User Defined")
NOTDEFINED = _("Not Defined") # Not in specification

# Class | Methods
# =========================================================================

def __str__(self) -> str:
"""
Return the user-friendly name of the enum member, with error handling
in case of unexpected value formats.
"""
try:
return self.value
except ValueError as e:
return str(e) # Log the error or handle it appropriately

@classmethod
def choices(cls):
"""
Returns the choices for field choices in a Django model field,
formatted as required by Django's field choices.
Returns:
tuple of tuples: Each tuple contains the enum member's value and
its human-readable name.
"""

return tuple((item.name, item.value) for item in cls)


# =============================================================================
# Public Interface
# =============================================================================

__all__ = [
"IfcAddressTypeEnum",
]
136 changes: 136 additions & 0 deletions src/django-bim/enums/actor/enum_ifc_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*-


# =============================================================================
# Docstring
# =============================================================================

"""
Provides IFC Role Enum Class
============================
This module defines an enumeration class `IfcRoleEnum` according to the
IFC standard, detailing various roles that can be assigned to actors
in a building construction project. These roles are essential for categorizing
job functions and responsibilities within IFC data models and can be used
to align project staffing and organization structures with IFC-compliant
systems.
For more information, refer to:
- https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcRoleEnum.htm
- https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcroleenum.htm
""" # noqa E501


# =============================================================================
# Import
# =============================================================================

# Import | Standard Library
from enum import Enum
# from typing import Any, Dict, List

# Import | Libraries
from django.utils.translation import gettext_lazy as _

# Import | Local Modules


# =============================================================================
# Classes
# =============================================================================

class IfcRoleEnum(Enum):
"""
IFC Role Enum Class
===================
Enumeration for IfcRoleEnum providing standardized role types as specified
in the IFC standard.
Each enum member represents a role type that can be assigned to actors
involved in building construction projects, ensuring adherence to
international standards for classification and reporting.
Examples:
- ARCHITECT: Responsible for design and aesthetics.
- ENGINEER: Can be specialized into categories such as CIVILENGINEER
or STRUCTURALENGINEER.
- CONTRACTOR: Primary entity responsible for the construction phase.
"""

# Class | Enum Members
# =========================================================================

ARCHITECT = _("Architect")
BUILDINGOPERATOR = _("Building Operator")
BUILDINGOWNER = _("Building Owner")
CIVILENGINEER = _("Civil Engineer")
CLIENT = _("Client")
COMMISSIONINGENGINEER = _("Commissioning Engineer")
CONSTRUCTIONMANAGER = _("Construction Manager")
CONSULTANT = _("Consultant")
CONTRACTOR = _("Contractor")
COSTENGINEER = _("Cost Engineer")
ELECTRICALENGINEER = _("Electrical Engineer")
ENGINEER = _("Engineer")
FACILITIESMANAGER = _("Facilities Manager")
FIELDCONSTRUCTIONMANAGER = _("Field Construction Manager")
MANUFACTURER = _("Manufacturer")
MECHANICALENGINEER = _("Mechanical Engineer")
OWNER = _("Owner")
PROJECTMANAGER = _("Project Manager")
RESELLER = _("Reseller")
STRUCTURALENGINEER = _("Structural Engineer")
SUBCONTRACTOR = _("Sub-contractor")
SUPPLIER = _("Supplier")
USERDEFINED = _("User Defined")

# Class | Methods
# =========================================================================

def __str__(self) -> str:
"""
Return the user-friendly name of the enum member, with error handling
in case of unexpected value formats.
"""
try:
return self.value
except ValueError as e:
return str(e) # Log the error or handle it appropriately

@classmethod
def choices(cls):
"""
Provides Django-compatible choices for model fields.
This method is particularly useful when using this Enum class in a
Django model as the choices for a field, facilitating the integration
of standardized role data into Django forms and admin interfaces.
Returns:
tuple of tuples: Each tuple contains the enum member's name and its
localized human-readable value, suitable for use in model
field choices.
"""
try:
return tuple(
(item.name, item.value) for item in cls
)
except Exception as e:
# Handle the error, log it, or raise a custom exception if
# necessary
raise ValueError(
"Failed to generate choices from the Enum: {}".format(e)
)


# =============================================================================
# Public Interface
# =============================================================================

__all__ = [
"IfcRoleEnum",
]
77 changes: 0 additions & 77 deletions src/django-bim/enums/enum_ifc_address_type.py

This file was deleted.

Loading

0 comments on commit d58a352

Please sign in to comment.