QuickPipe

I added a button in Context, Edges, Vertices menu

import bpy
import bmesh
import math
import mathutils as mathu

from bpy.props import (
    IntProperty,
    FloatProperty
)

bl_info = {
    "name": "Quick Pipe",
    "author": "floatvoid (Jeremy Mitchell), Pavel Geraskin",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "View3D > Edit Mode",
    "description": "Quickly converts an edge selection to an extruded curve.",
    "warning": "",
    "wiki_url": "",
    "category": "View3D"}


class jmPipeTool(bpy.types.Operator):
    bl_idname = "object.quickpipe"
    bl_label = "Quick Pipe"
    bl_options = {'REGISTER', 'UNDO'}

    first_mouse_x: IntProperty()
    first_value: FloatProperty()

    def modal(self, context, event):
        if event.type in {'RIGHTMOUSE', 'ESC', 'LEFTMOUSE'}:
            return {'FINISHED'}

        if event.type == 'MOUSEMOVE':
            delta = (self.first_mouse_x - event.mouse_x)

            if event.ctrl:
                delta *= 0.1

                if event.shift:
                    delta *= 0.1

            context.object.data.bevel_depth = abs((self.first_value + delta) * 0.01)
        elif event.type == 'WHEELUPMOUSE':
            bpy.context.object.data.bevel_resolution += 1
        elif event.type == 'WHEELDOWNMOUSE':
            if bpy.context.object.data.bevel_resolution > 0:
                bpy.context.object.data.bevel_resolution -= 1

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.object:

            if (context.object.type == 'MESH'):
                self.first_mouse_x = event.mouse_x

                bpy.ops.mesh.duplicate_move()
                bpy.ops.mesh.separate(type='SELECTED')
                bpy.ops.object.editmode_toggle()

                #  pipe = context.view_layer.objects[-1]
                pipe = context.selected_objects[-1]
                bpy.ops.object.select_all(action='DESELECT')
                pipe.select_set(state=True)
                context.view_layer.objects.active = pipe
                bpy.ops.object.convert(target='CURVE')

                pipe.data.fill_mode = 'FULL'
                pipe.data.splines[0].use_smooth = True
                pipe.data.bevel_resolution = 1
                pipe.data.bevel_depth = 0.1

            elif (context.object.type == 'CURVE'):
                self.report({'WARNING'}, "Need Edit Mode!")
                return {'CANCELLED'}

            self.first_value = pipe.data.bevel_depth

            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "No active object, could not finish")
            return {'CANCELLED'}


# class VIEW3D_PT_tools_jmPipeTool(bpy.types.Panel):

#     bl_label = "Quick Pipe"
#     bl_space_type = 'VIEW_3D'
#     bl_region_type = 'TOOLS'
#     bl_category = 'Tools'
#     bl_context = "mesh_edit"
#     bl_options = {'DEFAULT_CLOSED'}

#     def draw(self, context):
#         layout = self.layout

#         row = layout.row()
#         row.operator("object.quickpipe")

def menu_func(self, context):
    layout = self.layout
    layout.operator_context = "INVOKE_DEFAULT"
    self.layout.operator(jmPipeTool.bl_idname, text="Quick Pipe")

classes = (
    jmPipeTool,
)


# Register
def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    #  update_panel(None, bpy.context)
    bpy.types.VIEW3D_MT_edit_mesh_context_menu.append(menu_func)  # Mesh Context Menu
    bpy.types.VIEW3D_MT_edit_mesh_vertices.append(menu_func)  # Vertices Menu(CTRL+V)
    bpy.types.VIEW3D_MT_edit_mesh_edges.append(menu_func)  # Edge Menu(CTRL+E)


def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

    bpy.types.VIEW3D_MT_edit_mesh_context_menu.remove(menu_func)
    bpy.types.VIEW3D_MT_edit_mesh_vertices.remove(menu_func)
    bpy.types.VIEW3D_MT_edit_mesh_edges.remove(menu_func)

if __name__ == "__main__":
    register()

4 Likes

I love this community so much. Thank you guys for all of your hard work on this, and for adding this to the menus!!

2 Likes

Wow! Thanks a lot. I updated my repo with your things.

But I commented vertices for my version. I hope you don’t mind.

2 Likes

No problem at all.

1 Like

Thanks for the new update and add it to the menu :smiley:

I updated the addon created by Cebbi. Now we can create beautiful pipes in blender 2.8 :grinning:

1 Like

Is there any way these two scripts could be combined? It feels like there’s no reason why the Match Pipe Width shouldn’t just automatically happen in Quick Pipe.

2 Likes

I think the same.

I combined two add-ons together “Quick Pipe” and “Match Pipe Width”. I hope the authors do not mind.

Regular Quick Pipe

Press ALT

Download:

6 Likes

If you use a bevel cube ( round edges ) then you don’t have this problem and everything stays procedural , maybe not everyone need the extra option

Just use the one that works best for your workflow :smiley:

If not need extra option, don’t press alt button :slightly_smiling_face:

Excellent , thanks for the extra option

Little improvements

Version 2.1

3 Likes

Works Fine , thanks again :grinning:

1 Like

When i use the script i have wierd shading results on pipe.

Video in the link below:

You can use autosmooth or add bevel

1 Like

Autosmooth dont work shading is still broken… And what You mean by add bevel?

or you can mark sharp corners to sharp

Share blend file please.

one issue to address, while creating pipes (with Alt) alone 3 edges of a cube, 2nd & 3rd pipes started twisting.twisted%20pipe