mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 02:24:30 +00:00
typing
This commit is contained in:
@@ -32,7 +32,12 @@ from bonsai.bim.ifc import IfcStore
|
||||
from typing import Optional, Callable, Any, Union
|
||||
|
||||
|
||||
def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=None):
|
||||
def draw_attributes(
|
||||
props: list[bpy.types.PropertyGroup],
|
||||
layout: bpy.types.UILayout,
|
||||
copy_operator: Optional[str] = None,
|
||||
popup_active_attribute: Optional[bpy.types.PropertyGroup] = None,
|
||||
) -> None:
|
||||
"""you can set attribute active in popup with `active_attribute`
|
||||
meaning you will be able to type into attribute's field without having to click
|
||||
on it first
|
||||
@@ -44,7 +49,9 @@ def draw_attributes(props, layout, copy_operator=None, popup_active_attribute=No
|
||||
draw_attribute(attribute, row, copy_operator)
|
||||
|
||||
|
||||
def draw_attribute(attribute, layout, copy_operator=None):
|
||||
def draw_attribute(
|
||||
attribute: bpy.types.PropertyGroup, layout: bpy.types.UILayout, copy_operator: Optional[str] = None
|
||||
) -> None:
|
||||
value_name = attribute.get_value_name()
|
||||
if not value_name:
|
||||
layout.label(text=attribute.name)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import bonsai.bim.helper
|
||||
import bonsai.tool as tool
|
||||
import bonsai.bim.module.classification.prop as classification_prop
|
||||
@@ -116,6 +117,8 @@ class BIM_PT_classifications(Panel):
|
||||
|
||||
|
||||
class ReferenceUI:
|
||||
layout: bpy.types.UILayout
|
||||
|
||||
def draw_ui(self, context):
|
||||
obj = context.active_object
|
||||
self.sprops = context.scene.BIMClassificationProperties
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
def find_whl_files(directory):
|
||||
def find_whl_files(directory: str) -> list[str]:
|
||||
whl_files = []
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
@@ -12,7 +12,7 @@ def find_whl_files(directory):
|
||||
return whl_files
|
||||
|
||||
|
||||
def update_pyproject_toml(pyproject_path, whl_files):
|
||||
def update_pyproject_toml(pyproject_path: str, whl_files: list[str]) -> None:
|
||||
with open(pyproject_path, "a") as f:
|
||||
f.write("\nwheels = [\n")
|
||||
for whl in whl_files:
|
||||
|
||||
@@ -27,9 +27,7 @@ def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -
|
||||
All of the presentation items of the style will also be removed.
|
||||
|
||||
:param style: The IfcPresentationStyle to remove.
|
||||
:type style: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -51,25 +49,25 @@ class Usecase:
|
||||
file: ifcopenshell.file
|
||||
settings: dict[str, Any]
|
||||
|
||||
def execute(self):
|
||||
def execute(self) -> None:
|
||||
self.purge_styled_items(self.settings["style"])
|
||||
for style in self.settings["style"].Styles or []:
|
||||
ifcopenshell.api.style.remove_surface_style(self.file, style=style)
|
||||
self.file.remove(self.settings["style"])
|
||||
|
||||
def purge_styled_items(self, style):
|
||||
def purge_styled_items(self, style: ifcopenshell.entity_instance) -> None:
|
||||
for inverse in self.file.get_inverse(style):
|
||||
if inverse.is_a("IfcStyledItem") and len(inverse.Styles) == 1:
|
||||
self.purge_styled_representations(inverse)
|
||||
self.file.remove(inverse)
|
||||
|
||||
def purge_styled_representations(self, styled_item):
|
||||
def purge_styled_representations(self, styled_item: ifcopenshell.entity_instance) -> None:
|
||||
for inverse in self.file.get_inverse(styled_item):
|
||||
if inverse.is_a("IfcStyledRepresentation") and len(inverse.Items) == 1:
|
||||
self.purge_material_definition_representations(inverse)
|
||||
self.file.remove(inverse)
|
||||
|
||||
def purge_material_definition_representations(self, styled_representation):
|
||||
def purge_material_definition_representations(self, styled_representation: ifcopenshell.entity_instance) -> None:
|
||||
for inverse in self.file.get_inverse(styled_representation):
|
||||
if inverse.is_a("IfcMaterialDefinitionRepresentation") and len(inverse.Representations) == 1:
|
||||
self.file.remove(inverse)
|
||||
|
||||
Reference in New Issue
Block a user