This commit is contained in:
Andrej730
2024-12-23 11:20:47 +05:00
parent f1080a8278
commit 6dfb25862c
6 changed files with 33 additions and 34 deletions
@@ -61,15 +61,15 @@ class SelectByMaterial(bpy.types.Operator):
material: bpy.props.IntProperty() material: bpy.props.IntProperty()
def execute(self, context): def execute(self, context):
material=tool.Ifc.get().by_id(self.material) material = tool.Ifc.get().by_id(self.material)
core.select_by_material(tool.Material, tool.Spatial, material=material) core.select_by_material(tool.Material, tool.Spatial, material=material)
# copy selection query to clipboard # copy selection query to clipboard
material_name = material.Name material_name = material.Name
result = f'material="{material_name}"' result = f'material="{material_name}"'
bpy.context.window_manager.clipboard = result bpy.context.window_manager.clipboard = result
self.report({"INFO"}, f"({result}) was copied to the clipboard.") self.report({"INFO"}, f"({result}) was copied to the clipboard.")
return {"FINISHED"} return {"FINISHED"}
@@ -1157,6 +1157,7 @@ class ProductDecorator:
"TRIS", product_preview_data["verts"], transparent_color(decorator_color), product_preview_data["tris"] "TRIS", product_preview_data["verts"], transparent_color(decorator_color), product_preview_data["tris"]
) )
class WallAxisDecorator: class WallAxisDecorator:
is_installed = False is_installed = False
handlers = [] handlers = []
@@ -1166,9 +1167,7 @@ class WallAxisDecorator:
if cls.is_installed: if cls.is_installed:
cls.uninstall() cls.uninstall()
handler = cls() handler = cls()
cls.handlers.append( cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_wall_axis, (context,), "WINDOW", "POST_VIEW"))
SpaceView3D.draw_handler_add(handler.draw_wall_axis, (context,), "WINDOW", "POST_VIEW")
)
cls.is_installed = True cls.is_installed = True
@classmethod @classmethod
@@ -1206,9 +1205,7 @@ class WallAxisDecorator:
if element.is_a("IfcWall"): if element.is_a("IfcWall"):
layers = tool.Model.get_material_layer_parameters(element) layers = tool.Model.get_material_layer_parameters(element)
axis = tool.Model.get_wall_axis(obj, layers) axis = tool.Model.get_wall_axis(obj, layers)
verts = [tuple(list(v) + [0.0] )for v in axis["reference"]] verts = [tuple(list(v) + [0.0]) for v in axis["reference"]]
self.draw_batch("LINES", verts, selected_elements_color, [(0,1)]) self.draw_batch("LINES", verts, selected_elements_color, [(0, 1)])
verts = [tuple(list(v) + [0.0] )for v in axis["side"]] verts = [tuple(list(v) + [0.0]) for v in axis["side"]]
self.draw_batch("LINES", verts, unselected_elements_color, [(0,1)]) self.draw_batch("LINES", verts, unselected_elements_color, [(0, 1)])
+7 -3
View File
@@ -117,7 +117,7 @@ class DumbSlabGenerator:
# Always assume a closed polyline # Always assume a closed polyline
if self.polyline[0] != self.polyline[-1]: if self.polyline[0] != self.polyline[-1]:
self.polyline.append(self.polyline[0]) self.polyline.append(self.polyline[0])
return self.create_slab() return self.create_slab()
def create_slab(self): def create_slab(self):
@@ -770,12 +770,16 @@ class AddSlabFromWall(bpy.types.Operator, tool.Ifc.Operator):
return {"FINISHED"} return {"FINISHED"}
walls, is_closed_loop = tool.Model.get_connected_walls(bpy.context.selected_objects) walls, is_closed_loop = tool.Model.get_connected_walls(bpy.context.selected_objects)
if not is_closed_loop: if not is_closed_loop:
self.report({"WARNING"}, "Please select a closed loop of walls, or deselect the walls to add a slab using the polyline tool.") self.report(
{"WARNING"},
"Please select a closed loop of walls, or deselect the walls to add a slab using the polyline tool.",
)
return {"FINISHED"} return {"FINISHED"}
DumbSlabGenerator(self.relating_type).generate("WALLS") DumbSlabGenerator(self.relating_type).generate("WALLS")
return {"FINISHED"} return {"FINISHED"}
class DrawPolylineSlab(bpy.types.Operator, PolylineOperator): class DrawPolylineSlab(bpy.types.Operator, PolylineOperator):
bl_idname = "bim.draw_polyline_slab" bl_idname = "bim.draw_polyline_slab"
bl_label = "Draw Polyline Slab" bl_label = "Draw Polyline Slab"
@@ -518,7 +518,7 @@ class SelectIfcClass(Operator):
if element := tool.Ifc.get_entity(obj): if element := tool.Ifc.get_entity(obj):
classes.add(element.is_a()) classes.add(element.is_a())
predefined_types.add(ifcopenshell.util.element.get_predefined_type(element)) predefined_types.add(ifcopenshell.util.element.get_predefined_type(element))
result = '' result = ""
for cls in classes: for cls in classes:
for element in tool.Ifc.get().by_type(cls): for element in tool.Ifc.get().by_type(cls):
if ( if (
@@ -758,18 +758,17 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
) )
else: else:
self.report({"INFO"}, f"Selected all objects that share the same ({key}) value") self.report({"INFO"}, f"Selected all objects that share the same ({key}) value")
# copy selection query to clipboard # copy selection query to clipboard
if not self.calculate_sum: if not self.calculate_sum:
result = '' result = ""
if value == True: if value == True:
value = "TRUE" value = "TRUE"
if value == False: if value == False:
value = "FALSE" value = "FALSE"
if key == "predefined_type": if key == "predefined_type":
key = "PredefinedType" key = "PredefinedType"
if isinstance(value, list) and value: if isinstance(value, list) and value:
for item in value: for item in value:
sub_result = f'{key} = "{item}"' sub_result = f'{key} = "{item}"'
if not result: if not result:
@@ -777,6 +776,6 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
else: else:
result += f", {sub_result}" result += f", {sub_result}"
else: else:
result = f'{key} = "{value}"' result = f'{key} = "{value}"'
bpy.context.window_manager.clipboard = result bpy.context.window_manager.clipboard = result
self.report({"INFO"}, f"({result}) was copied to the clipboard.") self.report({"INFO"}, f"({result}) was copied to the clipboard.")
@@ -198,10 +198,10 @@ class SelectSimilarType(bpy.types.Operator):
continue continue
relating_types.add(relating_type) relating_types.add(relating_type)
result = '' result = ""
for relating_type in relating_types: for relating_type in relating_types:
related_objects = ifcopenshell.util.element.get_types(relating_type) related_objects = ifcopenshell.util.element.get_types(relating_type)
for element in related_objects: for element in related_objects:
obj = tool.Ifc.get_object(element) obj = tool.Ifc.get_object(element)
if obj and obj in context.visible_objects: if obj and obj in context.visible_objects:
@@ -211,13 +211,12 @@ class SelectSimilarType(bpy.types.Operator):
related_objects_class = related_objects[0].is_a() related_objects_class = related_objects[0].is_a()
relating_type_name = relating_type.Name relating_type_name = relating_type.Name
if not result: if not result:
result = f"{related_objects_class}, type=\"{relating_type_name}\"" result = f'{related_objects_class}, type="{relating_type_name}"'
else: else:
result += f" + {related_objects_class}, type=\"{relating_type_name}\"" result += f' + {related_objects_class}, type="{relating_type_name}"'
bpy.context.window_manager.clipboard = result bpy.context.window_manager.clipboard = result
self.report({"INFO"}, f"({result}) was copied to the clipboard.") self.report({"INFO"}, f"({result}) was copied to the clipboard.")
return {"FINISHED"} return {"FINISHED"}
+5 -5
View File
@@ -677,9 +677,9 @@ class Model(bonsai.core.tool.Model):
cls, walls: list[bpy.types.Object], opposite_direction: bool = False cls, walls: list[bpy.types.Object], opposite_direction: bool = False
) -> list[bpy.types.Object]: ) -> list[bpy.types.Object]:
""" """
Loop through walls by retrieving the next connected wall using the ConnectedTo attribute. Loop through walls by retrieving the next connected wall using the ConnectedTo attribute.
If the function encounters the first wall again, it will return the list of connected walls and indicate that a closed loop has been formed. If the function encounters the first wall again, it will return the list of connected walls and indicate that a closed loop has been formed.
If it reaches the end of the connections, the function will call itself in the opposite direction using the ConnectedFrom method If it reaches the end of the connections, the function will call itself in the opposite direction using the ConnectedFrom method
to obtain a list of connected walls in an open loop. to obtain a list of connected walls in an open loop.
""" """
@@ -716,8 +716,8 @@ class Model(bonsai.core.tool.Model):
@classmethod @classmethod
def get_polygons_from_wall_axis(cls, walls: list[bpy.types.Object]) -> list[shapely.Polygon]: def get_polygons_from_wall_axis(cls, walls: list[bpy.types.Object]) -> list[shapely.Polygon]:
""" """
Get the polygons formed by the intersection of the wall axis reference and side. Get the polygons formed by the intersection of the wall axis reference and side.
The polygon with the larger area will be considered the external polygon. The polygon with the larger area will be considered the external polygon.
This function only works with closed loops. This function only works with closed loops.
""" """
points1 = [] points1 = []