Skip to content
Snippets Groups Projects
pdt_command.py 35.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • Alan Odom's avatar
    Alan Odom committed
        # _offset <= 0 is ignored since a bevel/fillet radius must be > 0 to make sense
        _offset = float(values[0])
    
    Alan Odom's avatar
    Alan Odom committed
        _segments = float(values[1])
    
    Alan Odom's avatar
    Alan Odom committed
        if _segments < 1:
            _segments = 1   # This is a single, flat segment (ignores profile)
        _profile = float(values[2])
        if _profile < 0.0 or _profile > 1.0:
            _profile = 0.5  # This is a circular profile
        if mode == "i":
            # Fillet & Intersect Two Edges
            # Always use Current Selection
            verts = [v for v in bm.verts if v.select]
            edges = [e for e in bm.edges if e.select]
            if len(edges) == 2 and len(verts) == 4:
                plane = pg.plane
                v_active = edges[0].verts[0]
                v_other = edges[0].verts[1]
                v_last = edges[1].verts[0]
                v_first = edges[1].verts[1]
                vector_delta, done = intersection(v_active.co,
    
                                                  v_other.co,
                                                  v_last.co,
                                                  v_first.co,
                                                  plane
                                                  )
    
    Alan Odom's avatar
    Alan Odom committed
                if not done:
    
                    pg.error = f"{PDT_ERR_INT_LINES} {plane}  {PDT_LAB_PLANE}"
                    context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
    
    Alan Odom's avatar
    Alan Odom committed
                    raise PDT_IntersectionError
                if (v_active.co - vector_delta).length < (v_other.co - vector_delta).length:
                    v_active.co = vector_delta
                    v_other.select_set(False)
                else:
                    v_other.co = vector_delta
                    v_active.select_set(False)
                if (v_last.co - vector_delta).length < (v_first.co - vector_delta).length:
                    v_last.co = vector_delta
                    v_first.select_set(False)
                else:
                    v_first.co = vector_delta
                    v_last.select_set(False)
                bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
            else:
                pg.error = f"{PDT_ERR_SEL_4_VERTS} {len(verts)} Vert(s), {len(edges)} Edge(s))"
                context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
                raise PDT_SelectionError
    
        bpy.ops.mesh.bevel(
            offset_type="OFFSET",
            offset=_offset,
            segments=_segments,
            profile=_profile,
            vertex_only=vert_bool
        )