This commit is contained in:
Andrej730
2024-09-20 11:34:05 +05:00
parent d7adec3d54
commit 9953ce1b39
4 changed files with 18 additions and 10 deletions
+9 -2
View File
@@ -32,7 +32,12 @@ from bonsai.bim.ifc import IfcStore
from typing import Optional, Callable, Any, Union 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` """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 meaning you will be able to type into attribute's field without having to click
on it first 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) 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() value_name = attribute.get_value_name()
if not value_name: if not value_name:
layout.label(text=attribute.name) layout.label(text=attribute.name)
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>. # along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import bpy
import bonsai.bim.helper import bonsai.bim.helper
import bonsai.tool as tool import bonsai.tool as tool
import bonsai.bim.module.classification.prop as classification_prop import bonsai.bim.module.classification.prop as classification_prop
@@ -116,6 +117,8 @@ class BIM_PT_classifications(Panel):
class ReferenceUI: class ReferenceUI:
layout: bpy.types.UILayout
def draw_ui(self, context): def draw_ui(self, context):
obj = context.active_object obj = context.active_object
self.sprops = context.scene.BIMClassificationProperties self.sprops = context.scene.BIMClassificationProperties
+2 -2
View File
@@ -2,7 +2,7 @@ import os
import sys import sys
def find_whl_files(directory): def find_whl_files(directory: str) -> list[str]:
whl_files = [] whl_files = []
for root, dirs, files in os.walk(directory): for root, dirs, files in os.walk(directory):
for file in files: for file in files:
@@ -12,7 +12,7 @@ def find_whl_files(directory):
return whl_files 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: with open(pyproject_path, "a") as f:
f.write("\nwheels = [\n") f.write("\nwheels = [\n")
for whl in whl_files: 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. All of the presentation items of the style will also be removed.
:param style: The IfcPresentationStyle to remove. :param style: The IfcPresentationStyle to remove.
:type style: ifcopenshell.entity_instance
:return: None :return: None
:rtype: None
Example: Example:
@@ -51,25 +49,25 @@ class Usecase:
file: ifcopenshell.file file: ifcopenshell.file
settings: dict[str, Any] settings: dict[str, Any]
def execute(self): def execute(self) -> None:
self.purge_styled_items(self.settings["style"]) self.purge_styled_items(self.settings["style"])
for style in self.settings["style"].Styles or []: for style in self.settings["style"].Styles or []:
ifcopenshell.api.style.remove_surface_style(self.file, style=style) ifcopenshell.api.style.remove_surface_style(self.file, style=style)
self.file.remove(self.settings["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): for inverse in self.file.get_inverse(style):
if inverse.is_a("IfcStyledItem") and len(inverse.Styles) == 1: if inverse.is_a("IfcStyledItem") and len(inverse.Styles) == 1:
self.purge_styled_representations(inverse) self.purge_styled_representations(inverse)
self.file.remove(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): for inverse in self.file.get_inverse(styled_item):
if inverse.is_a("IfcStyledRepresentation") and len(inverse.Items) == 1: if inverse.is_a("IfcStyledRepresentation") and len(inverse.Items) == 1:
self.purge_material_definition_representations(inverse) self.purge_material_definition_representations(inverse)
self.file.remove(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): for inverse in self.file.get_inverse(styled_representation):
if inverse.is_a("IfcMaterialDefinitionRepresentation") and len(inverse.Representations) == 1: if inverse.is_a("IfcMaterialDefinitionRepresentation") and len(inverse.Representations) == 1:
self.file.remove(inverse) self.file.remove(inverse)