From 923a9a0b03ee499edf3b050cab9b3ad3b4172117 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 14 Feb 2005 01:26:07 +0000 Subject: Vertex group support in Apply_Def. If subsurf is off on the original mesh, copies groups AND weight. If not, only copies weight. --- release/scripts/Apply_def.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'release') diff --git a/release/scripts/Apply_def.py b/release/scripts/Apply_def.py index 5456d40f20b..bdcae3744ec 100644 --- a/release/scripts/Apply_def.py +++ b/release/scripts/Apply_def.py @@ -36,6 +36,8 @@ directly manipulate or export its data. # # Copyright (C) 2003: Martin Poirier, theeth@yahoo.com # +# Thanks to Jonathan Hudson for help with the vertex groups part +# # 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 @@ -80,4 +82,21 @@ for ob in ob_list: pass new_ob.setName(new_name) + ob_mesh = ob.getData() + new_ob_mesh = new_ob.getData() + + # If SubSurf is off on the original, copy the vertex weight + if not ob_mesh.getMode() & Blender.NMesh.Modes['SUBSURF']: + for vgroupname in ob_mesh.getVertGroupNames(): + vlist = ob_mesh.getVertsFromGroup(vgroupname, True) + new_ob_mesh.addVertGroup(vgroupname) + for vpair in vlist: + new_ob_mesh.assignVertsToGroup(vgroupname, [vpair[0]], vpair[1], 'add') + # If it's on, just add the vertex groups + else: + for vgroupname in ob_mesh.getVertGroupNames(): + new_ob_mesh.addVertGroup(vgroupname) + + new_ob_mesh.update() + Blender.Window.EditMode(1) -- cgit v1.2.3