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()
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)
# copy selection query to clipboard
material_name = material.Name
result = f'material="{material_name}"'
result = f'material="{material_name}"'
bpy.context.window_manager.clipboard = result
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
return {"FINISHED"}
@@ -1157,6 +1157,7 @@ class ProductDecorator:
"TRIS", product_preview_data["verts"], transparent_color(decorator_color), product_preview_data["tris"]
)
class WallAxisDecorator:
is_installed = False
handlers = []
@@ -1166,9 +1167,7 @@ class WallAxisDecorator:
if cls.is_installed:
cls.uninstall()
handler = cls()
cls.handlers.append(
SpaceView3D.draw_handler_add(handler.draw_wall_axis, (context,), "WINDOW", "POST_VIEW")
)
cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_wall_axis, (context,), "WINDOW", "POST_VIEW"))
cls.is_installed = True
@classmethod
@@ -1206,9 +1205,7 @@ class WallAxisDecorator:
if element.is_a("IfcWall"):
layers = tool.Model.get_material_layer_parameters(element)
axis = tool.Model.get_wall_axis(obj, layers)
verts = [tuple(list(v) + [0.0] )for v in axis["reference"]]
self.draw_batch("LINES", verts, selected_elements_color, [(0,1)])
verts = [tuple(list(v) + [0.0] )for v in axis["side"]]
self.draw_batch("LINES", verts, unselected_elements_color, [(0,1)])
verts = [tuple(list(v) + [0.0]) for v in axis["reference"]]
self.draw_batch("LINES", verts, selected_elements_color, [(0, 1)])
verts = [tuple(list(v) + [0.0]) for v in axis["side"]]
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
if self.polyline[0] != self.polyline[-1]:
self.polyline.append(self.polyline[0])
return self.create_slab()
def create_slab(self):
@@ -770,12 +770,16 @@ class AddSlabFromWall(bpy.types.Operator, tool.Ifc.Operator):
return {"FINISHED"}
walls, is_closed_loop = tool.Model.get_connected_walls(bpy.context.selected_objects)
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"}
DumbSlabGenerator(self.relating_type).generate("WALLS")
return {"FINISHED"}
class DrawPolylineSlab(bpy.types.Operator, PolylineOperator):
bl_idname = "bim.draw_polyline_slab"
bl_label = "Draw Polyline Slab"
@@ -518,7 +518,7 @@ class SelectIfcClass(Operator):
if element := tool.Ifc.get_entity(obj):
classes.add(element.is_a())
predefined_types.add(ifcopenshell.util.element.get_predefined_type(element))
result = ''
result = ""
for cls in classes:
for element in tool.Ifc.get().by_type(cls):
if (
@@ -758,18 +758,17 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
)
else:
self.report({"INFO"}, f"Selected all objects that share the same ({key}) value")
# copy selection query to clipboard
if not self.calculate_sum:
result = ''
result = ""
if value == True:
value = "TRUE"
if value == False:
value = "FALSE"
value = "FALSE"
if key == "predefined_type":
key = "PredefinedType"
if isinstance(value, list) and value:
key = "PredefinedType"
if isinstance(value, list) and value:
for item in value:
sub_result = f'{key} = "{item}"'
if not result:
@@ -777,6 +776,6 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
else:
result += f", {sub_result}"
else:
result = f'{key} = "{value}"'
result = f'{key} = "{value}"'
bpy.context.window_manager.clipboard = result
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
@@ -198,10 +198,10 @@ class SelectSimilarType(bpy.types.Operator):
continue
relating_types.add(relating_type)
result = ''
result = ""
for relating_type in relating_types:
related_objects = ifcopenshell.util.element.get_types(relating_type)
for element in related_objects:
obj = tool.Ifc.get_object(element)
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()
relating_type_name = relating_type.Name
if not result:
result = f"{related_objects_class}, type=\"{relating_type_name}\""
result = f'{related_objects_class}, type="{relating_type_name}"'
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
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
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
) -> list[bpy.types.Object]:
"""
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 it reaches the end of the connections, the function will call itself in the opposite direction using the ConnectedFrom method
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 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.
"""
@@ -716,8 +716,8 @@ class Model(bonsai.core.tool.Model):
@classmethod
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.
The polygon with the larger area will be considered the external polygon.
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.
This function only works with closed loops.
"""
points1 = []