Skip to content
Snippets Groups Projects
mesh_looptools.py 150 KiB
Newer Older
  • Learn to ignore specific revisions
  • Bart Crouch's avatar
    Bart Crouch committed
        gstretch_method = bpy.props.EnumProperty(name = "Method",
            items = (("project", "Project", "Project vertices onto the stroke, "\
                "using vertex normals and connected edges"),
                ("irregular", "Spread", "Distribute vertices along the full "\
                "stroke, retaining relative distances between the vertices"),
                ("regular", "Spread evenly", "Distribute vertices at regular "\
                "distances along the full stroke")),
            description = "Method of distributing the vertices over the Grease "\
                "Pencil stroke",
            default = 'regular')
        
    
        # relax properties
        relax_input = bpy.props.EnumProperty(name = "Input",
            items = (("all", "Parallel (all)", "Also use non-selected "\
                    "parallel loops as input"),
                ("selected", "Selection","Only use selected vertices as input")),
            description = "Loops that are relaxed",
            default = 'selected')
        relax_interpolation = bpy.props.EnumProperty(name = "Interpolation",
            items = (("cubic", "Cubic", "Natural cubic spline, smooth results"),
                ("linear", "Linear", "Simple and fast linear algorithm")),
            description = "Algorithm used for interpolation",
            default = 'cubic')
        relax_iterations = bpy.props.EnumProperty(name = "Iterations",
            items = (("1", "1", "One"),
                ("3", "3", "Three"),
                ("5", "5", "Five"),
                ("10", "10", "Ten"),
                ("25", "25", "Twenty-five")),
            description = "Number of times the loop is relaxed",
            default = "1")
        relax_regular = bpy.props.BoolProperty(name = "Regular",
            description = "Distribute vertices at constant distances along the" \
                "loop",
            default = True)
        
        # space properties
        space_influence = bpy.props.FloatProperty(name = "Influence",
            description = "Force of the tool",
            default = 100.0,
            min = 0.0,
            max = 100.0,
            precision = 1,
            subtype = 'PERCENTAGE')
        space_input = bpy.props.EnumProperty(name = "Input",
            items = (("all", "Parallel (all)", "Also use non-selected "\
                    "parallel loops as input"),
                ("selected", "Selection","Only use selected vertices as input")),
            description = "Loops that are spaced",
            default = 'selected')
        space_interpolation = bpy.props.EnumProperty(name = "Interpolation",
            items = (("cubic", "Cubic", "Natural cubic spline, smooth results"),
                ("linear", "Linear", "Vertices are projected on existing edges")),
            description = "Algorithm used for interpolation",
            default = 'cubic')
    
    
    # draw function for integration in menus
    def menu_func(self, context):
        self.layout.menu("VIEW3D_MT_edit_mesh_looptools")
        self.layout.separator()
    
    
    # define classes for registration
    classes = [VIEW3D_MT_edit_mesh_looptools,
        VIEW3D_PT_tools_looptools,
        LoopToolsProps,
        Bridge,
        Circle,
        Curve,
        Flatten,
    
    Bart Crouch's avatar
    Bart Crouch committed
        GStretch,
    
        Relax,
        Space]
    
    
    # registering and menu integration
    def register():
        for c in classes:
            bpy.utils.register_class(c)
        bpy.types.VIEW3D_MT_edit_mesh_specials.prepend(menu_func)
        bpy.types.WindowManager.looptools = bpy.props.PointerProperty(\
            type = LoopToolsProps)
    
    
    # unregistering and removing menus
    def unregister():
        for c in classes:
            bpy.utils.unregister_class(c)
        bpy.types.VIEW3D_MT_edit_mesh_specials.remove(menu_func)
        try:
            del bpy.types.WindowManager.looptools
        except:
            pass
    
    
    if __name__ == "__main__":
        register()