mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
typing
This commit is contained in:
@@ -63,24 +63,34 @@ from bonsai.bim.module.project.decorator import ProjectDecorator, ClippingPlaneD
|
||||
from bonsai.bim.module.project.prop import BreadcrumbType
|
||||
from bonsai.bim.module.model.decorator import PolylineDecorator, FaceAreaDecorator
|
||||
from bonsai.bim.module.model.polyline import PolylineOperator
|
||||
from typing import Union, TYPE_CHECKING, get_args
|
||||
from typing import Union, TYPE_CHECKING, get_args, Literal
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy.stub_internal.rna_enums as rna_enums
|
||||
from bonsai.bim.module.project.prop import Link
|
||||
|
||||
|
||||
PresetType = Literal["metric_m", "metric_mm", "imperial_ft", "demo", "wizard"]
|
||||
|
||||
|
||||
class NewProject(bpy.types.Operator):
|
||||
bl_idname = "bim.new_project"
|
||||
bl_label = "New Project"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Start a new IFC project in a fresh session"
|
||||
preset: bpy.props.StringProperty()
|
||||
preset: bpy.props.EnumProperty( # pyright: ignore[reportRedeclaration]
|
||||
items=[(i, i, "") for i in get_args(PresetType)]
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
if TYPE_CHECKING:
|
||||
preset: PresetType
|
||||
|
||||
def execute(self, context) -> set["rna_enums.OperatorReturnItems"]:
|
||||
bpy.ops.wm.read_homefile()
|
||||
pprops = tool.Project.get_project_props()
|
||||
bim_props = tool.Blender.get_bim_props()
|
||||
|
||||
assert bpy.context.scene
|
||||
if self.preset == "metric_m":
|
||||
pprops.export_schema = "IFC4"
|
||||
bpy.context.scene.unit_settings.system = "METRIC"
|
||||
|
||||
@@ -21,6 +21,10 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.unit
|
||||
import bonsai.tool as tool
|
||||
import bonsai.core.unit as core
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bpy.stub_internal import rna_enums
|
||||
|
||||
|
||||
class AssignSceneUnits(bpy.types.Operator, tool.Ifc.Operator):
|
||||
@@ -60,7 +64,7 @@ class LoadUnits(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Open the loaded units"
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context) -> set["rna_enums.OperatorReturnItems"]:
|
||||
core.load_units(tool.Unit)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -71,7 +75,7 @@ class DisableUnitEditingUI(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Close the editing units mode"
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context) -> set["rna_enums.OperatorReturnItems"]:
|
||||
core.disable_unit_editing_ui(tool.Unit)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -132,7 +136,7 @@ class EnableEditingUnit(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
unit: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context) -> set["rna_enums.OperatorReturnItems"]:
|
||||
core.enable_editing_unit(tool.Unit, unit=tool.Ifc.get().by_id(self.unit))
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -142,7 +146,7 @@ class DisableEditingUnit(bpy.types.Operator):
|
||||
bl_label = "Disable Editing Unit"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context) -> set["rna_enums.OperatorReturnItems"]:
|
||||
core.disable_editing_unit(tool.Unit)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class BIM_PT_units(Panel):
|
||||
UnitsData.load()
|
||||
|
||||
self.props = tool.Unit.get_unit_props()
|
||||
assert self.layout
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="{} Units Found".format(UnitsData.data["total_units"]), icon="SNAP_GRID")
|
||||
|
||||
@@ -26,7 +26,12 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def copy_attribute_to_selection(
|
||||
ifc: tool.Ifc, blender: tool.Blender, root: tool.Root, spatial: tool.Spatial, name: str, value: Union[str, None]
|
||||
ifc: type[tool.Ifc],
|
||||
blender: type[tool.Blender],
|
||||
root: type[tool.Root],
|
||||
spatial: type[tool.Spatial],
|
||||
name: str,
|
||||
value: Union[str, None],
|
||||
) -> int:
|
||||
total_changed = 0
|
||||
has_edited_spatial_name = False
|
||||
|
||||
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def load_brick_project(brick: tool.Brick, filepath: str, brick_root: str) -> None:
|
||||
def load_brick_project(brick: type[tool.Brick], filepath: str, brick_root: str) -> None:
|
||||
brick.load_brick_file(filepath)
|
||||
brick.import_brick_classes(brick_root)
|
||||
brick.import_brick_classes(brick_root, split_screen=True)
|
||||
@@ -33,7 +33,7 @@ def load_brick_project(brick: tool.Brick, filepath: str, brick_root: str) -> Non
|
||||
brick.set_active_brick_class(brick_root, split_screen=True)
|
||||
|
||||
|
||||
def new_brick_file(brick: tool.Brick, brick_root: str) -> None:
|
||||
def new_brick_file(brick: type[tool.Brick], brick_root: str) -> None:
|
||||
brick.new_brick_file()
|
||||
brick.import_brick_classes(brick_root)
|
||||
brick.import_brick_classes(brick_root, split_screen=True)
|
||||
@@ -41,7 +41,7 @@ def new_brick_file(brick: tool.Brick, brick_root: str) -> None:
|
||||
brick.set_active_brick_class(brick_root, split_screen=True)
|
||||
|
||||
|
||||
def view_brick_class(brick: tool.Brick, brick_class: str, split_screen: bool = False) -> None:
|
||||
def view_brick_class(brick: type[tool.Brick], brick_class: str, split_screen: bool = False) -> None:
|
||||
brick.add_brick_breadcrumb(split_screen=split_screen)
|
||||
brick.clear_brick_browser(split_screen=split_screen)
|
||||
brick.import_brick_classes(brick_class, split_screen=split_screen)
|
||||
@@ -49,13 +49,13 @@ def view_brick_class(brick: tool.Brick, brick_class: str, split_screen: bool = F
|
||||
brick.set_active_brick_class(brick_class, split_screen=split_screen)
|
||||
|
||||
|
||||
def view_brick_item(brick: tool.Brick, item: str, split_screen: bool = False) -> None:
|
||||
def view_brick_item(brick: type[tool.Brick], item: str, split_screen: bool = False) -> None:
|
||||
brick_class = brick.get_item_class(item)
|
||||
brick.run_view_brick_class(brick_class=brick_class, split_screen=split_screen)
|
||||
brick.select_browser_item(item, split_screen=split_screen)
|
||||
|
||||
|
||||
def rewind_brick_class(brick: tool.Brick, split_screen: bool = False) -> None:
|
||||
def rewind_brick_class(brick: type[tool.Brick], split_screen: bool = False) -> None:
|
||||
previous_class = brick.pop_brick_breadcrumb(split_screen=split_screen)
|
||||
brick.clear_brick_browser(split_screen=split_screen)
|
||||
brick.import_brick_classes(previous_class, split_screen=split_screen)
|
||||
@@ -63,7 +63,7 @@ def rewind_brick_class(brick: tool.Brick, split_screen: bool = False) -> None:
|
||||
brick.set_active_brick_class(previous_class, split_screen=split_screen)
|
||||
|
||||
|
||||
def close_brick_project(brick: tool.Brick) -> None:
|
||||
def close_brick_project(brick: type[tool.Brick]) -> None:
|
||||
brick.clear_project()
|
||||
brick.clear_brick_browser()
|
||||
brick.clear_brick_browser(split_screen=True)
|
||||
@@ -71,15 +71,15 @@ def close_brick_project(brick: tool.Brick) -> None:
|
||||
brick.clear_breadcrumbs(split_screen=True)
|
||||
|
||||
|
||||
def convert_brick_project(ifc: tool.Ifc, brick: tool.Brick) -> None:
|
||||
def convert_brick_project(ifc: type[tool.Ifc], brick: type[tool.Brick]) -> None:
|
||||
library = ifc.run("library.add_library", name=brick.get_brick_path_name())
|
||||
if ifc.get_schema() != "IFC2X3":
|
||||
ifc.run("library.edit_library", library=library, attributes={"Location": brick.get_brick_path()})
|
||||
|
||||
|
||||
def assign_brick_reference(
|
||||
ifc: tool.Ifc,
|
||||
brick: tool.Brick,
|
||||
ifc: type[tool.Ifc],
|
||||
brick: type[tool.Brick],
|
||||
element: ifcopenshell.entity_instance,
|
||||
library: ifcopenshell.entity_instance,
|
||||
brick_uri: str,
|
||||
@@ -96,8 +96,8 @@ def assign_brick_reference(
|
||||
|
||||
|
||||
def add_brick(
|
||||
ifc: tool.Ifc,
|
||||
brick: tool.Brick,
|
||||
ifc: type[tool.Ifc],
|
||||
brick: type[tool.Brick],
|
||||
element: Union[ifcopenshell.entity_instance, None],
|
||||
namespace: str,
|
||||
brick_class: str,
|
||||
@@ -113,12 +113,14 @@ def add_brick(
|
||||
brick.run_refresh_brick_viewer()
|
||||
|
||||
|
||||
def add_brick_relation(brick: tool.Brick, brick_uri: str, predicate: str, object: str) -> None:
|
||||
def add_brick_relation(brick: type[tool.Brick], brick_uri: str, predicate: str, object: str) -> None:
|
||||
brick.add_relation(brick_uri, predicate, object)
|
||||
brick.run_refresh_brick_viewer()
|
||||
|
||||
|
||||
def convert_ifc_to_brick(brick: tool.Brick, namespace: str, library: Union[ifcopenshell.entity_instance, None]) -> None:
|
||||
def convert_ifc_to_brick(
|
||||
brick: type[tool.Brick], namespace: str, library: Union[ifcopenshell.entity_instance, None]
|
||||
) -> None:
|
||||
# convert spaces to brick
|
||||
spaces = brick.get_convertable_brick_spaces()
|
||||
space_uris = {}
|
||||
@@ -163,14 +165,16 @@ def convert_ifc_to_brick(brick: tool.Brick, namespace: str, library: Union[ifcop
|
||||
brick.run_refresh_brick_viewer()
|
||||
|
||||
|
||||
def refresh_brick_viewer(brick: tool.Brick) -> None:
|
||||
def refresh_brick_viewer(brick: type[tool.Brick]) -> None:
|
||||
brick.run_view_brick_class(brick_class=brick.get_active_brick_class())
|
||||
brick.pop_brick_breadcrumb()
|
||||
brick.run_view_brick_class(brick_class=brick.get_active_brick_class(split_screen=True), split_screen=True)
|
||||
brick.pop_brick_breadcrumb(split_screen=True)
|
||||
|
||||
|
||||
def remove_brick(ifc: tool.Ifc, brick: tool.Brick, library: ifcopenshell.entity_instance, brick_uri: str) -> None:
|
||||
def remove_brick(
|
||||
ifc: type[tool.Ifc], brick: type[tool.Brick], library: ifcopenshell.entity_instance, brick_uri: str
|
||||
) -> None:
|
||||
if library:
|
||||
reference = brick.get_library_brick_reference(library, brick_uri)
|
||||
if reference:
|
||||
@@ -179,18 +183,18 @@ def remove_brick(ifc: tool.Ifc, brick: tool.Brick, library: ifcopenshell.entity_
|
||||
brick.run_refresh_brick_viewer()
|
||||
|
||||
|
||||
def serialize_brick(brick: tool.Brick) -> None:
|
||||
def serialize_brick(brick: type[tool.Brick]) -> None:
|
||||
brick.serialize_brick()
|
||||
|
||||
|
||||
def add_brick_namespace(brick: tool.Brick, alias: str, uri: str) -> None:
|
||||
def add_brick_namespace(brick: type[tool.Brick], alias: str, uri: str) -> None:
|
||||
brick.add_namespace(alias, uri)
|
||||
|
||||
|
||||
def set_brick_list_root(brick: tool.Brick, brick_root: str, split_screen: bool = False) -> None:
|
||||
def set_brick_list_root(brick: type[tool.Brick], brick_root: str, split_screen: bool = False) -> None:
|
||||
brick.run_view_brick_class(brick_class=brick_root, split_screen=split_screen)
|
||||
brick.clear_breadcrumbs(split_screen=split_screen)
|
||||
|
||||
|
||||
def remove_brick_relation(brick: tool.Brick, brick_uri: str, predicate: str, object: str) -> None:
|
||||
def remove_brick_relation(brick: type[tool.Brick], brick_uri: str, predicate: str, object: str) -> None:
|
||||
brick.remove_relation(brick_uri, predicate, object)
|
||||
|
||||
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def add_context(
|
||||
ifc: tool.Ifc,
|
||||
ifc: type[tool.Ifc],
|
||||
context_type: Optional[str] = None,
|
||||
context_identifier: Optional[str] = None,
|
||||
target_view: Optional[str] = None,
|
||||
@@ -41,19 +41,19 @@ def add_context(
|
||||
)
|
||||
|
||||
|
||||
def remove_context(ifc: tool.Ifc, context: ifcopenshell.entity_instance) -> None:
|
||||
def remove_context(ifc: type[tool.Ifc], context: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("context.remove_context", context=context)
|
||||
|
||||
|
||||
def enable_editing_context(context_tool: tool.Context, context: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_context(context_tool: type[tool.Context], context: ifcopenshell.entity_instance) -> None:
|
||||
context_tool.set_context(context)
|
||||
context_tool.import_attributes()
|
||||
|
||||
|
||||
def disable_editing_context(context: tool.Context) -> None:
|
||||
def disable_editing_context(context: type[tool.Context]) -> None:
|
||||
context.clear_context()
|
||||
|
||||
|
||||
def edit_context(ifc: tool.Ifc, context: tool.Context) -> None:
|
||||
def edit_context(ifc: type[tool.Ifc], context: type[tool.Context]) -> None:
|
||||
ifc.run("context.edit_context", context=context.get_context(), attributes=context.export_attributes())
|
||||
disable_editing_context(context)
|
||||
|
||||
@@ -458,7 +458,5 @@ def add_currency(ifc: type[tool.Ifc], cost: type[tool.Cost]) -> ifcopenshell.ent
|
||||
return unit
|
||||
|
||||
|
||||
def generate_cost_schedule_browser(
|
||||
cost: type[tool.Cost], cost_schedule: ifcopenshell.entity_instance
|
||||
) -> bpy.types.Panel:
|
||||
def generate_cost_schedule_browser(cost: type[tool.Cost], cost_schedule: ifcopenshell.entity_instance) -> None:
|
||||
return cost.generate_cost_schedule_browser(cost_schedule)
|
||||
|
||||
@@ -25,7 +25,9 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def add_instance_flooring_covering_from_cursor(ifc: tool.Ifc, root: tool.Root, spatial: tool.Spatial) -> None:
|
||||
def add_instance_flooring_covering_from_cursor(
|
||||
ifc: type[tool.Ifc], root: type[tool.Root], spatial: type[tool.Spatial]
|
||||
) -> None:
|
||||
if not root.get_default_container():
|
||||
raise NoDefaultContainer()
|
||||
|
||||
@@ -68,7 +70,7 @@ def add_instance_flooring_covering_from_cursor(ifc: tool.Ifc, root: tool.Root, s
|
||||
|
||||
|
||||
def add_instance_ceiling_covering_from_cursor(
|
||||
ifc: tool.Ifc, root: tool.Root, covering: tool.Covering, spatial: tool.Spatial
|
||||
ifc: type[tool.Ifc], root: type[tool.Root], covering: type[tool.Covering], spatial: type[tool.Spatial]
|
||||
) -> None:
|
||||
if not root.get_default_container():
|
||||
raise NoDefaultContainer()
|
||||
@@ -111,7 +113,7 @@ def add_instance_ceiling_covering_from_cursor(
|
||||
spatial.regen_obj_representation(obj, body)
|
||||
|
||||
|
||||
def regen_selected_covering_object(root: tool.Root, spatial: tool.Spatial) -> None:
|
||||
def regen_selected_covering_object(root: type[tool.Root], spatial: type[tool.Spatial]) -> None:
|
||||
if not root.get_default_container():
|
||||
raise NoDefaultContainer()
|
||||
|
||||
@@ -142,7 +144,7 @@ def regen_selected_covering_object(root: tool.Root, spatial: tool.Spatial) -> No
|
||||
|
||||
|
||||
# TODO CHECK IF IT IS POSSIBLE TO CREATE ONLY ONE CORE FUNCTION FOR _FROM_WALLS
|
||||
def add_instance_flooring_coverings_from_walls(root: tool.Root, spatial: tool.Spatial) -> None:
|
||||
def add_instance_flooring_coverings_from_walls(root: type[tool.Root], spatial: type[tool.Spatial]) -> None:
|
||||
if not root.get_default_container():
|
||||
raise NoDefaultContainer()
|
||||
|
||||
@@ -168,7 +170,9 @@ def add_instance_flooring_coverings_from_walls(root: tool.Root, spatial: tool.Sp
|
||||
spatial.regen_obj_representation(obj, body)
|
||||
|
||||
|
||||
def add_instance_ceiling_coverings_from_walls(root: tool.Root, spatial: tool.Spatial, covering: tool.Covering) -> None:
|
||||
def add_instance_ceiling_coverings_from_walls(
|
||||
root: type[tool.Root], spatial: type[tool.Spatial], covering: type[tool.Covering]
|
||||
) -> None:
|
||||
if not root.get_default_container():
|
||||
raise NoDefaultContainer()
|
||||
|
||||
|
||||
@@ -25,25 +25,25 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def add_georeferencing(georeference: tool.Georeference) -> None:
|
||||
def add_georeferencing(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.add_georeferencing()
|
||||
|
||||
|
||||
def enable_editing_georeferencing(georeference: tool.Georeference) -> None:
|
||||
def enable_editing_georeferencing(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.import_projected_crs()
|
||||
georeference.import_coordinate_operation()
|
||||
georeference.enable_editing()
|
||||
|
||||
|
||||
def remove_georeferencing(ifc: tool.Ifc) -> None:
|
||||
def remove_georeferencing(ifc: type[tool.Ifc]) -> None:
|
||||
ifc.run("georeference.remove_georeferencing")
|
||||
|
||||
|
||||
def disable_editing_georeferencing(georeference: tool.Georeference) -> None:
|
||||
def disable_editing_georeferencing(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.disable_editing()
|
||||
|
||||
|
||||
def edit_georeferencing(ifc: tool.Ifc, georeference: tool.Georeference) -> None:
|
||||
def edit_georeferencing(ifc: type[tool.Ifc], georeference: type[tool.Georeference]) -> None:
|
||||
ifc.run(
|
||||
"georeference.edit_georeferencing",
|
||||
projected_crs=georeference.export_projected_crs(),
|
||||
@@ -53,7 +53,7 @@ def edit_georeferencing(ifc: tool.Ifc, georeference: tool.Georeference) -> None:
|
||||
georeference.set_model_origin()
|
||||
|
||||
|
||||
def get_cursor_location(georeference: tool.Georeference) -> None:
|
||||
def get_cursor_location(georeference: type[tool.Georeference]) -> None:
|
||||
location = georeference.get_cursor_location()
|
||||
if georeference.has_blender_offset():
|
||||
georeference.set_coordinates("blender", location)
|
||||
@@ -61,39 +61,39 @@ def get_cursor_location(georeference: tool.Georeference) -> None:
|
||||
georeference.set_coordinates("local", location)
|
||||
|
||||
|
||||
def import_plot(georeference: tool.Georeference, filepath: str) -> None:
|
||||
def import_plot(georeference: type[tool.Georeference], filepath: str) -> None:
|
||||
georeference.import_plot(filepath)
|
||||
|
||||
|
||||
def enable_editing_wcs(georeference: tool.Georeference) -> None:
|
||||
def enable_editing_wcs(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.import_wcs()
|
||||
georeference.enable_editing_wcs()
|
||||
|
||||
|
||||
def disable_editing_wcs(georeference: tool.Georeference) -> None:
|
||||
def disable_editing_wcs(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.disable_editing_wcs()
|
||||
|
||||
|
||||
def edit_wcs(georeference: tool.Georeference) -> None:
|
||||
def edit_wcs(georeference: type[tool.Georeference]) -> None:
|
||||
wcs = georeference.export_wcs()
|
||||
georeference.set_wcs(wcs)
|
||||
georeference.disable_editing_wcs()
|
||||
georeference.set_model_origin()
|
||||
|
||||
|
||||
def enable_editing_true_north(georeference: tool.Georeference) -> None:
|
||||
def enable_editing_true_north(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.import_true_north()
|
||||
georeference.enable_editing_true_north()
|
||||
|
||||
|
||||
def disable_editing_true_north(georeference: tool.Georeference) -> None:
|
||||
def disable_editing_true_north(georeference: type[tool.Georeference]) -> None:
|
||||
georeference.disable_editing_true_north()
|
||||
|
||||
|
||||
def edit_true_north(ifc: tool.Ifc, georeference: tool.Georeference) -> None:
|
||||
def edit_true_north(ifc: type[tool.Ifc], georeference: type[tool.Georeference]) -> None:
|
||||
ifc.run("georeference.edit_true_north", true_north=georeference.get_true_north_attributes())
|
||||
georeference.disable_editing_true_north()
|
||||
|
||||
|
||||
def remove_true_north(ifc: tool.Ifc) -> None:
|
||||
def remove_true_north(ifc: type[tool.Ifc]) -> None:
|
||||
ifc.run("georeference.edit_true_north", true_north=None)
|
||||
|
||||
@@ -25,35 +25,35 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def add_library(ifc: tool.Ifc) -> ifcopenshell.entity_instance:
|
||||
def add_library(ifc: type[tool.Ifc]) -> ifcopenshell.entity_instance:
|
||||
return ifc.run("library.add_library", name="Unnamed")
|
||||
|
||||
|
||||
def remove_library(ifc: tool.Ifc, library: ifcopenshell.entity_instance) -> None:
|
||||
def remove_library(ifc: type[tool.Ifc], library: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("library.remove_library", library=library)
|
||||
|
||||
|
||||
def enable_editing_library_references(library_tool: tool.Library, library: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_library_references(library_tool: type[tool.Library], library: ifcopenshell.entity_instance) -> None:
|
||||
library_tool.set_editing_mode("REFERENCES")
|
||||
library_tool.set_active_library(library)
|
||||
library_tool.import_references(library)
|
||||
|
||||
|
||||
def disable_editing_library_references(library: tool.Library) -> None:
|
||||
def disable_editing_library_references(library: type[tool.Library]) -> None:
|
||||
library.clear_editing_mode()
|
||||
library.set_active_library(None)
|
||||
|
||||
|
||||
def enable_editing_library(library: tool.Library) -> None:
|
||||
def enable_editing_library(library: type[tool.Library]) -> None:
|
||||
library.set_editing_mode("LIBRARY")
|
||||
library.import_library_attributes(library.get_active_library())
|
||||
|
||||
|
||||
def disable_editing_library(library: tool.Library) -> None:
|
||||
def disable_editing_library(library: type[tool.Library]) -> None:
|
||||
library.set_editing_mode("REFERENCES")
|
||||
|
||||
|
||||
def edit_library(ifc: tool.Ifc, library: tool.Library) -> None:
|
||||
def edit_library(ifc: type[tool.Ifc], library: type[tool.Library]) -> None:
|
||||
library.set_editing_mode("REFERENCES")
|
||||
active_library = library.get_active_library()
|
||||
attributes = library.export_library_attributes()
|
||||
@@ -61,29 +61,31 @@ def edit_library(ifc: tool.Ifc, library: tool.Library) -> None:
|
||||
library.import_references(active_library)
|
||||
|
||||
|
||||
def add_library_reference(ifc: tool.Ifc, library: tool.Library) -> ifcopenshell.entity_instance:
|
||||
def add_library_reference(ifc: type[tool.Ifc], library: type[tool.Library]) -> ifcopenshell.entity_instance:
|
||||
active_library = library.get_active_library()
|
||||
reference = ifc.run("library.add_reference", library=active_library)
|
||||
library.import_references(active_library)
|
||||
return reference
|
||||
|
||||
|
||||
def remove_library_reference(ifc: tool.Ifc, library: tool.Library, reference: ifcopenshell.entity_instance) -> None:
|
||||
def remove_library_reference(
|
||||
ifc: type[tool.Ifc], library: type[tool.Library], reference: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("library.remove_reference", reference=reference)
|
||||
library.import_references(library.get_active_library())
|
||||
|
||||
|
||||
def enable_editing_library_reference(library: tool.Library, reference: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_library_reference(library: type[tool.Library], reference: ifcopenshell.entity_instance) -> None:
|
||||
library.set_editing_mode("REFERENCE")
|
||||
library.set_active_reference(reference)
|
||||
library.import_reference_attributes(reference)
|
||||
|
||||
|
||||
def disable_editing_library_reference(library: tool.Library) -> None:
|
||||
def disable_editing_library_reference(library: type[tool.Library]) -> None:
|
||||
library.set_editing_mode("REFERENCES")
|
||||
|
||||
|
||||
def edit_library_reference(ifc: tool.Ifc, library: tool.Library) -> None:
|
||||
def edit_library_reference(ifc: type[tool.Ifc], library: type[tool.Library]) -> None:
|
||||
library.set_editing_mode("REFERENCES")
|
||||
active_reference = library.get_active_reference()
|
||||
attributes = library.export_reference_attributes()
|
||||
@@ -91,9 +93,13 @@ def edit_library_reference(ifc: tool.Ifc, library: tool.Library) -> None:
|
||||
library.import_references(library.get_active_library())
|
||||
|
||||
|
||||
def assign_library_reference(ifc: tool.Ifc, obj: bpy.types.Object, reference: ifcopenshell.entity_instance) -> None:
|
||||
def assign_library_reference(
|
||||
ifc: type[tool.Ifc], obj: bpy.types.Object, reference: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("library.assign_reference", products=[ifc.get_entity(obj)], reference=reference)
|
||||
|
||||
|
||||
def unassign_library_reference(ifc: tool.Ifc, obj: bpy.types.Object, reference: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_library_reference(
|
||||
ifc: type[tool.Ifc], obj: bpy.types.Object, reference: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("library.unassign_reference", products=[ifc.get_entity(obj)], reference=reference)
|
||||
|
||||
@@ -25,18 +25,18 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def enable_editing_nest(nest: tool.Nest, obj: bpy.types.Object) -> None:
|
||||
def enable_editing_nest(nest: type[tool.Nest], obj: bpy.types.Object) -> None:
|
||||
nest.enable_editing(obj)
|
||||
|
||||
|
||||
def disable_editing_nest(nest: tool.Nest, obj: bpy.types.Object) -> None:
|
||||
def disable_editing_nest(nest: type[tool.Nest], obj: bpy.types.Object) -> None:
|
||||
nest.disable_editing(obj)
|
||||
|
||||
|
||||
def assign_object(
|
||||
ifc: tool.Ifc,
|
||||
nest: tool.Nest,
|
||||
collector: tool.Collector,
|
||||
ifc: type[tool.Ifc],
|
||||
nest: type[tool.Nest],
|
||||
collector: type[tool.Collector],
|
||||
relating_obj: bpy.types.Object,
|
||||
related_obj: bpy.types.Object,
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
@@ -54,9 +54,9 @@ def assign_object(
|
||||
|
||||
|
||||
def unassign_object(
|
||||
ifc: tool.Ifc,
|
||||
nest: tool.Nest,
|
||||
collector: tool.Collector,
|
||||
ifc: type[tool.Ifc],
|
||||
nest: type[tool.Nest],
|
||||
collector: type[tool.Collector],
|
||||
relating_obj: bpy.types.Object,
|
||||
related_obj: bpy.types.Object,
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
@@ -77,10 +77,10 @@ def unassign_object(
|
||||
|
||||
|
||||
def add_part_to_object(
|
||||
ifc: tool.Ifc,
|
||||
nest: tool.Nest,
|
||||
collector: tool.Collector,
|
||||
blender: tool.Blender,
|
||||
ifc: type[tool.Ifc],
|
||||
nest: type[tool.Nest],
|
||||
collector: type[tool.Collector],
|
||||
blender: type[tool.Blender],
|
||||
obj: bpy.types.Object,
|
||||
part_class: str,
|
||||
part_name: str,
|
||||
@@ -90,7 +90,7 @@ def add_part_to_object(
|
||||
|
||||
|
||||
def enable_nest_mode(
|
||||
nest: tool.Nest,
|
||||
nest: type[tool.Nest],
|
||||
obj: bpy.types.Object,
|
||||
) -> None:
|
||||
if nest.get_nest_mode():
|
||||
@@ -99,5 +99,5 @@ def enable_nest_mode(
|
||||
nest.enable_nest_mode(obj)
|
||||
|
||||
|
||||
def disable_nest_mode(nest: tool.Nest) -> None:
|
||||
def disable_nest_mode(nest: type[tool.Nest]) -> None:
|
||||
nest.disable_nest_mode()
|
||||
|
||||
@@ -26,5 +26,5 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def run_migrate_patch(patch: tool.Patch, infile: str, outfile: str, schema: str) -> None:
|
||||
def run_migrate_patch(patch: type[tool.Patch], infile: str, outfile: str, schema: str) -> None:
|
||||
patch.run_migrate_patch(infile, outfile, schema)
|
||||
|
||||
@@ -26,10 +26,10 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def create_project(
|
||||
ifc: tool.Ifc,
|
||||
georeference: tool.Georeference,
|
||||
project: tool.Project,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
georeference: type[tool.Georeference],
|
||||
project: type[tool.Project],
|
||||
spatial: type[tool.Spatial],
|
||||
schema: str,
|
||||
template: Optional[str] = None,
|
||||
) -> None:
|
||||
|
||||
@@ -27,8 +27,8 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def copy_property_to_selection(
|
||||
ifc: tool.Ifc,
|
||||
pset: tool.Pset,
|
||||
ifc: type[tool.Ifc],
|
||||
pset: type[tool.Pset],
|
||||
obj: bpy.types.Object,
|
||||
pset_name: str,
|
||||
prop_name: str,
|
||||
@@ -48,7 +48,11 @@ def copy_property_to_selection(
|
||||
|
||||
|
||||
def add_pset(
|
||||
ifc: tool.Ifc, pset: tool.Pset, blender: tool.Blender, obj_name: str, obj_type: tool.Ifc.OBJECT_TYPE
|
||||
ifc: type[tool.Ifc],
|
||||
pset: type[tool.Pset],
|
||||
blender: type[tool.Blender],
|
||||
obj_name: str,
|
||||
obj_type: type[tool.Ifc].OBJECT_TYPE,
|
||||
) -> None:
|
||||
pset_name = pset.get_pset_name(obj_name, obj_type, pset_type="PSET")
|
||||
if obj_type == "Object":
|
||||
@@ -64,12 +68,12 @@ def add_pset(
|
||||
|
||||
|
||||
def enable_pset_editing(
|
||||
pset_tool: tool.Pset,
|
||||
pset_tool: type[tool.Pset],
|
||||
pset: Union[ifcopenshell.entity_instance, None],
|
||||
pset_name: str,
|
||||
pset_type: tool.Pset.PSET_TYPE,
|
||||
pset_type: type[tool.Pset].PSET_TYPE,
|
||||
obj_name: str,
|
||||
obj_type: tool.Ifc.OBJECT_TYPE,
|
||||
obj_type: type[tool.Ifc].OBJECT_TYPE,
|
||||
) -> None:
|
||||
props = pset_tool.get_pset_props(obj_name, obj_type)
|
||||
pset_tool.clear_blender_pset_properties(props)
|
||||
@@ -90,7 +94,7 @@ def enable_pset_editing(
|
||||
|
||||
|
||||
def add_proposed_prop(
|
||||
pset: tool.Pset, obj_name: str, obj_type: tool.Ifc.OBJECT_TYPE, name: str, value: Any
|
||||
pset: type[tool.Pset], obj_name: str, obj_type: type[tool.Ifc].OBJECT_TYPE, name: str, value: Any
|
||||
) -> Union[None, str]:
|
||||
props = pset.get_pset_props(obj_name, obj_type)
|
||||
res = pset.add_proposed_property(name, pset.cast_string_to_primitive(value), props)
|
||||
@@ -99,7 +103,7 @@ def add_proposed_prop(
|
||||
|
||||
|
||||
def unshare_pset(
|
||||
ifc: tool.Ifc, pset_tool: tool.Pset, obj_type: tool.Ifc.OBJECT_TYPE, obj_name: str, pset_id: int
|
||||
ifc: type[tool.Ifc], pset_tool: type[tool.Pset], obj_type: type[tool.Ifc].OBJECT_TYPE, obj_name: str, pset_id: int
|
||||
) -> None:
|
||||
elements: list[ifcopenshell.entity_instance]
|
||||
pset = ifc.get_entity_by_id(pset_id)
|
||||
|
||||
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def calculate_circle_radius(qto: tool.Qto, obj: bpy.types.Object) -> float:
|
||||
def calculate_circle_radius(qto: type[tool.Qto], obj: bpy.types.Object) -> float:
|
||||
result = qto.get_radius_of_selected_vertices(obj)
|
||||
qto.set_qto_result(result)
|
||||
return result
|
||||
|
||||
@@ -1,2 +1,28 @@
|
||||
def show_scene_elements(spatial):
|
||||
# Bonsai - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 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
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def show_scene_elements(spatial: type[tool.Spatial]) -> None:
|
||||
spatial.show_scene_objects()
|
||||
|
||||
+143
-102
@@ -25,106 +25,110 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def add_work_plan(ifc: tool.Ifc) -> ifcopenshell.entity_instance:
|
||||
def add_work_plan(ifc: type[tool.Ifc]) -> ifcopenshell.entity_instance:
|
||||
return ifc.run("sequence.add_work_plan")
|
||||
|
||||
|
||||
def remove_work_plan(ifc: tool.Ifc, work_plan: ifcopenshell.entity_instance) -> None:
|
||||
def remove_work_plan(ifc: type[tool.Ifc], work_plan: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.remove_work_plan", work_plan=work_plan)
|
||||
|
||||
|
||||
def enable_editing_work_plan(sequence: tool.Sequence, work_plan: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_plan(sequence: type[tool.Sequence], work_plan: ifcopenshell.entity_instance) -> None:
|
||||
sequence.load_work_plan_attributes(work_plan)
|
||||
sequence.enable_editing_work_plan(work_plan)
|
||||
|
||||
|
||||
def disable_editing_work_plan(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_work_plan(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_work_plan()
|
||||
|
||||
|
||||
def edit_work_plan(ifc: tool.Ifc, sequence: tool.Sequence, work_plan: ifcopenshell.entity_instance) -> None:
|
||||
def edit_work_plan(ifc: type[tool.Ifc], sequence: type[tool.Sequence], work_plan: ifcopenshell.entity_instance) -> None:
|
||||
attributes = sequence.get_work_plan_attributes()
|
||||
ifc.run("sequence.edit_work_plan", work_plan=work_plan, attributes=attributes)
|
||||
sequence.disable_editing_work_plan()
|
||||
|
||||
|
||||
def edit_work_schedule(ifc: tool.Ifc, sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def edit_work_schedule(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
attributes = sequence.get_work_schedule_attributes()
|
||||
ifc.run("sequence.edit_work_schedule", work_schedule=work_schedule, attributes=attributes)
|
||||
sequence.disable_editing_work_schedule()
|
||||
|
||||
|
||||
def enable_editing_work_plan_schedules(
|
||||
sequence: tool.Sequence, work_plan: Optional[ifcopenshell.entity_instance] = None
|
||||
sequence: type[tool.Sequence], work_plan: Optional[ifcopenshell.entity_instance] = None
|
||||
) -> None:
|
||||
sequence.enable_editing_work_plan_schedules(work_plan)
|
||||
|
||||
|
||||
def add_work_schedule(ifc: tool.Ifc, sequence: tool.Sequence, name: str) -> ifcopenshell.entity_instance:
|
||||
def add_work_schedule(ifc: type[tool.Ifc], sequence: type[tool.Sequence], name: str) -> ifcopenshell.entity_instance:
|
||||
predefined_type, object_type = sequence.get_user_predefined_type()
|
||||
return ifc.run("sequence.add_work_schedule", name=name, predefined_type=predefined_type, object_type=object_type)
|
||||
|
||||
|
||||
def remove_work_schedule(ifc: tool.Ifc, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def remove_work_schedule(ifc: type[tool.Ifc], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.remove_work_schedule", work_schedule=work_schedule)
|
||||
|
||||
|
||||
def assign_work_schedule(
|
||||
ifc: tool.Ifc, work_plan: ifcopenshell.entity_instance, work_schedule: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc], work_plan: ifcopenshell.entity_instance, work_schedule: ifcopenshell.entity_instance
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
if work_schedule:
|
||||
return ifc.run("aggregate.assign_object", relating_object=work_plan, products=[work_schedule])
|
||||
|
||||
|
||||
def unassign_work_schedule(ifc: tool.Ifc, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_work_schedule(ifc: type[tool.Ifc], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("aggregate.unassign_object", products=[work_schedule])
|
||||
|
||||
|
||||
def enable_editing_work_schedule(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_schedule(sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
sequence.load_work_schedule_attributes(work_schedule)
|
||||
sequence.enable_editing_work_schedule(work_schedule)
|
||||
|
||||
|
||||
def enable_editing_work_schedule_tasks(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_schedule_tasks(
|
||||
sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
sequence.enable_editing_work_schedule_tasks(work_schedule)
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def load_task_tree(sequence: tool.Sequence, work_schedule) -> None:
|
||||
def load_task_tree(sequence: type[tool.Sequence], work_schedule) -> None:
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def expand_task(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def expand_task(sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
sequence.expand_task(task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def expand_all_tasks(sequence: tool.Sequence) -> None:
|
||||
def expand_all_tasks(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.expand_all_tasks()
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def contract_task(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def contract_task(sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
sequence.contract_task(task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def contract_all_tasks(sequence: tool.Sequence) -> None:
|
||||
def contract_all_tasks(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.contract_all_tasks()
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def remove_task(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def remove_task(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.remove_task", task=task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
@@ -132,22 +136,24 @@ def remove_task(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entit
|
||||
sequence.disable_selecting_deleted_task()
|
||||
|
||||
|
||||
def load_task_properties(sequence: tool.Sequence) -> None:
|
||||
def load_task_properties(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def disable_editing_work_schedule(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_work_schedule(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_work_schedule()
|
||||
|
||||
|
||||
def add_summary_task(ifc: tool.Ifc, sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def add_summary_task(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("sequence.add_task", work_schedule=work_schedule)
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def add_task(
|
||||
ifc: tool.Ifc, sequence: tool.Sequence, parent_task: Optional[ifcopenshell.entity_instance] = None
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], parent_task: Optional[ifcopenshell.entity_instance] = None
|
||||
) -> None:
|
||||
ifc.run("sequence.add_task", parent_task=parent_task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
@@ -155,19 +161,19 @@ def add_task(
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def enable_editing_task_attributes(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_task_attributes(sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
sequence.load_task_attributes(task)
|
||||
sequence.enable_editing_task_attributes(task)
|
||||
|
||||
|
||||
def edit_task(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def edit_task(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
attributes = sequence.get_task_attributes()
|
||||
ifc.run("sequence.edit_task", task=task, attributes=attributes)
|
||||
sequence.load_task_properties(task=task)
|
||||
sequence.disable_editing_task()
|
||||
|
||||
|
||||
def copy_task_attribute(ifc: tool.Ifc, sequence: tool.Sequence, attribute_name: str) -> None:
|
||||
def copy_task_attribute(ifc: type[tool.Ifc], sequence: type[tool.Sequence], attribute_name: str) -> None:
|
||||
for task in sequence.get_checked_tasks():
|
||||
ifc.run(
|
||||
"sequence.edit_task",
|
||||
@@ -177,18 +183,20 @@ def copy_task_attribute(ifc: tool.Ifc, sequence: tool.Sequence, attribute_name:
|
||||
sequence.load_task_properties(task)
|
||||
|
||||
|
||||
def duplicate_task(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def duplicate_task(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.duplicate_task", task=task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
sequence.load_task_tree(work_schedule)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def disable_editing_task(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_task(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_task()
|
||||
|
||||
|
||||
def enable_editing_task_time(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_task_time(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
task_time = sequence.get_task_time(task)
|
||||
if task_time is None:
|
||||
task_time = ifc.run("sequence.add_task_time", task=task)
|
||||
@@ -196,7 +204,9 @@ def enable_editing_task_time(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcop
|
||||
sequence.enable_editing_task_time(task)
|
||||
|
||||
|
||||
def edit_task_time(ifc: tool.Ifc, sequence: tool.Sequence, resource, task_time: ifcopenshell.entity_instance) -> None:
|
||||
def edit_task_time(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], resource, task_time: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
attributes = sequence.get_task_time_attributes()
|
||||
# TODO: nasty loop goes on when calendar props are messed up
|
||||
ifc.run("sequence.edit_task_time", task_time=task_time, attributes=attributes)
|
||||
@@ -206,34 +216,36 @@ def edit_task_time(ifc: tool.Ifc, sequence: tool.Sequence, resource, task_time:
|
||||
resource.load_resource_properties()
|
||||
|
||||
|
||||
def assign_predecessor(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def assign_predecessor(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
predecessor_task = sequence.get_highlighted_task()
|
||||
ifc.run("sequence.assign_sequence", relating_process=task, related_process=predecessor_task)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def unassign_predecessor(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_predecessor(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
predecessor_task = sequence.get_highlighted_task()
|
||||
ifc.run("sequence.unassign_sequence", relating_process=task, related_process=predecessor_task)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def assign_successor(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def assign_successor(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
successor_task = sequence.get_highlighted_task()
|
||||
ifc.run("sequence.assign_sequence", relating_process=successor_task, related_process=task)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def unassign_successor(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_successor(ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
successor_task = sequence.get_highlighted_task()
|
||||
ifc.run("sequence.unassign_sequence", relating_process=successor_task, related_process=task)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def assign_products(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
spatial: type[tool.Spatial],
|
||||
task: ifcopenshell.entity_instance,
|
||||
products: Optional[list[ifcopenshell.entity_instance]] = None,
|
||||
) -> None:
|
||||
@@ -244,9 +256,9 @@ def assign_products(
|
||||
|
||||
|
||||
def unassign_products(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
spatial: type[tool.Spatial],
|
||||
task: ifcopenshell.entity_instance,
|
||||
products: Optional[list[ifcopenshell.entity_instance]] = None,
|
||||
) -> None:
|
||||
@@ -257,9 +269,9 @@ def unassign_products(
|
||||
|
||||
|
||||
def assign_input_products(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
spatial: type[tool.Spatial],
|
||||
task: ifcopenshell.entity_instance,
|
||||
products: Optional[list[ifcopenshell.entity_instance]] = None,
|
||||
) -> None:
|
||||
@@ -270,9 +282,9 @@ def assign_input_products(
|
||||
|
||||
|
||||
def unassign_input_products(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
spatial: type[tool.Spatial],
|
||||
task: ifcopenshell.entity_instance,
|
||||
products: Optional[list[ifcopenshell.entity_instance]] = None,
|
||||
) -> None:
|
||||
@@ -282,7 +294,9 @@ def unassign_input_products(
|
||||
sequence.load_task_inputs(inputs)
|
||||
|
||||
|
||||
def assign_resource(ifc: tool.Ifc, sequence: tool.Sequence, resource_tool, task: ifcopenshell.entity_instance) -> None:
|
||||
def assign_resource(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], resource_tool, task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
resource = resource_tool.get_highlighted_resource()
|
||||
sub_resource = ifc.run(
|
||||
"resource.add_resource",
|
||||
@@ -296,8 +310,8 @@ def assign_resource(ifc: tool.Ifc, sequence: tool.Sequence, resource_tool, task:
|
||||
|
||||
|
||||
def unassign_resource(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
resource_tool,
|
||||
task: ifcopenshell.entity_instance,
|
||||
resource: ifcopenshell.entity_instance,
|
||||
@@ -308,54 +322,58 @@ def unassign_resource(
|
||||
resource_tool.load_resources()
|
||||
|
||||
|
||||
def remove_work_calendar(ifc: tool.Ifc, work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
def remove_work_calendar(ifc: type[tool.Ifc], work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.remove_work_calendar", work_calendar=work_calendar)
|
||||
|
||||
|
||||
def add_work_calendar(ifc: tool.Ifc) -> ifcopenshell.entity_instance:
|
||||
def add_work_calendar(ifc: type[tool.Ifc]) -> ifcopenshell.entity_instance:
|
||||
return ifc.run("sequence.add_work_calendar")
|
||||
|
||||
|
||||
def edit_work_calendar(ifc: tool.Ifc, sequence: tool.Sequence, work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
def edit_work_calendar(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], work_calendar: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
attributes = sequence.get_work_calendar_attributes()
|
||||
ifc.run("sequence.edit_work_calendar", work_calendar=work_calendar, attributes=attributes)
|
||||
sequence.disable_editing_work_calendar()
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def enable_editing_work_calendar(sequence: tool.Sequence, work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_calendar(sequence: type[tool.Sequence], work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
sequence.load_work_calendar_attributes(work_calendar)
|
||||
sequence.enable_editing_work_calendar(work_calendar)
|
||||
|
||||
|
||||
def disable_editing_work_calendar(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_work_calendar(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_work_calendar()
|
||||
|
||||
|
||||
def enable_editing_work_calendar_times(sequence: tool.Sequence, work_calendar: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_calendar_times(
|
||||
sequence: type[tool.Sequence], work_calendar: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
sequence.enable_editing_work_calendar_times(work_calendar)
|
||||
|
||||
|
||||
def add_work_time(
|
||||
ifc: tool.Ifc, work_calendar: ifcopenshell.entity_instance, time_type: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc], work_calendar: ifcopenshell.entity_instance, time_type: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
return ifc.run("sequence.add_work_time", work_calendar=work_calendar, time_type=time_type)
|
||||
|
||||
|
||||
def enable_editing_work_time(sequence: tool.Sequence, work_time: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_work_time(sequence: type[tool.Sequence], work_time: ifcopenshell.entity_instance) -> None:
|
||||
sequence.load_work_time_attributes(work_time)
|
||||
sequence.enable_editing_work_time(work_time)
|
||||
|
||||
|
||||
def disable_editing_work_time(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_work_time(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_work_time()
|
||||
|
||||
|
||||
def remove_work_time(ifc: tool.Ifc, work_time=None) -> None:
|
||||
def remove_work_time(ifc: type[tool.Ifc], work_time=None) -> None:
|
||||
ifc.run("sequence.remove_work_time", work_time=work_time)
|
||||
|
||||
|
||||
def edit_work_time(ifc: tool.Ifc, sequence: tool.Sequence) -> None:
|
||||
def edit_work_time(ifc: type[tool.Ifc], sequence: type[tool.Sequence]) -> None:
|
||||
work_time = sequence.get_active_work_time()
|
||||
ifc.run("sequence.edit_work_time", work_time=work_time, attributes=sequence.get_work_time_attributes())
|
||||
recurrence_pattern = work_time.RecurrencePattern
|
||||
@@ -369,32 +387,34 @@ def edit_work_time(ifc: tool.Ifc, sequence: tool.Sequence) -> None:
|
||||
|
||||
|
||||
def assign_recurrence_pattern(
|
||||
ifc: tool.Ifc, work_time: ifcopenshell.entity_instance, recurrence_type: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc], work_time: ifcopenshell.entity_instance, recurrence_type: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
return ifc.run("sequence.assign_recurrence_pattern", parent=work_time, recurrence_type=recurrence_type)
|
||||
|
||||
|
||||
def unassign_recurrence_pattern(ifc: tool.Ifc, recurrence_pattern: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_recurrence_pattern(ifc: type[tool.Ifc], recurrence_pattern: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.unassign_recurrence_pattern", recurrence_pattern=recurrence_pattern)
|
||||
|
||||
|
||||
def add_time_period(ifc: tool.Ifc, sequence: tool.Sequence, recurrence_pattern: ifcopenshell.entity_instance) -> None:
|
||||
def add_time_period(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], recurrence_pattern: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
start_time, end_time = sequence.get_recurrence_pattern_times()
|
||||
ifc.run("sequence.add_time_period", recurrence_pattern=recurrence_pattern, start_time=start_time, end_time=end_time)
|
||||
sequence.reset_time_period()
|
||||
|
||||
|
||||
def remove_time_period(ifc: tool.Ifc, time_period: ifcopenshell.entity_instance) -> None:
|
||||
def remove_time_period(ifc: type[tool.Ifc], time_period: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.remove_time_period", time_period=time_period)
|
||||
|
||||
|
||||
def enable_editing_task_calendar(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_task_calendar(sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> None:
|
||||
sequence.enable_editing_task_calendar(task)
|
||||
|
||||
|
||||
def edit_task_calendar(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
task: ifcopenshell.entity_instance,
|
||||
work_calendar: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
@@ -404,8 +424,8 @@ def edit_task_calendar(
|
||||
|
||||
|
||||
def remove_task_calendar(
|
||||
ifc: tool.Ifc,
|
||||
sequence: tool.Sequence,
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
task: ifcopenshell.entity_instance,
|
||||
work_calendar: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
@@ -414,38 +434,42 @@ def remove_task_calendar(
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def enable_editing_task_sequence(sequence: tool.Sequence) -> None:
|
||||
def enable_editing_task_sequence(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.enable_editing_task_sequence()
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def disable_editing_task_time(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_task_time(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_task_time()
|
||||
|
||||
|
||||
def enable_editing_sequence_attributes(sequence: tool.Sequence, rel_sequence: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_sequence_attributes(
|
||||
sequence: type[tool.Sequence], rel_sequence: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
sequence.enable_editing_rel_sequence_attributes(rel_sequence)
|
||||
sequence.load_rel_sequence_attributes(rel_sequence)
|
||||
|
||||
|
||||
def enable_editing_sequence_lag_time(
|
||||
sequence: tool.Sequence, rel_sequence: ifcopenshell.entity_instance, lag_time: ifcopenshell.entity_instance
|
||||
sequence: type[tool.Sequence], rel_sequence: ifcopenshell.entity_instance, lag_time: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
sequence.load_lag_time_attributes(lag_time)
|
||||
sequence.enable_editing_sequence_lag_time(rel_sequence)
|
||||
|
||||
|
||||
def unassign_lag_time(ifc: tool.Ifc, sequence: tool.Sequence, rel_sequence: ifcopenshell.entity_instance) -> None:
|
||||
def unassign_lag_time(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], rel_sequence: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("sequence.unassign_lag_time", rel_sequence=rel_sequence)
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def assign_lag_time(ifc: tool.Ifc, rel_sequence: ifcopenshell.entity_instance) -> None:
|
||||
def assign_lag_time(ifc: type[tool.Ifc], rel_sequence: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.assign_lag_time", rel_sequence=rel_sequence, lag_value="P1D")
|
||||
|
||||
|
||||
def edit_sequence_attributes(
|
||||
ifc: tool.Ifc, sequence: tool.Sequence, rel_sequence: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], rel_sequence: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
attributes = sequence.get_rel_sequence_attributes()
|
||||
ifc.run("sequence.edit_sequence", rel_sequence=rel_sequence, attributes=attributes)
|
||||
@@ -453,33 +477,41 @@ def edit_sequence_attributes(
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def edit_sequence_lag_time(ifc: tool.Ifc, sequence: tool.Sequence, lag_time: ifcopenshell.entity_instance) -> None:
|
||||
def edit_sequence_lag_time(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], lag_time: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
attributes = sequence.get_lag_time_attributes()
|
||||
ifc.run("sequence.edit_lag_time", lag_time=lag_time, attributes=attributes)
|
||||
sequence.disable_editing_rel_sequence()
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def disable_editing_rel_sequence(sequence: tool.Sequence) -> None:
|
||||
def disable_editing_rel_sequence(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.disable_editing_rel_sequence()
|
||||
|
||||
|
||||
def select_task_outputs(sequence: tool.Sequence, spatial: tool.Spatial, task: ifcopenshell.entity_instance) -> None:
|
||||
def select_task_outputs(
|
||||
sequence: type[tool.Sequence], spatial: type[tool.Spatial], task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
spatial.select_products(products=sequence.get_task_outputs(task))
|
||||
|
||||
|
||||
def select_task_inputs(sequence: tool.Sequence, spatial: tool.Spatial, task: ifcopenshell.entity_instance) -> None:
|
||||
def select_task_inputs(
|
||||
sequence: type[tool.Sequence], spatial: type[tool.Spatial], task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
spatial.select_products(products=sequence.get_task_inputs(task))
|
||||
|
||||
|
||||
def select_work_schedule_products(
|
||||
sequence: tool.Sequence, spatial: tool.Spatial, work_schedule: ifcopenshell.entity_instance
|
||||
sequence: type[tool.Sequence], spatial: type[tool.Spatial], work_schedule: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
products = sequence.get_work_schedule_products(work_schedule)
|
||||
spatial.select_products(products)
|
||||
|
||||
|
||||
def select_unassigned_work_schedule_products(ifc: tool.Ifc, sequence: tool.Sequence, spatial: tool.Spatial) -> None:
|
||||
def select_unassigned_work_schedule_products(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], spatial: type[tool.Spatial]
|
||||
) -> None:
|
||||
spatial.deselect_objects()
|
||||
products = ifc.get().by_type("IfcElement")
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
@@ -488,11 +520,11 @@ def select_unassigned_work_schedule_products(ifc: tool.Ifc, sequence: tool.Seque
|
||||
spatial.select_products(selection)
|
||||
|
||||
|
||||
def recalculate_schedule(ifc: tool.Ifc, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def recalculate_schedule(ifc: type[tool.Ifc], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("sequence.recalculate_schedule", work_schedule=work_schedule)
|
||||
|
||||
|
||||
def add_task_column(sequence: tool.Sequence, column_type: str, name: str, data_type: str) -> None:
|
||||
def add_task_column(sequence: type[tool.Sequence], column_type: str, name: str, data_type: str) -> None:
|
||||
sequence.add_task_column(column_type, name, data_type)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
if work_schedule:
|
||||
@@ -500,11 +532,11 @@ def add_task_column(sequence: tool.Sequence, column_type: str, name: str, data_t
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def remove_task_column(sequence: tool.Sequence, name: str) -> None:
|
||||
def remove_task_column(sequence: type[tool.Sequence], name: str) -> None:
|
||||
sequence.remove_task_column(name)
|
||||
|
||||
|
||||
def set_task_sort_column(sequence: tool.Sequence, column: str) -> None:
|
||||
def set_task_sort_column(sequence: type[tool.Sequence], column: str) -> None:
|
||||
sequence.set_task_sort_column(column)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
if work_schedule:
|
||||
@@ -512,7 +544,9 @@ def set_task_sort_column(sequence: tool.Sequence, column: str) -> None:
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def calculate_task_duration(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> None:
|
||||
def calculate_task_duration(
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
ifc.run("sequence.calculate_task_duration", task=task)
|
||||
work_schedule = sequence.get_active_work_schedule()
|
||||
if work_schedule:
|
||||
@@ -520,11 +554,13 @@ def calculate_task_duration(ifc: tool.Ifc, sequence: tool.Sequence, task: ifcope
|
||||
sequence.load_task_properties()
|
||||
|
||||
|
||||
def load_animation_color_scheme(sequence: tool.Sequence, scheme: Union[ifcopenshell.entity_instance, None]) -> None:
|
||||
def load_animation_color_scheme(
|
||||
sequence: type[tool.Sequence], scheme: Union[ifcopenshell.entity_instance, None]
|
||||
) -> None:
|
||||
sequence.load_animation_color_scheme(scheme)
|
||||
|
||||
|
||||
def go_to_task(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> Union[None, str]:
|
||||
def go_to_task(sequence: type[tool.Sequence], task: ifcopenshell.entity_instance) -> Union[None, str]:
|
||||
work_schedule = sequence.get_work_schedule(task)
|
||||
is_work_schedule_active = sequence.is_work_schedule_active(work_schedule)
|
||||
if is_work_schedule_active:
|
||||
@@ -533,26 +569,28 @@ def go_to_task(sequence: tool.Sequence, task: ifcopenshell.entity_instance) -> U
|
||||
return "Work schedule is not active"
|
||||
|
||||
|
||||
def guess_date_range(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def guess_date_range(sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
start, finish = sequence.guess_date_range(work_schedule)
|
||||
sequence.update_visualisation_date(start, finish)
|
||||
|
||||
|
||||
def setup_default_task_columns(sequence: tool.Sequence) -> None:
|
||||
def setup_default_task_columns(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.setup_default_task_columns()
|
||||
|
||||
|
||||
def add_task_bars(sequence: tool.Sequence) -> None:
|
||||
def add_task_bars(sequence: type[tool.Sequence]) -> None:
|
||||
tasks = sequence.get_animation_bar_tasks()
|
||||
if tasks:
|
||||
sequence.create_bars(tasks)
|
||||
|
||||
|
||||
def load_default_animation_color_scheme(sequence: tool.Sequence) -> None:
|
||||
def load_default_animation_color_scheme(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.load_default_animation_color_scheme()
|
||||
|
||||
|
||||
def visualise_work_schedule_date_range(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def visualise_work_schedule_date_range(
|
||||
sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
sequence.clear_objects_animation(include_blender_objects=False)
|
||||
settings = sequence.get_animation_settings()
|
||||
if settings:
|
||||
@@ -566,7 +604,7 @@ def visualise_work_schedule_date_range(sequence: tool.Sequence, work_schedule: i
|
||||
sequence.set_object_shading()
|
||||
|
||||
|
||||
def visualise_work_schedule_date(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def visualise_work_schedule_date(sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
sequence.clear_objects_animation(include_blender_objects=False)
|
||||
start_date = sequence.get_start_date()
|
||||
product_states = sequence.process_construction_state(work_schedule, start_date)
|
||||
@@ -574,13 +612,13 @@ def visualise_work_schedule_date(sequence: tool.Sequence, work_schedule: ifcopen
|
||||
sequence.set_object_shading()
|
||||
|
||||
|
||||
def generate_gantt_chart(sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
def generate_gantt_chart(sequence: type[tool.Sequence], work_schedule: ifcopenshell.entity_instance) -> None:
|
||||
json = sequence.create_tasks_json(work_schedule)
|
||||
sequence.generate_gantt_browser_chart(json, work_schedule)
|
||||
|
||||
|
||||
def load_product_related_tasks(
|
||||
sequence: tool.Sequence, product: ifcopenshell.entity_instance
|
||||
sequence: type[tool.Sequence], product: ifcopenshell.entity_instance
|
||||
) -> Union[list[ifcopenshell.entity_instance], str]:
|
||||
filter_by_schedule = sequence.is_filter_by_active_schedule()
|
||||
if filter_by_schedule:
|
||||
@@ -596,7 +634,7 @@ def load_product_related_tasks(
|
||||
|
||||
|
||||
def reorder_task_nesting(
|
||||
ifc: tool.Ifc, sequence: tool.Sequence, task: ifcopenshell.entity_instance, new_index: int
|
||||
ifc: type[tool.Ifc], sequence: type[tool.Sequence], task: ifcopenshell.entity_instance, new_index: int
|
||||
) -> Union[None, str]:
|
||||
is_sorting_enabled = sequence.is_sorting_enabled()
|
||||
is_sort_reversed = sequence.is_sort_reversed()
|
||||
@@ -610,18 +648,21 @@ def reorder_task_nesting(
|
||||
|
||||
|
||||
def create_baseline(
|
||||
ifc: tool.Ifc, sequence: tool.Sequence, work_schedule: ifcopenshell.entity_instance, name: Optional[str] = None
|
||||
ifc: type[tool.Ifc],
|
||||
sequence: type[tool.Sequence],
|
||||
work_schedule: ifcopenshell.entity_instance,
|
||||
name: Optional[str] = None,
|
||||
) -> None:
|
||||
ifc.run("sequence.create_baseline", work_schedule=work_schedule, name=name)
|
||||
|
||||
|
||||
def clear_previous_animation(sequence: tool.Sequence) -> None:
|
||||
def clear_previous_animation(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.clear_objects_animation(include_blender_objects=False)
|
||||
|
||||
|
||||
def add_animation_camera(sequence: tool.Sequence) -> None:
|
||||
def add_animation_camera(sequence: type[tool.Sequence]) -> None:
|
||||
sequence.add_animation_camera()
|
||||
|
||||
|
||||
def save_animation_color_scheme(sequence: tool.Sequence, name: str) -> None:
|
||||
def save_animation_color_scheme(sequence: type[tool.Sequence], name: str) -> None:
|
||||
sequence.save_animation_color_scheme(name)
|
||||
|
||||
@@ -26,8 +26,8 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def reference_structure(
|
||||
ifc: tool.Ifc,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
spatial: type[tool.Spatial],
|
||||
structure: Optional[ifcopenshell.entity_instance] = None,
|
||||
element: Optional[ifcopenshell.entity_instance] = None,
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
@@ -36,8 +36,8 @@ def reference_structure(
|
||||
|
||||
|
||||
def dereference_structure(
|
||||
ifc: tool.Ifc,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
spatial: type[tool.Spatial],
|
||||
structure: Optional[ifcopenshell.entity_instance] = None,
|
||||
element: Optional[ifcopenshell.entity_instance] = None,
|
||||
) -> None:
|
||||
@@ -46,9 +46,9 @@ def dereference_structure(
|
||||
|
||||
|
||||
def assign_container(
|
||||
ifc: tool.Ifc,
|
||||
collector: tool.Collector,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
collector: type[tool.Collector],
|
||||
spatial: type[tool.Spatial],
|
||||
container: ifcopenshell.entity_instance,
|
||||
element_obj: Optional[bpy.types.Object] = None,
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
@@ -61,24 +61,24 @@ def assign_container(
|
||||
return rel
|
||||
|
||||
|
||||
def enable_editing_container(spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
def enable_editing_container(spatial: type[tool.Spatial], obj: bpy.types.Object) -> None:
|
||||
spatial.set_target_container_as_default()
|
||||
spatial.enable_editing(obj)
|
||||
|
||||
|
||||
def disable_editing_container(spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
def disable_editing_container(spatial: type[tool.Spatial], obj: bpy.types.Object) -> None:
|
||||
spatial.disable_editing(obj)
|
||||
|
||||
|
||||
def remove_container(ifc: tool.Ifc, collector: tool.Collector, obj: bpy.types.Object) -> None:
|
||||
def remove_container(ifc: type[tool.Ifc], collector: type[tool.Collector], obj: bpy.types.Object) -> None:
|
||||
ifc.run("spatial.unassign_container", products=[ifc.get_entity(obj)])
|
||||
collector.assign(obj)
|
||||
|
||||
|
||||
def copy_to_container(
|
||||
ifc: tool.Ifc,
|
||||
collector: tool.Collector,
|
||||
spatial: tool.Spatial,
|
||||
ifc: type[tool.Ifc],
|
||||
collector: type[tool.Collector],
|
||||
spatial: type[tool.Spatial],
|
||||
obj: bpy.types.Object,
|
||||
containers: list[ifcopenshell.entity_instance],
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
@@ -102,57 +102,71 @@ def copy_to_container(
|
||||
|
||||
|
||||
def select_container(
|
||||
ifc: tool.Ifc, spatial: tool.Spatial, container: ifcopenshell.entity_instance, selection_mode: str = "ADD"
|
||||
ifc: type[tool.Ifc],
|
||||
spatial: type[tool.Spatial],
|
||||
container: ifcopenshell.entity_instance,
|
||||
selection_mode: str = "ADD",
|
||||
) -> None:
|
||||
spatial.set_active_object(ifc.get_object(container), selection_mode=selection_mode)
|
||||
|
||||
|
||||
def select_similar_container(ifc: tool.Ifc, spatial: tool.Spatial, obj: bpy.types.Object) -> None:
|
||||
def select_similar_container(ifc: type[tool.Ifc], spatial: type[tool.Spatial], obj: bpy.types.Object) -> None:
|
||||
element = ifc.get_entity(obj)
|
||||
if element:
|
||||
spatial.select_products(spatial.get_decomposed_elements(spatial.get_container(element)))
|
||||
|
||||
|
||||
def select_product(spatial: tool.Spatial, product: ifcopenshell.entity_instance) -> None:
|
||||
def select_product(spatial: type[tool.Spatial], product: ifcopenshell.entity_instance) -> None:
|
||||
spatial.select_products([product])
|
||||
|
||||
|
||||
def import_spatial_decomposition(spatial: tool.Spatial) -> None:
|
||||
def import_spatial_decomposition(spatial: type[tool.Spatial]) -> None:
|
||||
spatial.import_spatial_decomposition()
|
||||
|
||||
|
||||
def set_orientation_slot(spatial: tool.Spatial, container: ifcopenshell.entity_instance) -> None:
|
||||
def set_orientation_slot(spatial: type[tool.Spatial], container: ifcopenshell.entity_instance) -> None:
|
||||
spatial.create_orientation_slot(container)
|
||||
|
||||
|
||||
def contract_container(spatial: tool.Spatial, container: ifcopenshell.entity_instance, is_recursive: bool) -> None:
|
||||
def contract_container(
|
||||
spatial: type[tool.Spatial], container: ifcopenshell.entity_instance, is_recursive: bool
|
||||
) -> None:
|
||||
spatial.contract_container(container, is_recursive=is_recursive)
|
||||
spatial.import_spatial_decomposition()
|
||||
|
||||
|
||||
def expand_container(spatial: tool.Spatial, container: ifcopenshell.entity_instance, is_recursive: bool) -> None:
|
||||
def expand_container(spatial: type[tool.Spatial], container: ifcopenshell.entity_instance, is_recursive: bool) -> None:
|
||||
spatial.expand_container(container, is_recursive=is_recursive)
|
||||
spatial.import_spatial_decomposition()
|
||||
|
||||
|
||||
def delete_container(
|
||||
ifc: tool.Ifc, spatial: tool.Spatial, geometry: tool.Geometry, container: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc],
|
||||
spatial: type[tool.Spatial],
|
||||
geometry: type[tool.Geometry],
|
||||
container: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
geometry.delete_ifc_object(ifc.get_object(container))
|
||||
spatial.import_spatial_decomposition()
|
||||
|
||||
|
||||
def toggle_container_element(spatial: tool.Spatial, element_index: int, is_recursive: bool) -> None:
|
||||
def toggle_container_element(spatial: type[tool.Spatial], element_index: int, is_recursive: bool) -> None:
|
||||
spatial.toggle_container_element(element_index, is_recursive=is_recursive)
|
||||
spatial.load_contained_elements()
|
||||
|
||||
|
||||
def select_decomposed_element(ifc: tool.Ifc, spatial: tool.Spatial, element: ifcopenshell.entity_instance) -> None:
|
||||
def select_decomposed_element(
|
||||
ifc: type[tool.Ifc], spatial: type[tool.Spatial], element: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
spatial.set_active_object(ifc.get_object(element))
|
||||
|
||||
|
||||
def generate_space(
|
||||
ifc: tool.Ifc, model: tool.Model, root: tool.Root, spatial: tool.Spatial, type: tool.Type
|
||||
ifc: type[tool.Ifc],
|
||||
model: type[tool.Model],
|
||||
root: type[tool.Root],
|
||||
spatial: type[tool.Spatial],
|
||||
type: type[tool.Type],
|
||||
) -> Union[None, str]:
|
||||
"""
|
||||
:return: None if successful, error message string if not.
|
||||
@@ -217,7 +231,9 @@ def generate_space(
|
||||
spatial.import_spatial_decomposition()
|
||||
|
||||
|
||||
def generate_spaces_from_walls(ifc: tool.Ifc, spatial: tool.Spatial, collector: tool.Collector) -> None:
|
||||
def generate_spaces_from_walls(
|
||||
ifc: type[tool.Ifc], spatial: type[tool.Spatial], collector: type[tool.Collector]
|
||||
) -> None:
|
||||
z = spatial.get_active_obj_z()
|
||||
h = spatial.get_active_obj_height()
|
||||
|
||||
@@ -237,7 +253,7 @@ def generate_spaces_from_walls(ifc: tool.Ifc, spatial: tool.Spatial, collector:
|
||||
spatial.assign_ifcspace_class_to_obj(obj)
|
||||
|
||||
|
||||
def toggle_space_visibility(ifc: tool.Ifc, spatial: tool.Spatial) -> None:
|
||||
def toggle_space_visibility(ifc: type[tool.Ifc], spatial: type[tool.Spatial]) -> None:
|
||||
model = ifc.get()
|
||||
spaces = model.by_type("IfcSpace")
|
||||
if not spaces:
|
||||
@@ -245,7 +261,7 @@ def toggle_space_visibility(ifc: tool.Ifc, spatial: tool.Spatial) -> None:
|
||||
spatial.toggle_spaces_visibility_wired_and_textured(spaces)
|
||||
|
||||
|
||||
def toggle_hide_spaces(ifc: tool.Ifc, spatial: tool.Spatial) -> None:
|
||||
def toggle_hide_spaces(ifc: type[tool.Ifc], spatial: type[tool.Spatial]) -> None:
|
||||
model = ifc.get()
|
||||
spaces = model.by_type("IfcSpace")
|
||||
if not spaces:
|
||||
@@ -253,7 +269,7 @@ def toggle_hide_spaces(ifc: tool.Ifc, spatial: tool.Spatial) -> None:
|
||||
spatial.toggle_hide_spaces(spaces)
|
||||
|
||||
|
||||
def set_default_container(spatial: tool.Spatial, container: ifcopenshell.entity_instance) -> None:
|
||||
def set_default_container(spatial: type[tool.Spatial], container: ifcopenshell.entity_instance) -> None:
|
||||
spatial.set_default_container(container)
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def add_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural) -> ifcopenshell.entity_instance:
|
||||
def add_structural_analysis_model(
|
||||
ifc: type[tool.Ifc], structural: type[tool.Structural]
|
||||
) -> ifcopenshell.entity_instance:
|
||||
result = ifc.run("structural.add_structural_analysis_model")
|
||||
structural.load_structural_analysis_models()
|
||||
structural.ensure_representation_contexts()
|
||||
@@ -33,7 +35,7 @@ def add_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural) ->
|
||||
|
||||
|
||||
def assign_structural_analysis_model(
|
||||
ifc: tool.Ifc,
|
||||
ifc: type[tool.Ifc],
|
||||
products: list[ifcopenshell.entity_instance],
|
||||
structural_analysis_model: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
@@ -44,15 +46,15 @@ def assign_structural_analysis_model(
|
||||
)
|
||||
|
||||
|
||||
def disable_editing_structural_analysis_model(structural: tool.Structural) -> None:
|
||||
def disable_editing_structural_analysis_model(structural: type[tool.Structural]) -> None:
|
||||
structural.disable_editing_structural_analysis_model()
|
||||
|
||||
|
||||
def disable_structural_analysis_model_editing_ui(structural: tool.Structural) -> None:
|
||||
def disable_structural_analysis_model_editing_ui(structural: type[tool.Structural]) -> None:
|
||||
structural.disable_structural_analysis_model_editing_ui()
|
||||
|
||||
|
||||
def edit_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural) -> None:
|
||||
def edit_structural_analysis_model(ifc: type[tool.Ifc], structural: type[tool.Structural]) -> None:
|
||||
attributes = structural.get_structural_analysis_model_attributes()
|
||||
ifc.run(
|
||||
"structural.edit_structural_analysis_model",
|
||||
@@ -63,28 +65,28 @@ def edit_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural) -
|
||||
structural.disable_editing_structural_analysis_model()
|
||||
|
||||
|
||||
def enable_editing_structural_analysis_model(structural: tool.Structural, model: Union[int, None]) -> None:
|
||||
def enable_editing_structural_analysis_model(structural: type[tool.Structural], model: Union[int, None]) -> None:
|
||||
structural.enable_editing_structural_analysis_model(model)
|
||||
|
||||
|
||||
def enable_structural_analysis_model_editing_ui(structural: tool.Structural) -> None:
|
||||
def enable_structural_analysis_model_editing_ui(structural: type[tool.Structural]) -> None:
|
||||
structural.enable_structural_analysis_model_editing_ui()
|
||||
|
||||
|
||||
def load_structural_analysis_model_attributes(structural: tool.Structural, model: Union[int, None]) -> None:
|
||||
def load_structural_analysis_model_attributes(structural: type[tool.Structural], model: Union[int, None]) -> None:
|
||||
data = structural.get_ifc_structural_analysis_model_attributes(model)
|
||||
if data is None:
|
||||
return
|
||||
structural.load_structural_analysis_model_attributes(data)
|
||||
|
||||
|
||||
def load_structural_analysis_models(structural: tool.Structural) -> None:
|
||||
def load_structural_analysis_models(structural: type[tool.Structural]) -> None:
|
||||
structural.load_structural_analysis_models()
|
||||
structural.enable_structural_analysis_model_editing_ui()
|
||||
# structural.disable_editing_structural_analysis_model()
|
||||
|
||||
|
||||
def remove_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural, model: int) -> None:
|
||||
def remove_structural_analysis_model(ifc: type[tool.Ifc], structural: type[tool.Structural], model: int) -> None:
|
||||
ifc.run(
|
||||
"structural.remove_structural_analysis_model",
|
||||
structural_analysis_model=ifc.get().by_id(model),
|
||||
@@ -93,7 +95,7 @@ def remove_structural_analysis_model(ifc: tool.Ifc, structural: tool.Structural,
|
||||
|
||||
|
||||
def unassign_structural_analysis_model(
|
||||
ifc: tool.Ifc,
|
||||
ifc: type[tool.Ifc],
|
||||
products: list[ifcopenshell.entity_instance],
|
||||
structural_analysis_model: ifcopenshell.entity_instance,
|
||||
) -> None:
|
||||
|
||||
@@ -25,62 +25,62 @@ if TYPE_CHECKING:
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def load_systems(system: tool.System) -> None:
|
||||
def load_systems(system: type[tool.System]) -> None:
|
||||
system.import_systems()
|
||||
system.enable_system_editing_ui()
|
||||
system.disable_editing_system()
|
||||
|
||||
|
||||
def disable_system_editing_ui(system: tool.System) -> None:
|
||||
def disable_system_editing_ui(system: type[tool.System]) -> None:
|
||||
system.disable_editing_system()
|
||||
system.disable_system_editing_ui()
|
||||
|
||||
|
||||
def add_system(ifc: tool.Ifc, system: tool.System, ifc_class: str) -> None:
|
||||
def add_system(ifc: type[tool.Ifc], system: type[tool.System], ifc_class: str) -> None:
|
||||
ifc.run("system.add_system", ifc_class=ifc_class)
|
||||
system.import_systems()
|
||||
|
||||
|
||||
def edit_system(ifc: tool.Ifc, system_tool: tool.System, system: ifcopenshell.entity_instance) -> None:
|
||||
def edit_system(ifc: type[tool.Ifc], system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
|
||||
attributes = system_tool.export_system_attributes()
|
||||
ifc.run("system.edit_system", system=system, attributes=attributes)
|
||||
system_tool.disable_editing_system()
|
||||
system_tool.import_systems()
|
||||
|
||||
|
||||
def remove_system(ifc: tool.Ifc, system_tool: tool.System, system: ifcopenshell.entity_instance) -> None:
|
||||
def remove_system(ifc: type[tool.Ifc], system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("system.remove_system", system=system)
|
||||
system_tool.import_systems()
|
||||
|
||||
|
||||
def enable_editing_system(system_tool: tool.System, system: ifcopenshell.entity_instance) -> None:
|
||||
def enable_editing_system(system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
|
||||
system_tool.import_system_attributes(system)
|
||||
system_tool.set_active_edited_system(system)
|
||||
|
||||
|
||||
def disable_editing_system(system: tool.System) -> None:
|
||||
def disable_editing_system(system: type[tool.System]) -> None:
|
||||
system.disable_editing_system()
|
||||
|
||||
|
||||
def assign_system(
|
||||
ifc: tool.Ifc, system: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance]
|
||||
ifc: type[tool.Ifc], system: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance]
|
||||
) -> None:
|
||||
ifc.run("system.assign_system", products=products, system=system)
|
||||
|
||||
|
||||
def unassign_system(
|
||||
ifc: tool.Ifc, system: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance]
|
||||
ifc: type[tool.Ifc], system: ifcopenshell.entity_instance, products: list[ifcopenshell.entity_instance]
|
||||
) -> None:
|
||||
ifc.run("system.unassign_system", products=products, system=system)
|
||||
|
||||
|
||||
def select_system_products(system_tool: tool.System, system: ifcopenshell.entity_instance) -> None:
|
||||
def select_system_products(system_tool: type[tool.System], system: ifcopenshell.entity_instance) -> None:
|
||||
system_tool.select_system_products(system)
|
||||
system_tool.set_active_system(system)
|
||||
|
||||
|
||||
def show_ports(
|
||||
ifc: tool.Ifc, system: tool.System, spatial: tool.Spatial, element: ifcopenshell.entity_instance
|
||||
ifc: type[tool.Ifc], system: type[tool.System], spatial: type[tool.Spatial], element: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
obj = ifc.get_object(element)
|
||||
if obj and ifc.is_moved(obj):
|
||||
@@ -91,7 +91,7 @@ def show_ports(
|
||||
spatial.select_products(ports)
|
||||
|
||||
|
||||
def hide_ports(ifc: tool.Ifc, system: tool.System, element: ifcopenshell.entity_instance) -> None:
|
||||
def hide_ports(ifc: type[tool.Ifc], system: type[tool.System], element: ifcopenshell.entity_instance) -> None:
|
||||
obj = ifc.get_object(element)
|
||||
if obj and ifc.is_moved(obj):
|
||||
system.run_geometry_edit_object_placement(obj=obj)
|
||||
@@ -105,27 +105,29 @@ def hide_ports(ifc: tool.Ifc, system: tool.System, element: ifcopenshell.entity_
|
||||
system.delete_element_objects(ports)
|
||||
|
||||
|
||||
def add_port(ifc: tool.Ifc, system: tool.System, element: ifcopenshell.entity_instance) -> None:
|
||||
def add_port(ifc: type[tool.Ifc], system: type[tool.System], element: ifcopenshell.entity_instance) -> None:
|
||||
system.load_ports(element, system.get_ports(element))
|
||||
obj = system.create_empty_at_cursor_with_element_orientation(element)
|
||||
port = system.run_root_assign_class(obj=obj, ifc_class="IfcDistributionPort", should_add_representation=False)
|
||||
ifc.run("system.assign_port", element=element, port=port)
|
||||
|
||||
|
||||
def remove_port(ifc: tool.Ifc, system: tool.System, port: ifcopenshell.entity_instance) -> None:
|
||||
def remove_port(ifc: type[tool.Ifc], system: type[tool.System], port: ifcopenshell.entity_instance) -> None:
|
||||
system.delete_element_objects([port])
|
||||
ifc.run("root.remove_product", product=port)
|
||||
|
||||
|
||||
def connect_port(ifc: tool.Ifc, port1: ifcopenshell.entity_instance, port2: ifcopenshell.entity_instance) -> None:
|
||||
def connect_port(ifc: type[tool.Ifc], port1: ifcopenshell.entity_instance, port2: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("system.connect_port", port1=port1, port2=port2)
|
||||
|
||||
|
||||
def disconnect_port(ifc: tool.Ifc, port: ifcopenshell.entity_instance) -> None:
|
||||
def disconnect_port(ifc: type[tool.Ifc], port: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("system.disconnect_port", port=port)
|
||||
|
||||
|
||||
def set_flow_direction(ifc: tool.Ifc, system: tool.System, port: ifcopenshell.entity_instance, direction: str) -> None:
|
||||
def set_flow_direction(
|
||||
ifc: type[tool.Ifc], system: type[tool.System], port: ifcopenshell.entity_instance, direction: str
|
||||
) -> None:
|
||||
port2 = system.get_connected_port(port)
|
||||
if not port2:
|
||||
return
|
||||
|
||||
@@ -1,8 +1,35 @@
|
||||
def generate_port_number(web):
|
||||
# Bonsai - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 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
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import bonsai.tool as tool
|
||||
|
||||
|
||||
def generate_port_number(web: type[tool.Web]) -> int:
|
||||
return web.generate_port_number()
|
||||
|
||||
|
||||
def connect_websocket_server(web, port, page):
|
||||
def connect_websocket_server(web: type[tool.Web], port: int, page: str) -> None:
|
||||
# check if port already has a server listening to it
|
||||
if web.is_port_available(port):
|
||||
web.start_websocket_server(port)
|
||||
@@ -15,13 +42,13 @@ def connect_websocket_server(web, port, page):
|
||||
web.connect_websocket_server(port)
|
||||
|
||||
|
||||
def disconnect_websocket_server(web):
|
||||
def disconnect_websocket_server(web: type[tool.Web]) -> None:
|
||||
web.disconnect_websocket_server()
|
||||
|
||||
|
||||
def kill_websocket_server(web):
|
||||
def kill_websocket_server(web: type[tool.Web]) -> None:
|
||||
web.kill_websocket_server()
|
||||
|
||||
|
||||
def open_web_browser(web, port, page):
|
||||
def open_web_browser(web: type[tool.Web], port: int, page: str) -> None:
|
||||
web.open_web_browser(port, page)
|
||||
|
||||
@@ -159,7 +159,6 @@ class Project(bonsai.core.tool.Project):
|
||||
@classmethod
|
||||
def set_default_modeling_dimensions(cls) -> None:
|
||||
props = tool.Model.get_model_props()
|
||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
props.extrusion_depth = 3
|
||||
props.length = 1
|
||||
props.rl1 = 0
|
||||
|
||||
@@ -69,6 +69,7 @@ class Unit(bonsai.core.tool.Unit):
|
||||
def get_scene_unit_name(cls, unit_type: UNIT_TYPE) -> str:
|
||||
bim_props = tool.Blender.get_bim_props()
|
||||
if unit_type == "LENGTHUNIT":
|
||||
assert bpy.context.scene
|
||||
props = bpy.context.scene.unit_settings
|
||||
if props.length_unit == "MILES":
|
||||
return "mile"
|
||||
@@ -84,12 +85,13 @@ class Unit(bonsai.core.tool.Unit):
|
||||
elif unit_type == "VOLUMEUNIT":
|
||||
return bim_props.volume_unit
|
||||
else:
|
||||
assert_never()
|
||||
assert_never(unit_type)
|
||||
|
||||
@classmethod
|
||||
def get_scene_unit_si_prefix(cls, unit_type: UNIT_TYPE) -> Union[str, None]:
|
||||
bim_props = tool.Blender.get_bim_props()
|
||||
if unit_type == "LENGTHUNIT":
|
||||
assert bpy.context.scene
|
||||
props = bpy.context.scene.unit_settings
|
||||
if props.length_unit == "ADAPTIVE" or props.length_unit == "METERS":
|
||||
return
|
||||
@@ -163,6 +165,7 @@ class Unit(bonsai.core.tool.Unit):
|
||||
|
||||
@classmethod
|
||||
def is_scene_unit_metric(cls) -> bool:
|
||||
assert bpy.context.scene
|
||||
return bpy.context.scene.unit_settings.system in ["METRIC", "NONE"]
|
||||
|
||||
@classmethod
|
||||
@@ -189,6 +192,7 @@ class Unit(bonsai.core.tool.Unit):
|
||||
|
||||
@classmethod
|
||||
def blender_format_unit(cls, value: float) -> str:
|
||||
assert bpy.context.scene
|
||||
return bpy.utils.units.to_string(
|
||||
bpy.context.scene.unit_settings.system,
|
||||
"LENGTH",
|
||||
|
||||
Reference in New Issue
Block a user