~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to release/scripts/fixfromarmature.py

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!BPY
 
2
 
 
3
""" Registration info for Blender menus: <- these words are ignored
 
4
Name: 'Fix From Everything'
 
5
Blender: 236
 
6
Group: 'Mesh'
 
7
Tip: 'Fix armature/lattice/RVK/curve deform and taper/soft body deformation (without bake)'
 
8
"""
 
9
 
 
10
__author__ = "Jean-Michel Soler (jms)"
 
11
__url__ = ("blender", "elysiun",
 
12
"Script's homepage, http://jmsoler.free.fr/util/blenderfile/py/fixfromarmature.py",
 
13
"Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
 
14
__version__ = "06/2005"
 
15
 
 
16
__bpydoc__ = """\
 
17
This script creates a copy of the active mesh with deformations fixed.
 
18
 
 
19
Usage:
 
20
 
 
21
Select the deformed mesh and run this script.  A fixed copy of it will be created.
 
22
"""
 
23
 
 
24
# $Id: fixfromarmature.py,v 1.8 2005/06/11 05:30:13 ianwill Exp $
 
25
#
 
26
#----------------------------------------------
 
27
# jm soler  05/2004-->04/2005 :   'FixfromArmature'
 
28
#----------------------------------------------
 
29
# Official Page :
 
30
#   http://jmsoler.free.fr/util/blenderfile/py/fixfromarmature.py
 
31
# Communicate problems and errors on:
 
32
#   http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
 
33
#---------------------------------------------
 
34
# Page officielle :
 
35
#   http://jmsoler.free.fr/util/blenderfile/py/fixfromarmature.py
 
36
# Communiquer les problemes et erreurs sur:
 
37
#   http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
 
38
#---------------------------------------------
 
39
# ce script est propos� sous licence GPL pour etre associe
 
40
# a la distribution de Blender 2.33 et suivant
 
41
# --------------------------------------------------------------------------
 
42
# this script is released under GPL licence
 
43
# for the Blender 2.33 scripts package
 
44
# --------------------------------------------------------------------------
 
45
# ***** BEGIN GPL LICENSE BLOCK *****
 
46
#
 
47
# Script copyright (C) 2003, 2004: Jean-Michel Soler 
 
48
#
 
49
# This program is free software; you can redistribute it and/or
 
50
# modify it under the terms of the GNU General Public License
 
51
# as published by the Free Software Foundation; either version 2
 
52
# of the License, or (at your option) any later version.
 
53
#
 
54
# This program is distributed in the hope that it will be useful,
 
55
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
56
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
57
# GNU General Public License for more details.
 
58
#
 
59
# You should have received a copy of the GNU General Public License
 
60
# along with this program; if not, write to the Free Software Foundation,
 
61
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
62
#
 
63
# ***** END GPL LICENCE BLOCK *****
 
64
# --------------------------------------------------------------------------
 
65
 
 
66
import Blender
 
67
 
 
68
def fix_mesh(nomdelobjet):
 
69
        Mesh=Blender.NMesh.GetRawFromObject(nomdelobjet)
 
70
        Obis = Blender.Object.New ('Mesh')
 
71
        Obis.link(Mesh)
 
72
        Obis.setMatrix(Ozero.getMatrix())
 
73
        scene = Blender.Scene.getCurrent()
 
74
        scene.link (Obis)
 
75
        try :
 
76
                Mesh2=Obis.getData()
 
77
                Mesh1=Ozero.getData()
 
78
                if len(Mesh2.verts)==len(Mesh1.verts): 
 
79
                        for VertGroupName in Mesh1.getVertGroupNames():
 
80
                                VertexList = Mesh1.getVertsFromGroup(VertGroupName, True)
 
81
                                Mesh2.addVertGroup(VertGroupName)
 
82
                                for Vertex in VertexList:
 
83
                                        Mesh2.assignVertsToGroup(VertGroupName, [Vertex[0]], Vertex[1], 'add')
 
84
                else:
 
85
                        for vgroupname in Mesh1.getVertGroupNames():
 
86
                                Mesh2.addVertGroup(vgroupname)
 
87
                Mesh2.update()
 
88
        except:
 
89
                print "mesh has no vertex group "
 
90
 
 
91
Ozero=Blender.Object.GetSelected()[0]
 
92
 
 
93
errormsg = ''
 
94
 
 
95
if not Ozero:
 
96
        errormsg = "no mesh object selected"
 
97
elif Ozero.getType() != "Mesh":
 
98
        errormsg = "selected (active) object must be a mesh"
 
99
 
 
100
if errormsg:
 
101
        Blender.Draw.PupMenu("ERROR: %s" % errormsg)
 
102
 
 
103
else:
 
104
        fix = 1
 
105
        curframe = Blender.Get('curframe')
 
106
        if Ozero.isSB() and curframe != 1:
 
107
                softbodies=Blender.Draw.PupMenu("Soft Body: play anim up to the current frame to fix it?%t|Yes%x1|No %x2|Cancel %x3")
 
108
                if softbodies==3:
 
109
                        fix = 0
 
110
                elif softbodies==1:
 
111
                        for f in range(1, curframe + 1):
 
112
                                Blender.Set('curframe',f)
 
113
                                Blender.Window.RedrawAll()
 
114
        if fix: fix_mesh(Ozero.getName())