mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
typing
This commit is contained in:
@@ -1952,7 +1952,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
if not material:
|
||||
continue
|
||||
if not (style := tool.Ifc.get_entity(material)):
|
||||
style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=material.name)
|
||||
style = ifcopenshell.api.style.add_style(ifc_file, name=material.name)
|
||||
if material.use_nodes:
|
||||
ifc_class = "IfcSurfaceStyleRendering"
|
||||
attributes = tool.Style.get_surface_rendering_attributes(material)
|
||||
|
||||
@@ -59,16 +59,16 @@ class Project(bonsai.core.tool.Project):
|
||||
bpy.ops.bim.append_library_element(definition=element.id())
|
||||
|
||||
@classmethod
|
||||
def create_empty(cls, name):
|
||||
def create_empty(cls, name: str) -> bpy.types.Object:
|
||||
return bpy.data.objects.new(name, None)
|
||||
|
||||
@classmethod
|
||||
def load_default_thumbnails(cls):
|
||||
def load_default_thumbnails(cls) -> None:
|
||||
if tool.Ifc.get().by_type("IfcElementType"):
|
||||
bpy.ops.bim.load_type_thumbnails()
|
||||
|
||||
@classmethod
|
||||
def load_pset_templates(cls):
|
||||
def load_pset_templates(cls) -> None:
|
||||
props = tool.Blender.get_bim_props()
|
||||
pset_dir = tool.Ifc.resolve_uri(props.pset_dir)
|
||||
if os.path.isdir(pset_dir):
|
||||
@@ -76,13 +76,21 @@ class Project(bonsai.core.tool.Project):
|
||||
bonsai.bim.schema.ifc.psetqto.templates.append(ifcopenshell.open(path))
|
||||
|
||||
@classmethod
|
||||
def run_aggregate_assign_object(cls, relating_obj=None, related_obj=None):
|
||||
def run_aggregate_assign_object(
|
||||
cls, relating_obj: Optional[bpy.types.Object] = None, related_obj: Optional[bpy.types.Object] = None
|
||||
):
|
||||
return bonsai.core.aggregate.assign_object(
|
||||
tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=relating_obj, related_obj=related_obj
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def run_context_add_context(cls, context_type=None, context_identifier=None, target_view=None, parent=None):
|
||||
def run_context_add_context(
|
||||
cls,
|
||||
context_type: Optional[str] = None,
|
||||
context_identifier: Optional[str] = None,
|
||||
target_view: Optional[str] = None,
|
||||
parent: Optional[str] = None,
|
||||
):
|
||||
return bonsai.core.context.add_context(
|
||||
tool.Ifc,
|
||||
context_type=context_type,
|
||||
@@ -100,11 +108,13 @@ class Project(bonsai.core.tool.Project):
|
||||
return bonsai.core.owner.add_person(tool.Ifc)
|
||||
|
||||
@classmethod
|
||||
def run_owner_add_person_and_organisation(cls, person=None, organisation=None):
|
||||
def run_owner_add_person_and_organisation(
|
||||
cls, person: ifcopenshell.entity_instance, organisation: ifcopenshell.entity_instance
|
||||
):
|
||||
return bonsai.core.owner.add_person_and_organisation(tool.Ifc, person=person, organisation=organisation)
|
||||
|
||||
@classmethod
|
||||
def run_owner_set_user(cls, user=None):
|
||||
def run_owner_set_user(cls, user: ifcopenshell.entity_instance):
|
||||
return bonsai.core.owner.set_user(tool.Owner, user=user)
|
||||
|
||||
@classmethod
|
||||
@@ -116,7 +126,7 @@ class Project(bonsai.core.tool.Project):
|
||||
should_add_representation: bool = True,
|
||||
context: Optional[ifcopenshell.entity_instance] = None,
|
||||
ifc_representation_class: Optional[str] = None,
|
||||
) -> ifcopenshell.entity_instance:
|
||||
):
|
||||
return bonsai.core.root.assign_class(
|
||||
tool.Ifc,
|
||||
tool.Collector,
|
||||
@@ -134,20 +144,20 @@ class Project(bonsai.core.tool.Project):
|
||||
return bonsai.core.unit.assign_scene_units(tool.Ifc, tool.Unit)
|
||||
|
||||
@classmethod
|
||||
def set_context(cls, context):
|
||||
def set_context(cls, context: ifcopenshell.entity_instance) -> None:
|
||||
bonsai.bim.handler.refresh_ui_data()
|
||||
rprops = tool.Root.get_root_props()
|
||||
rprops.contexts = str(context.id())
|
||||
|
||||
@classmethod
|
||||
def set_default_context(cls):
|
||||
def set_default_context(cls) -> None:
|
||||
context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
||||
if context:
|
||||
rprops = tool.Root.get_root_props()
|
||||
rprops.contexts = str(context.id())
|
||||
|
||||
@classmethod
|
||||
def set_default_modeling_dimensions(cls):
|
||||
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
|
||||
@@ -323,7 +333,7 @@ class Project(bonsai.core.tool.Project):
|
||||
return any(rel in project_library_rels for rel in has_context)
|
||||
|
||||
@classmethod
|
||||
def update_current_library_page(cls):
|
||||
def update_current_library_page(cls) -> None:
|
||||
props = cls.get_project_props()
|
||||
active_library_breadcrumb = props.get_active_library_breadcrumb()
|
||||
change_back = False
|
||||
|
||||
Reference in New Issue
Block a user