InvertPaths 0.51

This script inverts selected paths. It doesn’t work with normal curves nor NURBS yet.


#!BPY

"""
Name: 'InvertPaths 0.51'
Blender: 241
Group: 'Object'
Tooltip: 'Inverts the selected paths.'
"""

__author__ = "BeBraw"
__url__ = ("")
__version__ = "0.51 13.07.06"

__bpydoc__ = """\

Inverts the selected paths.

Usage:
Select paths and execute the script.

Tips:

"""
#############################################################
# Code history                                              #
#############################################################
#	version 0.51 released 13.07.06

# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2006: BeBraw
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------

'''
Version history:
0.50 - initial release

0.51 - removed NMesh from import

Current issues:
-doesn't work properly with normal curves. Disable this?

TODO:
'''

import Blender
from Blender import Window

inEmode = Window.EditMode()
if inEmode:	Window.EditMode(0)

selectedObjects = Blender.Object.GetSelected()
curves = []

for s in selectedObjects:
    curves.append(s.getData())
    
for c in curves:
    try:
        for cur in c:
            print type( cur ), cur
            for i in range(0, len(cur)/2):
                swap1 = cur[i]
                swap2 = cur[len(cur)-i-1]
                cur[i] = swap2
                cur[len(cur)-i-1] = swap1
    except:
        print 'Not a curve!'   
    
for c in curves:
    c.update()
    
Window.EditMode(0)
Window.EditMode(1)    
if not inEmode:	
    Window.EditMode(0)    

Blender.Redraw()

BeBraw: there is such a function in blender. W-key -> switch direction

Aligorith

Heh.

Anyway it was a good practice and it works on multiple paths at once unlike W. :slight_smile:

True… I’m think of adding a patch that adds selecting of the first/last vertex of a curve. You need to know this before you decide whether or not you want to reverse a curve :wink:

Aligorith

You should replace :

 Group : 'Mesh' 

by :

 Group : 'Object' 

Why do you import the NMesh module ?

Whoops. I forgot that NMesh there in my coding frenzy. :slight_smile:

jms: What do you mean by that Group : ‘Mesh’ to Group : ‘Object’? Could you point the exact line that has the problem?

Thanks for feedback!

I mean at the beginning of your script, line 6

Whoops. Thanks. Got it. :slight_smile: