mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 02:49:12 +00:00
You can now change the radius of existing arcs. Minor interface cleanup.
This commit is contained in:
@@ -622,6 +622,69 @@ class AddIfcArcIndexFillet(bpy.types.Operator):
|
||||
layout.prop(self, prop)
|
||||
|
||||
def execute(self, context):
|
||||
if self.has_selected_existing_arc(context):
|
||||
self.change_radius(context)
|
||||
else:
|
||||
self.create_arc(context)
|
||||
return {"FINISHED"}
|
||||
|
||||
def has_selected_existing_arc(self, context):
|
||||
obj = context.active_object
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
verts = [v for v in bm.verts if v.select and not v.hide]
|
||||
if len(verts) != 3:
|
||||
return False
|
||||
groups = []
|
||||
for i, group in enumerate(obj.vertex_groups):
|
||||
if "IFCARCINDEX" in group.name:
|
||||
groups.append(i)
|
||||
bm.verts.layers.deform.verify()
|
||||
deform_layer = bm.verts.layers.deform.active
|
||||
for group in groups:
|
||||
try:
|
||||
if group in verts[0][deform_layer] and group in verts[1][deform_layer]:
|
||||
return True
|
||||
except:
|
||||
pass # Potentially fail if the vert has been removed in the previous operation
|
||||
|
||||
def change_radius(self, context):
|
||||
obj = context.active_object
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
edges = [e for e in bm.edges if e.select and not e.hide]
|
||||
|
||||
mid = list(set(edges[0].verts) & set(edges[1].verts))[0]
|
||||
v1 = edges[0].other_vert(mid)
|
||||
v2 = edges[1].other_vert(mid)
|
||||
center = tool.Cad.get_center_of_arc([v1.co, mid.co, v2.co])
|
||||
|
||||
if len(v1.link_edges) != 2 or len(v2.link_edges) != 2:
|
||||
return
|
||||
|
||||
v3 = v1.link_edges[1].other_vert(v1) if mid in v1.link_edges[0].verts else v1.link_edges[0].other_vert(v1)
|
||||
v4 = v2.link_edges[1].other_vert(v2) if mid in v2.link_edges[0].verts else v2.link_edges[0].other_vert(v2)
|
||||
dir1 = (v3.co - v1.co).normalized()
|
||||
dir2 = (v4.co - v2.co).normalized()
|
||||
|
||||
intersect = mathutils.geometry.intersect_line_line(v3.co, v1.co, v4.co, v2.co)[0]
|
||||
|
||||
edge_angle = dir1.angle(dir2)
|
||||
slide_distance = self.radius / math.tan(edge_angle / 2)
|
||||
|
||||
v1.co = intersect + (dir1 * slide_distance)
|
||||
v2.co = intersect + (dir2 * slide_distance)
|
||||
|
||||
normal = mathutils.geometry.normal([v1.co, intersect, v2.co])
|
||||
center = mathutils.geometry.intersect_line_line(
|
||||
v1.co, v1.co + normal.cross(dir1), v2.co, v2.co + normal.cross(dir2)
|
||||
)[0]
|
||||
|
||||
mid.co = center + ((v1.co.lerp(v2.co, 0.5) - center).normalized() * self.radius)
|
||||
|
||||
bm.verts.index_update()
|
||||
bm.edges.index_update()
|
||||
bmesh.update_edit_mesh(obj.data)
|
||||
|
||||
def create_arc(self, context):
|
||||
obj = bpy.context.active_object
|
||||
|
||||
bpy.ops.object.mode_set(mode="OBJECT")
|
||||
@@ -688,4 +751,3 @@ class AddIfcArcIndexFillet(bpy.types.Operator):
|
||||
bm.verts.index_update()
|
||||
bm.edges.index_update()
|
||||
bmesh.update_edit_mesh(obj.data)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -712,7 +712,7 @@ class DumbWallPlaner:
|
||||
class DumbWallJoiner:
|
||||
def __init__(self):
|
||||
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "AXIS", "GRAPH_VIEW")
|
||||
self.axis_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Axis", "GRAPH_VIEW")
|
||||
self.body_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
||||
|
||||
def unjoin(self, wall1):
|
||||
|
||||
@@ -98,10 +98,15 @@ class BimTool(WorkSpaceTool):
|
||||
if ifc_classes:
|
||||
row = layout.row()
|
||||
row.operator("bim.display_constr_types", icon="TRIA_DOWN", text="")
|
||||
row = layout.row(align=True)
|
||||
row.label(text="", icon="EVENT_SHIFT")
|
||||
row.label(text="", icon="EVENT_A")
|
||||
row.label(text=f" Add")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label(text="", icon="EVENT_SHIFT")
|
||||
row.label(text="", icon="EVENT_A")
|
||||
op = row.operator("bim.add_constr_type_instance", text="Add")
|
||||
op.from_invoke = True
|
||||
op.ifc_class = ifc_class
|
||||
if relating_type_id.isnumeric():
|
||||
op.relating_type_id = int(relating_type_id)
|
||||
else:
|
||||
row = layout.row(align=True)
|
||||
if ifc_classes:
|
||||
@@ -118,18 +123,16 @@ class BimTool(WorkSpaceTool):
|
||||
if is_sidebar and ifc_classes and relating_types_ids:
|
||||
box = layout.box()
|
||||
box.template_icon(icon_value=props.icon_id, scale=8)
|
||||
row = layout.row()
|
||||
op = row.operator("bim.add_constr_type_instance", icon="ADD")
|
||||
op.from_invoke = True
|
||||
op.ifc_class = ifc_class
|
||||
if relating_type_id.isnumeric():
|
||||
op.relating_type_id = int(relating_type_id)
|
||||
|
||||
if ifc_classes:
|
||||
row = layout.row(align=True)
|
||||
row.label(text="", icon="EVENT_SHIFT")
|
||||
row.label(text="", icon="EVENT_A")
|
||||
row.label(text=f" Add Type Instance")
|
||||
op = row.operator("bim.add_constr_type_instance", text="Add")
|
||||
op.from_invoke = True
|
||||
op.ifc_class = ifc_class
|
||||
if relating_type_id.isnumeric():
|
||||
op.relating_type_id = int(relating_type_id)
|
||||
|
||||
if ifc_classes:
|
||||
if ifc_class == "IfcWallType":
|
||||
|
||||
Reference in New Issue
Block a user