mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 12:12:15 +00:00
typing
This commit is contained in:
@@ -30,6 +30,7 @@ from bpy.props import (
|
||||
FloatVectorProperty,
|
||||
CollectionProperty,
|
||||
)
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
||||
def update_layer_property(self: "Layer", context: bpy.types.Context, *, property: str) -> None:
|
||||
@@ -74,3 +75,11 @@ class BIMLayerProperties(PropertyGroup):
|
||||
),
|
||||
default="IfcPresentationLayerAssignment",
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
layer_attributes: bpy.types.bpy_prop_collection_idprop[Attribute]
|
||||
active_layer_id: int
|
||||
layers: bpy.types.bpy_prop_collection_idprop[Layer]
|
||||
active_layer_index: int
|
||||
is_editing: bool
|
||||
layer_type: str
|
||||
|
||||
@@ -35,6 +35,7 @@ from bpy.props import (
|
||||
FloatVectorProperty,
|
||||
CollectionProperty,
|
||||
)
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
||||
def get_profile_classes(self, context):
|
||||
@@ -53,6 +54,11 @@ class Profile(PropertyGroup):
|
||||
ifc_class: StringProperty(name="IFC Class")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
if TYPE_CHECKING:
|
||||
name: str
|
||||
ifc_class: str
|
||||
ifc_definition_id: int
|
||||
|
||||
|
||||
def update_active_profile_index(self, context):
|
||||
ProfileData.data["active_profile_users"] = ProfileData.active_profile_users()
|
||||
|
||||
@@ -257,7 +257,7 @@ class BIM_PT_styles(Panel):
|
||||
|
||||
|
||||
class BIM_UL_styles(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||
def draw_item(self, context, layout: bpy.types.UILayout, data, item, icon, active_data, active_property):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.prop(item, "name", text="", emboss=False)
|
||||
|
||||
@@ -488,6 +488,11 @@ class Ifc:
|
||||
def get_all_element_occurrences(cls, element): pass
|
||||
|
||||
|
||||
@interface
|
||||
class Layer:
|
||||
pass
|
||||
|
||||
|
||||
@interface
|
||||
class Library:
|
||||
def clear_editing_mode(cls): pass
|
||||
|
||||
@@ -39,6 +39,7 @@ from bonsai.tool.georeference import Georeference
|
||||
from bonsai.tool.ifc import Ifc
|
||||
from bonsai.tool.ifcgit import IfcGit
|
||||
from bonsai.tool.ifcgit import IfcGitRepo
|
||||
from bonsai.tool.layer import Layer
|
||||
from bonsai.tool.library import Library
|
||||
from bonsai.tool.loader import Loader
|
||||
from bonsai.tool.material import Material
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
import bpy
|
||||
import bmesh
|
||||
import struct
|
||||
@@ -56,9 +57,14 @@ from typing_extensions import TypeIs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bonsai.bim.prop import Attribute
|
||||
from bonsai.bim.module.geometry.prop import BIMObjectGeometryProperties
|
||||
|
||||
|
||||
class Geometry(bonsai.core.tool.Geometry):
|
||||
@classmethod
|
||||
def get_object_geometry_props(cls, object: bpy.types.Object) -> BIMObjectGeometryProperties:
|
||||
return object.BIMGeometryProperties
|
||||
|
||||
@classmethod
|
||||
def change_object_data(cls, obj: bpy.types.Object, data: bpy.types.ID, is_global: bool = False) -> None:
|
||||
if is_global:
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Bonsai - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of Bonsai.
|
||||
#
|
||||
# Bonsai is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Bonsai is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
import bpy
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bonsai.bim.module.layer.prop import BIMLayerProperties
|
||||
|
||||
|
||||
class Layer(bonsai.core.tool.Layer):
|
||||
@classmethod
|
||||
def get_layer_props(cls) -> BIMLayerProperties:
|
||||
return bpy.context.scene.BIMLayerProperties
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.profile
|
||||
@@ -28,7 +29,10 @@ import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
import PIL.ImageDraw
|
||||
from bonsai.bim.module.model.decorator import ProfileDecorator
|
||||
from typing import Union
|
||||
from typing import Union, TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bonsai.bim.module.profile.prop
|
||||
|
||||
|
||||
class Profile(bonsai.core.tool.Profile):
|
||||
@@ -111,7 +115,7 @@ class Profile(bonsai.core.tool.Profile):
|
||||
return new_profile
|
||||
|
||||
@classmethod
|
||||
def get_active_profile_ui(cls) -> Union[bpy.types.PropertyGroup, None]:
|
||||
def get_active_profile_ui(cls) -> Union[bonsai.bim.module.profile.prop.Profile, None]:
|
||||
props = bpy.context.scene.BIMProfileProperties
|
||||
index = props.active_profile_index
|
||||
if len(props.profiles) > index >= 0:
|
||||
|
||||
@@ -38,7 +38,7 @@ import bonsai.bim.helper
|
||||
from dateutil import parser
|
||||
from datetime import datetime
|
||||
from datetime import time as datetime_time
|
||||
from typing import Optional, Any, Union, Literal, TYPE_CHECKING
|
||||
from typing import Optional, Any, Union, Literal, TYPE_CHECKING, Iterable
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bonsai.bim.prop
|
||||
@@ -705,14 +705,14 @@ class Sequence(bonsai.core.tool.Sequence):
|
||||
return bonsai.bim.helper.export_attributes(bpy.context.scene.BIMWorkScheduleProperties.lag_time_attributes)
|
||||
|
||||
@classmethod
|
||||
def select_products(cls, products):
|
||||
def select_products(cls, products: Iterable[ifcopenshell.entity_instance]) -> None:
|
||||
[obj.select_set(False) for obj in bpy.context.selected_objects]
|
||||
for product in products:
|
||||
obj = tool.Ifc.get_object(product)
|
||||
obj.select_set(True) if obj else None
|
||||
|
||||
@classmethod
|
||||
def add_task_column(cls, column_type: str, name: str, data_type: str):
|
||||
def add_task_column(cls, column_type: str, name: str, data_type: str) -> None:
|
||||
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||
new = props.columns.add()
|
||||
new.name = f"{column_type}.{name}"
|
||||
|
||||
Reference in New Issue
Block a user