blender/release/scripts/camera_changer.py
Willian Padovani Germano 8f080e024f BPython: bug fixes / patches from trackers
(excuse me for not committing earlier)

Patches by Ken Hughes (thanks for all bug fixes!):

1) Setting a scene's MapOld and MapNew values in python does nothing:
bug #2566 submitted by Dominic Agoro-Ombaka (dmao):
https://projects.blender.org/tracker/?func=detail&aid=2566&group_id=9&atid=125
patch #2571:
https://projects.blender.org/tracker/index.php?func=detail&aid=2571&group_id=9&atid=127

2) Calling the file selector after setting the progress bar crashes Blender:
bug #2418 submitted by Alessandro Garosi (brandano):
https://projects.blender.org/tracker/?func=detail&aid=2418&group_id=9&atid=125
patch #2568:
https://projects.blender.org/tracker/index.php?func=detail&aid=2568&group_id=9&atid=127

3) Menus always generate same event when canceled:
bug #2429 submitted by Campbell Barton:
https://projects.blender.org/tracker/?func=detail&aid=2429&group_id=9&atid=125
patch #2579:
https://projects.blender.org/tracker/?func=detail&aid=2579&group_id=9&atid=127

4) Add a vertex to a mesh with groups using a script and then edit that mesh hangs blender:
bug #2211 reported by German Alonso Tamayo (servivo):
https://projects.blender.org/tracker/index.php?func=detail&aid=2211&group_id=9&atid=125
patch #2580
#https://projects.blender.org/tracker/index.php?func=detail&aid=2580&group_id=9&atid=127

About bug #2033, I'm still looking at it, committing a small fix now.

=====

Patches by Campbell Barton (thanks!):

#2482: BGL pydocs fix broken links
https://projects.blender.org/tracker/index.php?func=detail&aid=2482&group_id=9&atid=127

#2426: Large text in Draw.Text and Draw.GetStreingWidth
https://projects.blender.org/tracker/index.php?func=detail&aid=2462&group_id=9&atid=127

#2521: scene.getActiveObject()
https://projects.blender.org/tracker/index.php?func=detail&aid=2521&group_id=9&atid=127

#2523: NMesh.GetNames()
https://projects.blender.org/tracker/index.php?func=detail&aid=2523&group_id=9&atid=127

- docs also updated
2005-05-20 05:14:03 +00:00

121 lines
4.2 KiB
Python

#!BPY
""" Registration info for Blender menus: <- these words are ignored
Name: 'Camera Changer'
Blender: 234
Group: 'Animation'
Tip: 'Create script link to change cameras (based on their names) during an animation'
"""
__author__ = '3R - R3gis'
__version__ = '1.2'
__url__ = ["Author's site , http://cybercreator.free.fr", "French Blender support forum, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender"]
__email__=["3R, r3gis@free.fr"]
__bpydoc__ = """\
This script creates an script link to change cameras during an animation.
The created script link (a Blender Text) is linked to Scene Frame Changed events.
Usage:
Run the script, then name the camera Object with the number of the frame(s)
where you want this camera to become active.
For example:<br>
- a camera called "10" will become active at frame 10.<br>
- a camera called "10,25,185" will become active at frames 10, 25 and 185.
Notes:<br>
- This script creates another script named camera.py, which is linked to the current scene.<br>
- If there is already a text called "camera.py", but it's from an old version or is not recognized,
you can choose if you want to rename or overwrite it.
- Script inspired by Jean-Michel (jms) Soler's:<br>
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_changerdecamera.htm
"""
# $Id$
#
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2004-2005: Regis Montoya
#
# 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 *****
# --------------------------------------------------------------------------
#Script inspired of the idea of this one :
#http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_changerdecamera.htm
#
#----------------------------------------------
# R3gis Montoya (3R)
#
# Pout tout probleme a:
# cybercreator@free.fr
# ---------------------------------------------
import Blender
from Blender import *
import string
sc=Scene.GetCurrent()
#import du texte
lestext=Blender.Text.Get()
Ntexts=[]
for txt in lestext:
Ntexts.append(txt.getName())
ecrire=0
if 'camera.py' not in Ntexts:
ecrire=1
else :
if lestext[Ntexts.index('camera.py')].asLines()[0] != "# camera.py 1.2 link python #":
reecrire=Blender.Draw.PupMenu("WARNING: Text camera.py already exists but is outdated%t|Overwrite|Rename old version text")
if reecrire == 1:
Text.unlink(lestext[Ntexts.index('camera.py')])
ecrire=1
if reecrire == 2:
lestext[Ntexts.index('camera.py')].name="old_camera.txt"
ecrire=1
if ecrire == 1:
scripting=Blender.Text.New('camera.py')
scripting.write("# camera.py 1.2 link python #\nimport Blender\nfrom Blender import *\nfrom math import *\nimport string\n")
scripting.write("sc=Scene.GetCurrent()\n#Changement camera\nlescam=[]\nobjets=Blender.Object.Get()\n")
scripting.write("for ob in objets:\n if type(ob.getData())==Blender.Types.CameraType:\n try:")
scripting.write("\n lesfram=string.split(ob.name,',')\n for fr in lesfram:\n lescam.append(ob.name)\n lescam.append(int(fr))\n except:\n pass")
scripting.write("\nframe = Blender.Get('curframe')\nif frame in lescam:\n nom=lescam.index(frame)\n sc.setCurrentCamera(Blender.Object.Get(lescam[nom-1]))\n")
#Linkage
list=[]
try:
for script in sc.getScriptLinks('FrameChanged'):
list.append(script)
except:
pass
if 'camera.py' not in list:
sc.addScriptLink('camera.py','FrameChanged')
Blender.Draw.PupMenu("Done! Remember:%t|Name cameras as (a comma separated list of) their activation frame number(s)")
Blender.Redraw(-1)