Finally decided to break my brain and try making
a script for something I really need. Just a rough
draft since I don’t know what i’m doing…
Today - Flatten selected vertices to a plane (Z-Axis only).
Tomorrow - GUI and multi-Axis
#!BPY
“”"
Name: ‘Flatten Mesh v0.1 (Z-Axis)’
Blender: 249b
Group: ‘Mesh’
Tooltip: ‘Flatten selected vertices to a plane.’
“”"
author = “Christopher P. Waguespack (Daellus)”
version = “0.1 09/14/2010 02:45 CST”
email = [‘scripts’, ‘Author, [email protected]’]
url = [‘blender’, ‘blenderartists.org’]
bpydoc = “”"
Find an interesting vertex array? Flatten it!
Tuesday 2:45 AM CST
September 14, 2010
I’ve often noticed that various modifications and whatnot
in the process of modeling objects produce interesting vertex
and face patterns that I would like to use as planar surfaces
for textures (i.e. stained-glass windows, etc.).
Well, flatten them and go forth! Currently only works with
setting the Z-coordinates of selected vertices to 0. Once I
learn how to script a panel, there’ll be numerous options.
Help would be appreciated, but not compensated.
IMPORTANT: This uses the mesh’s LOCAL coordinates, so make
sure you have it pointing the right way!
“”"
--------------------------------------------------------------------------
mesh_flatten.py v0.1 09/14/2010 02:45 CST
--------------------------------------------------------------------------
***** BEGIN GPL LICENSE BLOCK *****
Copyright © 2010: Christopher P. Waguespack (Daellus), [email protected]
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 *****
--------------------------------------------------------------------------
from Blender import Scene, Mesh, Window, sys
import BPyMessages
import bpy
def flatten(me):
vcount = 0
for v in me.verts:
if v.sel:
v.co.z = 0.0
vcount += 1
print me.name + ’ modified.’
print str(vcount) + ’ vertices moved to Z-Axiz’
def main():
sce = bpy.data.scenes.active
ob_act = sce.objects.active
if not ob_act or ob_act.type != ‘Mesh’:
BPyMessages.Error_NoMeshActive()
return
is_editmode = Window.EditMode()
if is_editmode: Window.EditMode(0)
Window.WaitCursor(1)
me = ob_act.getData(mesh=1)
t = sys.time()
flatten(me)
if is_editmode: Window.EditMode(1)
print ‘Completion time: %.2f seconds’ % (sys.time()-t)
Window.WaitCursor(0)
if name == ‘main’:
main()