2003-02-26 19:22:24 +00:00
|
|
|
/*
|
2004-07-21 21:01:15 +00:00
|
|
|
* $Id$
|
2003-02-26 19:22:24 +00:00
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* 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. The Blender
|
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
|
* about this.
|
|
|
|
|
*
|
|
|
|
|
* 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,
|
2004-04-24 20:04:37 +00:00
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2003-02-26 19:22:24 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This is a new part of Blender.
|
|
|
|
|
*
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
* Contributor(s): Michel Selten, Willian P. Germano, Joseph Gilbert,
|
|
|
|
|
* Campbell Barton
|
2003-02-26 19:22:24 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
2005-07-18 03:50:37 +00:00
|
|
|
struct ID; /*keep me up here */
|
2003-02-26 19:22:24 +00:00
|
|
|
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Blender.h" /*This must come first */
|
BPython:
- tentative fix for scripts with CR/LF endings and split lines:
in 2.32, the ac3d and vrml2 exporters, for example, had lines
split with '\\\\' and so gave syntax errors when executed on Win
platforms, because the scripts bundled with Win binaries had dos
line endings.
- Chris Keith has written code to execute Python scripts from the
command-line, with '-P ' switch: "blender -P filename":
a Blender.Quit function was also added, so Blender can quit after
running the script (end the script with Blender.Quit()), but there's
still work to be done in this part, including adding more functions,
to load / save .blend files and to run scripts. More testing and
discussions are necessary.
Thanks Chris, for both your contributions and your patience, since I
wasn't available to check / commit this for a while.
2004-03-31 04:18:39 +00:00
|
|
|
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
/* for open, close in Blender_Load */
|
|
|
|
|
#include <fcntl.h>
|
Mathutils update
- also included is some fixes for preprocessor inclues and some clean up of the previous commit
-rewrite and bugfixes
----------------------------------
Here's my changelog:
-fixed Rand() so that it doesn't seed everytime and should generate better random numbers
- changed a few error return types to something more appropriate
- clean up of uninitialized variables & removal of unneccessary objects
- NMesh returns wrapped vectors now
- World returns wrapped matrices now
- Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present
- Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix
- Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks
- Removed memory allocation (unneeded) from all methods
- Vector's resize methods are only applicable to new vectors not wrapped data.
- Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences
- Fixed Slerp() so that it now works correctly values are clamped between 0 and 1
- Euler.rotate does internal rotation now
- Slice assignment now works better for all types
- Vector * Vector and Quat * Quat are defined and return the DOT product
- Mat * Vec and Vec * Mat are defined now
- Moved #includes to .c file from headers. Also fixed prototypes in mathutils
- Added new helper functions for incref'ing to genutils
- Major cleanup of header files includes - include Mathutils.h for access to math types
- matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes
- Matrix() with no parameters now returns an identity matrix by default not a zero matrix
- printf() now prints with 6 digits instead of 4
- printf() now prints output with object descriptor
- Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4)
- Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix.
- slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data.
- slice assignment will no longer modify the data if the assignment operation fails
- fixed error in matrix * scalar multiplication
- euler.toMatrix(), toQuat() no longer causes "creep" from repeated use
- Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used
- Quats can be created with angle/axis, axis/angle
- 4x4 matrices can be multiplied by 3D vectors (by popular demand :))
- vec *quat / quat * vec is now defined
- vec.magnitude alias for vec.length
- all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none')
- these methods have been deprecated (still functioning but suggested to use the corrected functionality):
* CopyVec() - replaced by Vector() functionality
* CopyMat() - replaced by Matrix() functionality
* CopyQuat() - replace by Quaternion() functionality
* CopyEuler() - replaced by Euler() functionality
* RotateEuler() - replaced by Euler.rotate() funtionality
* MatMultVec() - replaced by matrix * vector
* VecMultMat() - replaced by vector * matrix
- New struct containers references to python object data or internally allocated blender data for wrapping
* Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python
* otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
2005-07-14 03:34:56 +00:00
|
|
|
#include "BDR_editobject.h" /* exit_editmode() */
|
|
|
|
|
#include "BIF_usiblender.h"
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLO_writefile.h"
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
#include "BKE_blender.h"
|
Mathutils update
- also included is some fixes for preprocessor inclues and some clean up of the previous commit
-rewrite and bugfixes
----------------------------------
Here's my changelog:
-fixed Rand() so that it doesn't seed everytime and should generate better random numbers
- changed a few error return types to something more appropriate
- clean up of uninitialized variables & removal of unneccessary objects
- NMesh returns wrapped vectors now
- World returns wrapped matrices now
- Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present
- Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix
- Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks
- Removed memory allocation (unneeded) from all methods
- Vector's resize methods are only applicable to new vectors not wrapped data.
- Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences
- Fixed Slerp() so that it now works correctly values are clamped between 0 and 1
- Euler.rotate does internal rotation now
- Slice assignment now works better for all types
- Vector * Vector and Quat * Quat are defined and return the DOT product
- Mat * Vec and Vec * Mat are defined now
- Moved #includes to .c file from headers. Also fixed prototypes in mathutils
- Added new helper functions for incref'ing to genutils
- Major cleanup of header files includes - include Mathutils.h for access to math types
- matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes
- Matrix() with no parameters now returns an identity matrix by default not a zero matrix
- printf() now prints with 6 digits instead of 4
- printf() now prints output with object descriptor
- Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4)
- Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix.
- slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data.
- slice assignment will no longer modify the data if the assignment operation fails
- fixed error in matrix * scalar multiplication
- euler.toMatrix(), toQuat() no longer causes "creep" from repeated use
- Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used
- Quats can be created with angle/axis, axis/angle
- 4x4 matrices can be multiplied by 3D vectors (by popular demand :))
- vec *quat / quat * vec is now defined
- vec.magnitude alias for vec.length
- all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none')
- these methods have been deprecated (still functioning but suggested to use the corrected functionality):
* CopyVec() - replaced by Vector() functionality
* CopyMat() - replaced by Matrix() functionality
* CopyQuat() - replace by Quaternion() functionality
* CopyEuler() - replaced by Euler() functionality
* RotateEuler() - replaced by Euler.rotate() funtionality
* MatMultVec() - replaced by matrix * vector
* VecMultMat() - replaced by vector * matrix
- New struct containers references to python object data or internally allocated blender data for wrapping
* Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python
* otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
2005-07-14 03:34:56 +00:00
|
|
|
#include "BKE_exotic.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_packedFile.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "BKE_utildefines.h"
|
Mathutils update
- also included is some fixes for preprocessor inclues and some clean up of the previous commit
-rewrite and bugfixes
----------------------------------
Here's my changelog:
-fixed Rand() so that it doesn't seed everytime and should generate better random numbers
- changed a few error return types to something more appropriate
- clean up of uninitialized variables & removal of unneccessary objects
- NMesh returns wrapped vectors now
- World returns wrapped matrices now
- Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present
- Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix
- Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks
- Removed memory allocation (unneeded) from all methods
- Vector's resize methods are only applicable to new vectors not wrapped data.
- Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences
- Fixed Slerp() so that it now works correctly values are clamped between 0 and 1
- Euler.rotate does internal rotation now
- Slice assignment now works better for all types
- Vector * Vector and Quat * Quat are defined and return the DOT product
- Mat * Vec and Vec * Mat are defined now
- Moved #includes to .c file from headers. Also fixed prototypes in mathutils
- Added new helper functions for incref'ing to genutils
- Major cleanup of header files includes - include Mathutils.h for access to math types
- matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes
- Matrix() with no parameters now returns an identity matrix by default not a zero matrix
- printf() now prints with 6 digits instead of 4
- printf() now prints output with object descriptor
- Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4)
- Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix.
- slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data.
- slice assignment will no longer modify the data if the assignment operation fails
- fixed error in matrix * scalar multiplication
- euler.toMatrix(), toQuat() no longer causes "creep" from repeated use
- Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used
- Quats can be created with angle/axis, axis/angle
- 4x4 matrices can be multiplied by 3D vectors (by popular demand :))
- vec *quat / quat * vec is now defined
- vec.magnitude alias for vec.length
- all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none')
- these methods have been deprecated (still functioning but suggested to use the corrected functionality):
* CopyVec() - replaced by Vector() functionality
* CopyMat() - replaced by Matrix() functionality
* CopyQuat() - replace by Quaternion() functionality
* CopyEuler() - replaced by Euler() functionality
* RotateEuler() - replaced by Euler.rotate() funtionality
* MatMultVec() - replaced by matrix * vector
* VecMultMat() - replaced by vector * matrix
- New struct containers references to python object data or internally allocated blender data for wrapping
* Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python
* otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
2005-07-14 03:34:56 +00:00
|
|
|
#include "BKE_object.h"
|
2006-03-29 23:16:09 +00:00
|
|
|
#include "BKE_scene.h"
|
Mathutils update
- also included is some fixes for preprocessor inclues and some clean up of the previous commit
-rewrite and bugfixes
----------------------------------
Here's my changelog:
-fixed Rand() so that it doesn't seed everytime and should generate better random numbers
- changed a few error return types to something more appropriate
- clean up of uninitialized variables & removal of unneccessary objects
- NMesh returns wrapped vectors now
- World returns wrapped matrices now
- Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present
- Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix
- Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks
- Removed memory allocation (unneeded) from all methods
- Vector's resize methods are only applicable to new vectors not wrapped data.
- Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences
- Fixed Slerp() so that it now works correctly values are clamped between 0 and 1
- Euler.rotate does internal rotation now
- Slice assignment now works better for all types
- Vector * Vector and Quat * Quat are defined and return the DOT product
- Mat * Vec and Vec * Mat are defined now
- Moved #includes to .c file from headers. Also fixed prototypes in mathutils
- Added new helper functions for incref'ing to genutils
- Major cleanup of header files includes - include Mathutils.h for access to math types
- matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes
- Matrix() with no parameters now returns an identity matrix by default not a zero matrix
- printf() now prints with 6 digits instead of 4
- printf() now prints output with object descriptor
- Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4)
- Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix.
- slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data.
- slice assignment will no longer modify the data if the assignment operation fails
- fixed error in matrix * scalar multiplication
- euler.toMatrix(), toQuat() no longer causes "creep" from repeated use
- Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used
- Quats can be created with angle/axis, axis/angle
- 4x4 matrices can be multiplied by 3D vectors (by popular demand :))
- vec *quat / quat * vec is now defined
- vec.magnitude alias for vec.length
- all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none')
- these methods have been deprecated (still functioning but suggested to use the corrected functionality):
* CopyVec() - replaced by Vector() functionality
* CopyMat() - replaced by Matrix() functionality
* CopyQuat() - replace by Quaternion() functionality
* CopyEuler() - replaced by Euler() functionality
* RotateEuler() - replaced by Euler.rotate() funtionality
* MatMultVec() - replaced by matrix * vector
* VecMultMat() - replaced by vector * matrix
- New struct containers references to python object data or internally allocated blender data for wrapping
* Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python
* otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
2005-07-14 03:34:56 +00:00
|
|
|
#include "BKE_text.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "BKE_ipo.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_main.h"
|
Mathutils update
- also included is some fixes for preprocessor inclues and some clean up of the previous commit
-rewrite and bugfixes
----------------------------------
Here's my changelog:
-fixed Rand() so that it doesn't seed everytime and should generate better random numbers
- changed a few error return types to something more appropriate
- clean up of uninitialized variables & removal of unneccessary objects
- NMesh returns wrapped vectors now
- World returns wrapped matrices now
- Object.getEuler() and Object.getBoundingBox() return Wrapped data when data is present
- Object.getMatrix() returns wrapped data if it's worldspace, 'localspace' returns a new matrix
- Vector, Euler, Mat, Quat, call all now internally wrap object without destroying internal datablocks
- Removed memory allocation (unneeded) from all methods
- Vector's resize methods are only applicable to new vectors not wrapped data.
- Matrix(), Quat(), Euler(), Vector() now accepts ANY sequence list, including tuples, list, or a self object to copy - matrices accept multiple sequences
- Fixed Slerp() so that it now works correctly values are clamped between 0 and 1
- Euler.rotate does internal rotation now
- Slice assignment now works better for all types
- Vector * Vector and Quat * Quat are defined and return the DOT product
- Mat * Vec and Vec * Mat are defined now
- Moved #includes to .c file from headers. Also fixed prototypes in mathutils
- Added new helper functions for incref'ing to genutils
- Major cleanup of header files includes - include Mathutils.h for access to math types
- matrix.toQuat() and .toEuler() now fixed take appropriate matrix sizes
- Matrix() with no parameters now returns an identity matrix by default not a zero matrix
- printf() now prints with 6 digits instead of 4
- printf() now prints output with object descriptor
- Matrices now support [x][y] assignment (e.g. matrix[x][y] = 5.4)
- Matrix[index] = value now expectes a sequence not an integer. This will now set a ROW of the matrix through a sequence. index cannot go above the row size of the matrix.
- slice operations on matrices work with sequences now (rows of the matrix) example: mymatrix[0:2] returns a list of 2 wrapped vectors with access to the matrix data.
- slice assignment will no longer modify the data if the assignment operation fails
- fixed error in matrix * scalar multiplication
- euler.toMatrix(), toQuat() no longer causes "creep" from repeated use
- Wrapped data will generate wrapped objects when toEuler(), toQuat(), toMatrix() is used
- Quats can be created with angle/axis, axis/angle
- 4x4 matrices can be multiplied by 3D vectors (by popular demand :))
- vec *quat / quat * vec is now defined
- vec.magnitude alias for vec.length
- all self, internal methods return a pointer to self now so you can do print vector.internalmethod() or vector.internalmethod().nextmethod() (no more print matrix.inverse() returning 'none')
- these methods have been deprecated (still functioning but suggested to use the corrected functionality):
* CopyVec() - replaced by Vector() functionality
* CopyMat() - replaced by Matrix() functionality
* CopyQuat() - replace by Quaternion() functionality
* CopyEuler() - replaced by Euler() functionality
* RotateEuler() - replaced by Euler.rotate() funtionality
* MatMultVec() - replaced by matrix * vector
* VecMultMat() - replaced by vector * matrix
- New struct containers references to python object data or internally allocated blender data for wrapping
* Explaination here: math structs now function as a 'simple wrapper' or a 'py_object' - data that is created on the fly will now be a 'py_object' with its memory managed by python
* otherwise if the data is returned by blender's G.main then the math object is a 'simple wrapper' and data can be accessed directly from the struct just like other python objects.
2005-07-14 03:34:56 +00:00
|
|
|
#include "BPI_script.h"
|
|
|
|
|
#include "BSE_headerbuttons.h"
|
|
|
|
|
#include "DNA_screen_types.h" /* for SPACE_VIEW3D */
|
|
|
|
|
#include "DNA_userdef_types.h"
|
2006-05-06 06:17:46 +00:00
|
|
|
#include "DNA_packedFile_types.h"
|
2005-03-21 05:26:52 +00:00
|
|
|
#include "EXPP_interface.h" /* for bpy_gethome() */
|
2004-05-18 03:23:45 +00:00
|
|
|
#include "gen_utils.h"
|
|
|
|
|
#include "modules.h"
|
BPython:
- Made Blender.event var (previously only used by script links) hold ascii value -- where it applies -- of current event during events callback registered with Draw.Register(gui, events, button_events). Useful for gui scripts like Campbell's Python console. No problem using this var to hold the value, since in gui scripts it was not used (always None).
- Updated Window and Window.Theme with new theme vars and the Time space.
- Script links:
-- Added "Render" event for script links (runs twice, second time as "PostEvent", for clean-up actions). Now FrameChanged links don't run when a single pic is rendered.
-- Added "Enable Script Links" button in the script buttons tab. Now this bit gets saved in .blends along with the rest of G.f, so users can define per .blend if they are on or off by default. "blender -y" also disables all slinks as happened before with OnLoad ones only.
-- Other small changes in the script buttons tab:
When a link is added (button "new"), it becomes the active one for the window, no need to press a button to reach it.
Also, a pupmenu showing all available texts is shown when "new" is pressed, so users can choose a text w/o having to type. Cancel the popup to leave the string button empty (link exists, but has no script assigned). A pulldown would be better UI-wise, but it's kinda weird to show both scripts and normal texts (Blender doesn't differentiate them) in a script links pulldown. With a popup we can show only texts ending in ".py" (not done in this commit, need opinions) and if the script has no or another extension, case of many in old and current .blend's, there's still the string box for writing its name.
-- Implemented Ton's space handler script links:
Right now only for the 3d View, but it's trivial to add for others. There are two types: EVENT, to receive 3d View events from a chosen window and DRAW, to draw on the window. Ton's idea was to give scripts a controlled way to integrate better within Blender.
Here's how it works:
- scripts must have a proper header, like:
# SPACEHANDLER.VIEW3D.EVENT
and then they are shown in 3d View's View menu, "Space Handler Scripts" submenu. Check (mark, click on it) a script to make it active.
EVENT handlers should consult the Blender.event var to get the current event, which can be compared with values from the Draw module:
import Blender
from Blender import Draw
evt = Blender.event
if evt == Draw.AKEY:
print "a"
elif evt == Draw.LEFTMOUSE:
print "left mouse button"
else:
return # ignore, pass event back to Blender
Blender.event = None # tell Blender not to process itself the event
DRAW handlers are free to draw to their owner 3D View. OpenGL attributes and modelview and projection matrices are pushed before running the handler and poped when it finishes.
To communicate between EVENT and DRAW handler scripts we have the Blender.Registry module, as always.
Still need to code some nice example, which should also serve to test properly space handlers. Simple tests went fine.
- doc updates about the additions.
=======
Note: the UI part of the space handlers and script links is of course open for changes, I just tried to make it understandable. Probably we won't use the scriptlinks icon for "None Available" (check 3d View -> View -> Space Handler Scripts), though it hints at what space handlers are. The tooltips may not be accepted either, since other menus don't use them. Opinions welcomed.
2005-05-08 21:20:34 +00:00
|
|
|
#include "constant.h"
|
2005-03-21 05:26:52 +00:00
|
|
|
#include "../BPY_extern.h" /* BPY_txt_do_python_Text */
|
2005-01-13 19:19:05 +00:00
|
|
|
#include "../BPY_menus.h" /* to update menus */
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Armature.h"
|
|
|
|
|
#include "BezTriple.h"
|
|
|
|
|
#include "Camera.h"
|
2006-05-07 14:57:58 +00:00
|
|
|
#include "Constraint.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Curve.h"
|
|
|
|
|
#include "CurNurb.h"
|
|
|
|
|
#include "Draw.h"
|
|
|
|
|
#include "Effect.h"
|
|
|
|
|
#include "Ipo.h"
|
|
|
|
|
#include "Ipocurve.h"
|
2007-04-01 03:58:42 +00:00
|
|
|
#include "IDProp.h"
|
2005-09-09 01:31:10 +00:00
|
|
|
#include "Key.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Lamp.h"
|
|
|
|
|
#include "Lattice.h"
|
2007-03-21 14:25:31 +00:00
|
|
|
#include "Library.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Mathutils.h"
|
2006-07-02 15:28:28 +00:00
|
|
|
#include "Geometry.h"
|
2005-10-03 19:36:15 +00:00
|
|
|
#include "Mesh.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Metaball.h"
|
2006-04-23 17:01:04 +00:00
|
|
|
#include "Modifier.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "NMesh.h"
|
|
|
|
|
#include "Object.h"
|
2006-03-18 14:47:26 +00:00
|
|
|
#include "Group.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Registry.h"
|
|
|
|
|
#include "Scene.h"
|
|
|
|
|
#include "Sound.h"
|
2006-08-28 04:44:16 +00:00
|
|
|
#include "SurfNurb.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
#include "Sys.h"
|
|
|
|
|
#include "Text.h"
|
|
|
|
|
#include "Texture.h"
|
|
|
|
|
#include "Window.h"
|
|
|
|
|
#include "World.h"
|
2006-04-16 15:28:50 +00:00
|
|
|
#include "Types.h"
|
2005-07-18 03:50:37 +00:00
|
|
|
|
2004-05-18 03:23:45 +00:00
|
|
|
/**********************************************************/
|
|
|
|
|
/* Python API function prototypes for the Blender module. */
|
|
|
|
|
/**********************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Set( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *Blender_Get( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *Blender_Redraw( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *Blender_Quit( PyObject * self );
|
|
|
|
|
static PyObject *Blender_Load( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *Blender_Save( PyObject * self, PyObject * args );
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
static PyObject *Blender_Run( PyObject * self, PyObject * args );
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
static PyObject *Blender_ShowHelp( PyObject * self, PyObject * args );
|
2005-01-13 19:19:05 +00:00
|
|
|
static PyObject *Blender_UpdateMenus( PyObject * self);
|
2006-05-06 06:17:46 +00:00
|
|
|
static PyObject *Blender_PackAll( PyObject * self);
|
|
|
|
|
static PyObject *Blender_UnpackAll( PyObject * self, PyObject * args);
|
|
|
|
|
static PyObject *Blender_CountPackedFiles( PyObject * self );
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
extern PyObject *Text3d_Init( void ); /* missing in some include */
|
|
|
|
|
|
2004-05-18 03:23:45 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* The following string definitions are used for documentation strings. */
|
|
|
|
|
/* In Python these will be written to the console when doing a */
|
|
|
|
|
/* Blender.__doc__ */
|
2004-05-18 03:23:45 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
static char Blender_Set_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(request, data) - Update settings in Blender\n\
|
2004-05-18 03:23:45 +00:00
|
|
|
\n\
|
|
|
|
|
(request) A string identifying the setting to change\n\
|
|
|
|
|
'curframe' - Sets the current frame using the number in data";
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static char Blender_Get_doc[] = "(request) - Retrieve settings from Blender\n\
|
2004-05-18 03:23:45 +00:00
|
|
|
\n\
|
|
|
|
|
(request) A string indentifying the data to be returned\n\
|
|
|
|
|
'curframe' - Returns the current animation frame\n\
|
|
|
|
|
'curtime' - Returns the current animation time\n\
|
|
|
|
|
'staframe' - Returns the start frame of the animation\n\
|
|
|
|
|
'endframe' - Returns the end frame of the animation\n\
|
|
|
|
|
'filename' - Returns the name of the last file read or written\n\
|
2004-11-02 05:13:52 +00:00
|
|
|
'homedir' - Returns Blender's home dir\n\
|
2004-05-22 20:25:22 +00:00
|
|
|
'datadir' - Returns the dir where scripts can save their data, if available\n\
|
- Blender: added option 'scriptsdir' to Blender.Get();
- small updates to the docs;
- Object: small fix to getMatrix: check during_script() to avoid undesired loops; added old behavior (pre 2.34) as option: .getMatrix('oldlocal');
- tentative fix for bug #1275: scene REDRAW scriptlinks were not being executed (the call to do so was missing):
http://projects.blender.org/tracker/index.php?func=detail&aid=1275&group_id=9&atid=125
added the call in drawview.c, in drawview3dspace(). This causes the scriptlink to be called for each visible view3d, but that's what happens with object redraw scriptlinks, too. Anyway, this is still a test. The place was chosen based on the idea that a scene redraw scriptlink is like an object redraw one, but for all objs in the scene at once.
- Window.Theme: new submodule, to get/set theme options in Blender;
- Added the script save_theme.py (Help menu for now), to save the current theme in Blender as an executable script (currently shown in the Scripts->Misc menu).
There's more work to do for themes, like defining a proper place for them in the interface, adding documentation (for now the added script and the ones it generates can give a pretty good idea of how to use the new module), probably extending themes to support SpaceScript and so on.
2004-09-21 05:28:17 +00:00
|
|
|
'scriptsdir' - Returns the main dir where scripts are kept, if available\n\
|
2004-11-02 05:13:52 +00:00
|
|
|
'uscriptsdir' - Returns the user defined dir for scripts, if available\n\
|
2004-05-18 03:23:45 +00:00
|
|
|
'version' - Returns the Blender version number";
|
|
|
|
|
|
|
|
|
|
static char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
|
|
|
|
|
|
|
|
|
|
static char Blender_Quit_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static char Blender_Load_doc[] = "(filename) - Load the given file.\n\
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
Supported formats:\n\
|
|
|
|
|
Blender, DXF, Inventor 1.0 ASCII, VRML 1.0 asc, STL, Videoscape, radiogour.\n\
|
|
|
|
|
\n\
|
2004-05-18 03:23:45 +00:00
|
|
|
Notes:\n\
|
|
|
|
|
1 - () - an empty argument loads the default .B.blend file;\n\
|
|
|
|
|
2 - if the substring '.B.blend' occurs inside 'filename', the default\n\
|
|
|
|
|
.B.blend file is loaded;\n\
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
3 - If a Blender file is loaded the script ends immediately.\n\
|
|
|
|
|
4 - The current data is always preserved as an autosave file, for safety;\n\
|
|
|
|
|
5 - This function only works if the script where it's executed is the\n\
|
|
|
|
|
only one running at the moment.";
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-06-24 09:43:13 +00:00
|
|
|
static char Blender_Save_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(filename) - Save data to a file based on the filename's extension.\n\
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
Supported are: Blender's .blend and the builtin exporters:\n\
|
|
|
|
|
VRML 1.0 (.wrl), Videoscape (.obj), DXF (.dxf) and STL (.stl)\n\
|
|
|
|
|
(filename) - A filename with one of the supported extensions.\n\
|
|
|
|
|
Note 1: 'filename' should not contain the substring \".B.blend\" in it.\n\
|
|
|
|
|
Note 2: only .blend raises an error if file wasn't saved.\n\
|
|
|
|
|
\tYou can use Blender.sys.exists(filename) to make sure the file was saved\n\
|
|
|
|
|
\twhen writing to one of the other formats.";
|
2004-06-24 09:43:13 +00:00
|
|
|
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
static char Blender_Run_doc[] =
|
|
|
|
|
"(script) - Run the given Python script.\n\
|
|
|
|
|
(script) - the path to a file or the name of an available Blender Text.";
|
|
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
static char Blender_ShowHelp_doc[] =
|
|
|
|
|
"(script) - Show help for the given Python script.\n\
|
|
|
|
|
This will try to open the 'Scripts Help Browser' script, so to have\n\
|
|
|
|
|
any help displayed the passed 'script' must be properly documented\n\
|
|
|
|
|
with the expected strings (check API ref docs or any bundled script\n\
|
|
|
|
|
for examples).\n\n\
|
|
|
|
|
(script) - the filename of a script in the default or user defined\n\
|
|
|
|
|
scripts dir (no need to supply the full path name).";
|
|
|
|
|
|
2005-01-13 19:19:05 +00:00
|
|
|
static char Blender_UpdateMenus_doc[] =
|
|
|
|
|
"() - Update the menus where scripts are registered. Only needed for\n\
|
|
|
|
|
scripts that save other new scripts in the default or user defined folders.";
|
|
|
|
|
|
2006-05-06 06:17:46 +00:00
|
|
|
static char Blender_PackAll_doc[] =
|
|
|
|
|
"() - Pack all files.\n\
|
|
|
|
|
All files will packed into the blend file.";
|
|
|
|
|
static char Blender_UnpackAll_doc[] =
|
|
|
|
|
"(mode) - Unpack files.\n\
|
|
|
|
|
All files will be unpacked using specified mode.\n\n\
|
|
|
|
|
(mode) - the unpack mode.";
|
|
|
|
|
|
|
|
|
|
static char Blender_CountPackedFiles_doc[] =
|
|
|
|
|
"() - Returns the number of packed files.";
|
|
|
|
|
|
2004-05-18 03:23:45 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Python method structure definition. */
|
2004-05-18 03:23:45 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
static struct PyMethodDef Blender_methods[] = {
|
2004-09-25 20:30:40 +00:00
|
|
|
{"Set", Blender_Set, METH_VARARGS, Blender_Set_doc},
|
|
|
|
|
{"Get", Blender_Get, METH_VARARGS, Blender_Get_doc},
|
2004-05-18 03:23:45 +00:00
|
|
|
{"Redraw", Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
|
2004-09-25 20:30:40 +00:00
|
|
|
{"Quit", ( PyCFunction ) Blender_Quit, METH_NOARGS, Blender_Quit_doc},
|
2004-05-18 03:23:45 +00:00
|
|
|
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
|
2004-06-24 09:43:13 +00:00
|
|
|
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
{"Run", Blender_Run, METH_VARARGS, Blender_Run_doc},
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
{"ShowHelp", Blender_ShowHelp, METH_VARARGS, Blender_ShowHelp_doc},
|
2006-05-06 06:17:46 +00:00
|
|
|
{"CountPackedFiles", ( PyCFunction ) Blender_CountPackedFiles, METH_NOARGS, Blender_CountPackedFiles_doc},
|
|
|
|
|
{"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc},
|
|
|
|
|
{"UnpackAll", Blender_UnpackAll, METH_VARARGS, Blender_UnpackAll_doc},
|
2005-01-13 19:19:05 +00:00
|
|
|
{"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
|
|
|
|
|
Blender_UpdateMenus_doc},
|
2004-09-25 20:30:40 +00:00
|
|
|
{NULL, NULL, 0, NULL}
|
2004-05-18 03:23:45 +00:00
|
|
|
};
|
2003-03-08 18:10:20 +00:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Global variables */
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2003-04-21 20:33:06 +00:00
|
|
|
PyObject *g_blenderdict;
|
2003-03-08 18:10:20 +00:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Function: Blender_Set */
|
|
|
|
|
/* Python equivalent: Blender.Set */
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Set( PyObject * self, PyObject * args )
|
2003-02-26 19:22:24 +00:00
|
|
|
{
|
2006-09-21 18:25:40 +00:00
|
|
|
char *name, *dir = NULL;
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *arg;
|
|
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "sO", &name, &arg ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected 2 args, where the first is always a string" );
|
2004-04-24 20:04:37 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( StringEqual( name, "curframe" ) ) {
|
2006-12-26 19:13:13 +00:00
|
|
|
if( !PyInt_Check( arg ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError,
|
|
|
|
|
"expected an integer" );
|
|
|
|
|
|
|
|
|
|
G.scene->r.cfra = (short)PyInt_AsLong( arg ) ;
|
|
|
|
|
|
|
|
|
|
/* update all objects, so python scripts can export all objects
|
|
|
|
|
in a scene without worrying about the view layers */
|
2006-10-13 11:56:08 +00:00
|
|
|
scene_update_for_newframe(G.scene, (1<<20) - 1);
|
2006-09-21 18:25:40 +00:00
|
|
|
|
|
|
|
|
} else if (StringEqual( name , "uscriptsdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.pythondir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "yfexportdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.yfexportdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "fontsdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.fontdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "texturesdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.textudir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "texpluginsdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.plugtexdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "seqpluginsdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.plugseqdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "renderdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.renderdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "soundsdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.sounddir, dir, FILE_MAXDIR);
|
|
|
|
|
} else if (StringEqual( name , "tempdir" ) ) {
|
|
|
|
|
if ( !PyArg_Parse( arg , "s" , &dir ))
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
|
|
|
|
|
BLI_strncpy(U.tempdir, dir, FILE_MAXDIR);
|
|
|
|
|
} else
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
2006-09-21 18:25:40 +00:00
|
|
|
"value given is not a blender setting" ) );
|
|
|
|
|
Py_RETURN_NONE;
|
2003-02-26 19:22:24 +00:00
|
|
|
}
|
2003-03-08 18:10:20 +00:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Function: Blender_Get */
|
|
|
|
|
/* Python equivalent: Blender.Get */
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Get( PyObject * self, PyObject * args )
|
2003-03-08 18:10:20 +00:00
|
|
|
{
|
2005-12-05 01:07:24 +00:00
|
|
|
PyObject *ret = NULL;
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
char *str = NULL;
|
|
|
|
|
|
|
|
|
|
if( !PyArg_ParseTuple( args, "s", &str ) )
|
|
|
|
|
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
|
|
|
|
"expected string argument");
|
|
|
|
|
|
|
|
|
|
if( StringEqual( str, "curframe" ) )
|
|
|
|
|
ret = PyInt_FromLong( G.scene->r.cfra );
|
|
|
|
|
else if( StringEqual( str, "curtime" ) )
|
|
|
|
|
ret = PyFloat_FromDouble( frame_to_float( G.scene->r.cfra ) );
|
2006-05-17 16:42:04 +00:00
|
|
|
else if( StringEqual( str, "rt" ) )
|
2007-03-01 21:30:48 +00:00
|
|
|
ret = PyInt_FromLong( (long)frame_to_float( G.rt ) );
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
else if( StringEqual( str, "staframe" ) )
|
|
|
|
|
ret = PyInt_FromLong( G.scene->r.sfra );
|
|
|
|
|
else if( StringEqual( str, "endframe" ) )
|
|
|
|
|
ret = PyInt_FromLong( G.scene->r.efra );
|
2007-03-19 01:51:54 +00:00
|
|
|
else if( StringEqual( str, "filename" ) ) {
|
|
|
|
|
if ( strstr(G.main->name, ".B.blend") != 0)
|
2007-03-20 07:23:09 +00:00
|
|
|
ret = PyString_FromString("");
|
2007-03-19 01:51:54 +00:00
|
|
|
else
|
|
|
|
|
ret = PyString_FromString(G.main->name);
|
|
|
|
|
}
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
else if( StringEqual( str, "homedir" ) ) {
|
|
|
|
|
char *hdir = bpy_gethome(0);
|
2005-03-21 05:26:52 +00:00
|
|
|
if( hdir && BLI_exists( hdir ))
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
ret = PyString_FromString( hdir );
|
|
|
|
|
else
|
|
|
|
|
ret = EXPP_incr_ret( Py_None );
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
else if( StringEqual( str, "datadir" ) ) {
|
|
|
|
|
char datadir[FILE_MAXDIR];
|
2005-03-21 05:26:52 +00:00
|
|
|
char *sdir = bpy_gethome(1);
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
|
2005-03-21 05:26:52 +00:00
|
|
|
if (sdir) {
|
2005-03-22 04:28:36 +00:00
|
|
|
BLI_make_file_string( "/", datadir, sdir, "bpydata" );
|
2005-03-21 05:26:52 +00:00
|
|
|
if( BLI_exists( datadir ) )
|
|
|
|
|
ret = PyString_FromString( datadir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret( Py_None );
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
}
|
|
|
|
|
else if(StringEqual(str, "udatadir")) {
|
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
2005-03-19 18:23:05 +00:00
|
|
|
if (U.pythondir[0] != '\0') {
|
|
|
|
|
char upydir[FILE_MAXDIR];
|
2004-04-24 20:04:37 +00:00
|
|
|
|
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
2005-03-19 18:23:05 +00:00
|
|
|
BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(upydir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if (BLI_exists(upydir)) {
|
|
|
|
|
char udatadir[FILE_MAXDIR];
|
|
|
|
|
|
2005-03-22 04:28:36 +00:00
|
|
|
BLI_make_file_string("/", udatadir, upydir, "bpydata");
|
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
2005-03-19 18:23:05 +00:00
|
|
|
|
|
|
|
|
if (BLI_exists(udatadir))
|
|
|
|
|
ret = PyString_FromString(udatadir);
|
|
|
|
|
}
|
2004-11-02 05:13:52 +00:00
|
|
|
}
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
else if( StringEqual( str, "scriptsdir" ) ) {
|
|
|
|
|
char *sdir = bpy_gethome(1);
|
2004-11-02 05:13:52 +00:00
|
|
|
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
if (sdir)
|
|
|
|
|
ret = PyString_FromString(sdir);
|
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
2005-03-19 18:23:05 +00:00
|
|
|
else
|
|
|
|
|
ret = EXPP_incr_ret( Py_None );
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
}
|
|
|
|
|
else if( StringEqual( str, "uscriptsdir" ) ) {
|
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
2005-03-19 18:23:05 +00:00
|
|
|
if (U.pythondir[0] != '\0') {
|
|
|
|
|
char upydir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(upydir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( upydir ) )
|
|
|
|
|
ret = PyString_FromString( upydir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
/* USER PREFS: */
|
|
|
|
|
else if( StringEqual( str, "yfexportdir" ) ) {
|
|
|
|
|
if (U.yfexportdir[0] != '\0') {
|
|
|
|
|
char yfexportdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(yfexportdir, U.yfexportdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(yfexportdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( yfexportdir ) )
|
|
|
|
|
ret = PyString_FromString( yfexportdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* fontsdir */
|
|
|
|
|
else if( StringEqual( str, "fontsdir" ) ) {
|
|
|
|
|
if (U.fontdir[0] != '\0') {
|
|
|
|
|
char fontdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(fontdir, U.fontdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(fontdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( fontdir ) )
|
|
|
|
|
ret = PyString_FromString( fontdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* texturesdir */
|
|
|
|
|
else if( StringEqual( str, "texturesdir" ) ) {
|
|
|
|
|
if (U.textudir[0] != '\0') {
|
|
|
|
|
char textudir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(textudir, U.textudir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(textudir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( textudir ) )
|
|
|
|
|
ret = PyString_FromString( textudir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* texpluginsdir */
|
|
|
|
|
else if( StringEqual( str, "texpluginsdir" ) ) {
|
|
|
|
|
if (U.plugtexdir[0] != '\0') {
|
|
|
|
|
char plugtexdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(plugtexdir, U.plugtexdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(plugtexdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( plugtexdir ) )
|
|
|
|
|
ret = PyString_FromString( plugtexdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* seqpluginsdir */
|
|
|
|
|
else if( StringEqual( str, "seqpluginsdir" ) ) {
|
|
|
|
|
if (U.plugseqdir[0] != '\0') {
|
|
|
|
|
char plugseqdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(plugseqdir, U.plugseqdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(plugseqdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( plugseqdir ) )
|
|
|
|
|
ret = PyString_FromString( plugseqdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* renderdir */
|
|
|
|
|
else if( StringEqual( str, "renderdir" ) ) {
|
|
|
|
|
if (U.renderdir[0] != '\0') {
|
|
|
|
|
char renderdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(renderdir, U.renderdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(renderdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( renderdir ) )
|
|
|
|
|
ret = PyString_FromString( renderdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* soundsdir */
|
|
|
|
|
else if( StringEqual( str, "soundsdir" ) ) {
|
|
|
|
|
if (U.sounddir[0] != '\0') {
|
|
|
|
|
char sounddir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(sounddir, U.sounddir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(sounddir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( sounddir ) )
|
|
|
|
|
ret = PyString_FromString( sounddir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
/* tempdir */
|
|
|
|
|
else if( StringEqual( str, "tempdir" ) ) {
|
|
|
|
|
if (U.tempdir[0] != '\0') {
|
|
|
|
|
char tempdir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(tempdir, U.tempdir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(tempdir, G.sce, 0);
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( tempdir ) )
|
|
|
|
|
ret = PyString_FromString( tempdir );
|
|
|
|
|
}
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
2006-12-30 07:32:58 +00:00
|
|
|
}
|
|
|
|
|
/* icondir */
|
|
|
|
|
else if( StringEqual( str, "icondir" ) ) {
|
|
|
|
|
|
|
|
|
|
char icondirstr[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons");
|
|
|
|
|
#else
|
|
|
|
|
BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if( BLI_exists( icondirstr ) )
|
|
|
|
|
ret = PyString_FromString( icondirstr );
|
|
|
|
|
|
|
|
|
|
if (!ret) ret = EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
/* According to the old file (opy_blender.c), the following if
|
|
|
|
|
statement is a quick hack and needs some clean up. */
|
|
|
|
|
else if( StringEqual( str, "vrmloptions" ) ) {
|
|
|
|
|
ret = PyDict_New( );
|
|
|
|
|
|
2005-11-30 08:18:06 +00:00
|
|
|
EXPP_dict_set_item_str( ret, "twoside",
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
PyInt_FromLong( U.vrmlflag & USER_VRML_TWOSIDED ) );
|
2004-04-24 20:04:37 +00:00
|
|
|
|
2005-11-30 08:18:06 +00:00
|
|
|
EXPP_dict_set_item_str( ret, "layers",
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
PyInt_FromLong( U.vrmlflag & USER_VRML_LAYERS ) );
|
|
|
|
|
|
2005-11-30 08:18:06 +00:00
|
|
|
EXPP_dict_set_item_str( ret, "autoscale",
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
PyInt_FromLong( U.vrmlflag & USER_VRML_AUTOSCALE ) );
|
|
|
|
|
|
|
|
|
|
} /* End 'quick hack' part. */
|
|
|
|
|
else if(StringEqual( str, "version" ))
|
|
|
|
|
ret = PyInt_FromLong( G.version );
|
|
|
|
|
else
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError, "unknown attribute" );
|
|
|
|
|
|
|
|
|
|
if (ret) return ret;
|
|
|
|
|
else
|
|
|
|
|
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
|
|
|
|
"could not create pystring!");
|
2003-03-08 18:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Function: Blender_Redraw */
|
|
|
|
|
/* Python equivalent: Blender.Redraw */
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Redraw( PyObject * self, PyObject * args )
|
2003-03-08 18:10:20 +00:00
|
|
|
{
|
2007-06-01 05:54:16 +00:00
|
|
|
return M_Window_Redraw( self, args );
|
2003-03-08 18:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
BPython:
- tentative fix for scripts with CR/LF endings and split lines:
in 2.32, the ac3d and vrml2 exporters, for example, had lines
split with '\\\\' and so gave syntax errors when executed on Win
platforms, because the scripts bundled with Win binaries had dos
line endings.
- Chris Keith has written code to execute Python scripts from the
command-line, with '-P ' switch: "blender -P filename":
a Blender.Quit function was also added, so Blender can quit after
running the script (end the script with Blender.Quit()), but there's
still work to be done in this part, including adding more functions,
to load / save .blend files and to run scripts. More testing and
discussions are necessary.
Thanks Chris, for both your contributions and your patience, since I
wasn't available to check / commit this for a while.
2004-03-31 04:18:39 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Function: Blender_Quit */
|
|
|
|
|
/* Python equivalent: Blender.Quit */
|
BPython:
- tentative fix for scripts with CR/LF endings and split lines:
in 2.32, the ac3d and vrml2 exporters, for example, had lines
split with '\\\\' and so gave syntax errors when executed on Win
platforms, because the scripts bundled with Win binaries had dos
line endings.
- Chris Keith has written code to execute Python scripts from the
command-line, with '-P ' switch: "blender -P filename":
a Blender.Quit function was also added, so Blender can quit after
running the script (end the script with Blender.Quit()), but there's
still work to be done in this part, including adding more functions,
to load / save .blend files and to run scripts. More testing and
discussions are necessary.
Thanks Chris, for both your contributions and your patience, since I
wasn't available to check / commit this for a while.
2004-03-31 04:18:39 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Quit( PyObject * self )
|
BPython:
- tentative fix for scripts with CR/LF endings and split lines:
in 2.32, the ac3d and vrml2 exporters, for example, had lines
split with '\\\\' and so gave syntax errors when executed on Win
platforms, because the scripts bundled with Win binaries had dos
line endings.
- Chris Keith has written code to execute Python scripts from the
command-line, with '-P ' switch: "blender -P filename":
a Blender.Quit function was also added, so Blender can quit after
running the script (end the script with Blender.Quit()), but there's
still work to be done in this part, including adding more functions,
to load / save .blend files and to run scripts. More testing and
discussions are necessary.
Thanks Chris, for both your contributions and your patience, since I
wasn't available to check / commit this for a while.
2004-03-31 04:18:39 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
BIF_write_autosave( ); /* save the current data first */
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
exit_usiblender( ); /* renames last autosave to quit.blend */
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
2004-05-18 03:23:45 +00:00
|
|
|
}
|
|
|
|
|
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
/**
|
|
|
|
|
* Blender.Load
|
|
|
|
|
* loads Blender's .blend, DXF, radiogour(?), STL, Videoscape,
|
|
|
|
|
* Inventor 1.0 ASCII, VRML 1.0 asc.
|
|
|
|
|
*/
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Load( PyObject * self, PyObject * args )
|
2004-05-18 03:23:45 +00:00
|
|
|
{
|
|
|
|
|
char *fname = NULL;
|
2004-08-04 06:16:46 +00:00
|
|
|
int keep_oldfname = 0;
|
2004-05-18 03:23:45 +00:00
|
|
|
Script *script = NULL;
|
2004-08-04 06:16:46 +00:00
|
|
|
char str[32], name[FILE_MAXDIR];
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
int file, is_blend_file = 0;
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "|si", &fname, &keep_oldfname ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
"expected filename and optional int or nothing as arguments" );
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( fname ) {
|
|
|
|
|
if( strlen( fname ) > FILE_MAXDIR ) /* G.main->name's max length */
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"filename too long!" );
|
|
|
|
|
else if( !BLI_exists( fname ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"requested file doesn't exist!" );
|
2004-08-04 06:16:46 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( keep_oldfname )
|
|
|
|
|
BLI_strncpy( name, G.sce, FILE_MAXDIR );
|
2004-08-04 06:16:46 +00:00
|
|
|
}
|
2004-05-18 03:23:45 +00:00
|
|
|
|
|
|
|
|
/* We won't let a new .blend file be loaded if there are still other
|
|
|
|
|
* scripts running, since loading a new file will close and remove them. */
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( G.main->script.first != G.main->script.last )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"there are other scripts running at the Scripts win, close them first!" );
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( fname ) {
|
|
|
|
|
file = open( fname, O_BINARY | O_RDONLY );
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( file <= 0 ) {
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"cannot open file!" );
|
|
|
|
|
} else {
|
|
|
|
|
read( file, str, 31 );
|
|
|
|
|
close( file );
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strncmp( str, "BLEN", 4 ) == 0 )
|
|
|
|
|
is_blend_file = 1;
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
} else
|
|
|
|
|
is_blend_file = 1; /* no arg given means default: .B.blend */
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( is_blend_file ) {
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
int during_slink = during_scriptlink( );
|
2004-07-16 03:08:43 +00:00
|
|
|
|
|
|
|
|
/* when loading a .blend file from a scriptlink, the scriptlink pointer
|
|
|
|
|
* in BPY_do_pyscript becomes invalid during a loop. Inform it here.
|
|
|
|
|
* Also do not allow a nested scriptlink (called from inside another)
|
|
|
|
|
* to load .blend files, to avoid nasty problems. */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( during_slink >= 1 ) {
|
|
|
|
|
if( during_slink == 1 )
|
|
|
|
|
disable_where_scriptlink( -1 );
|
2004-07-16 03:08:43 +00:00
|
|
|
else {
|
2004-09-25 20:30:40 +00:00
|
|
|
return EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_EnvironmentError,
|
|
|
|
|
"Blender.Load: cannot load .blend files from a nested scriptlink." );
|
2004-07-16 03:08:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
/* trick: mark the script so that its script struct won't be freed after
|
|
|
|
|
* the script is executed (to avoid a double free warning on exit): */
|
|
|
|
|
script = G.main->script.first;
|
2004-09-25 20:30:40 +00:00
|
|
|
if( script )
|
|
|
|
|
script->flags |= SCRIPT_GUI;
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
BIF_write_autosave( ); /* for safety let's preserve the current data */
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
}
|
2004-05-18 03:23:45 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( G.obedit )
|
2006-09-28 01:55:44 +00:00
|
|
|
exit_editmode(EM_FREEDATA);
|
2004-08-17 04:26:00 +00:00
|
|
|
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
if (G.background) { /* background mode */
|
|
|
|
|
if (is_blend_file)
|
|
|
|
|
BKE_read_file(fname, NULL);
|
|
|
|
|
else {
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_AttributeError,
|
|
|
|
|
"only .blend files can be loaded from command line,\n\
|
|
|
|
|
other file types require interactive mode.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { /* interactive mode */
|
|
|
|
|
/* for safety, any filename with .B.blend is considered the default one.
|
|
|
|
|
* It doesn't seem necessary to compare file attributes (like st_ino and
|
|
|
|
|
* st_dev, according to the glibc info pages) to find out if the given
|
|
|
|
|
* filename, that may have been given with a twisted misgiving path, is the
|
|
|
|
|
* default one for sure. Taking any .B.blend file as the default is good
|
|
|
|
|
* enough here. Note: the default file requires extra clean-up done by
|
|
|
|
|
* BIF_read_homefile: freeing the user theme data. */
|
|
|
|
|
if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
|
2007-03-02 18:15:41 +00:00
|
|
|
BIF_read_homefile(0);
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
else
|
|
|
|
|
BIF_read_file( fname );
|
2003-05-13 01:54:28 +00:00
|
|
|
|
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad.
- Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton.
- #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions.
- #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it.
- #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely.
- #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate.
- #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list.
Thanks all for the help and for being patient (long delay, again).
2005-10-03 19:12:11 +00:00
|
|
|
if( fname && keep_oldfname ) {
|
|
|
|
|
/*BLI_strncpy(G.main->name, name, FILE_MAXDIR); */
|
|
|
|
|
BLI_strncpy( G.sce, name, FILE_MAXDIR );
|
|
|
|
|
}
|
2004-08-04 06:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
2003-05-13 01:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
static PyObject *Blender_Save( PyObject * self, PyObject * args )
|
2004-06-24 09:43:13 +00:00
|
|
|
{
|
|
|
|
|
char *fname = NULL;
|
|
|
|
|
int overwrite = 0, len = 0;
|
|
|
|
|
char *error = NULL;
|
|
|
|
|
Library *li;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "s|i", &fname, &overwrite ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected filename and optional int (overwrite flag) as arguments" );
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
for( li = G.main->library.first; li; li = li->id.next ) {
|
|
|
|
|
if( BLI_streq( li->name, fname ) ) {
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"cannot overwrite used library" );
|
2004-06-24 09:43:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
2004-06-24 09:43:13 +00:00
|
|
|
/* for safety, any filename with .B.blend is considered the default one
|
|
|
|
|
* and not accepted here. */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strstr( fname, ".B.blend" ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"filename can't contain the substring \".B.blend\" in it." );
|
|
|
|
|
|
|
|
|
|
len = strlen( fname );
|
|
|
|
|
|
|
|
|
|
if( len > FILE_MAXFILE )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"filename is too long!" );
|
|
|
|
|
else if( BLI_exists( fname ) && !overwrite )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"file already exists and overwrite flag was not given." );
|
|
|
|
|
|
|
|
|
|
disable_where_script( 1 ); /* to avoid error popups in the write_* functions */
|
|
|
|
|
|
2006-03-24 15:46:26 +00:00
|
|
|
if( BLI_testextensie( fname, ".blend" ) ) {
|
2004-09-25 20:30:40 +00:00
|
|
|
if( G.fileflags & G_AUTOPACK )
|
|
|
|
|
packAll( );
|
|
|
|
|
if( !BLO_write_file( fname, G.fileflags, &error ) ) {
|
|
|
|
|
disable_where_script( 0 );
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_SystemError,
|
|
|
|
|
error );
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
} else if( BLI_testextensie( fname, ".dxf" ) )
|
|
|
|
|
write_dxf( fname );
|
|
|
|
|
else if( BLI_testextensie( fname, ".stl" ) )
|
|
|
|
|
write_stl( fname );
|
|
|
|
|
else if( BLI_testextensie( fname, ".wrl" ) )
|
|
|
|
|
write_vrml( fname );
|
2007-03-13 11:54:53 +00:00
|
|
|
else if( BLI_testextensie( fname, ".obj" ) )
|
|
|
|
|
write_videoscape( fname );
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
else {
|
2004-09-25 20:30:40 +00:00
|
|
|
disable_where_script( 0 );
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"unknown file extension." );
|
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
Thanks to them for the new contributions!
(I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
2004-07-03 05:17:04 +00:00
|
|
|
}
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
disable_where_script( 0 );
|
2004-06-24 09:43:13 +00:00
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
2004-06-24 09:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
PyObject *script = NULL;
|
|
|
|
|
char hspath[FILE_MAXDIR + FILE_MAXFILE]; /* path to help_browser.py */
|
|
|
|
|
char *sdir = bpy_gethome(1);
|
|
|
|
|
PyObject *rkeyd = NULL, *arglist = NULL;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O!", &PyString_Type, &script))
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
|
|
|
|
"expected a script filename as argument");
|
|
|
|
|
|
|
|
|
|
/* first we try to find the help_browser script */
|
|
|
|
|
|
|
|
|
|
if (sdir) BLI_make_file_string("/", hspath, sdir, "help_browser.py");
|
|
|
|
|
|
|
|
|
|
if (!sdir || (!BLI_exists(hspath) && (U.pythondir[0] != '\0'))) {
|
|
|
|
|
char upydir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
|
|
|
|
|
BLI_convertstringcode(upydir, G.sce, 0);
|
|
|
|
|
BLI_make_file_string("/", hspath, upydir, "help_browser.py");
|
|
|
|
|
|
|
|
|
|
if (!BLI_exists(hspath))
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
|
|
|
|
"can't find script help_browser.py");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now we store the passed script in the registry dict and call the
|
|
|
|
|
* help_browser to show help info for it */
|
|
|
|
|
rkeyd = PyDict_New();
|
|
|
|
|
if (!rkeyd)
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_MemoryError,
|
|
|
|
|
"can't create py dictionary!");
|
|
|
|
|
|
2006-06-18 19:05:51 +00:00
|
|
|
/* note: don't use EXPP_dict_set_item_str for 'script', which is an
|
|
|
|
|
* argument to the function we're in and so shouldn't be decref'ed: */
|
|
|
|
|
PyDict_SetItemString(rkeyd, "script", script);
|
|
|
|
|
|
2005-11-30 08:18:06 +00:00
|
|
|
EXPP_dict_set_item_str(bpy_registryDict, "__help_browser", rkeyd);
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
|
|
|
|
|
arglist = Py_BuildValue("(s)", hspath);
|
|
|
|
|
Blender_Run(self, arglist);
|
|
|
|
|
Py_DECREF(arglist);
|
|
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
static PyObject *Blender_Run(PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
char *fname = NULL;
|
|
|
|
|
Text *text = NULL;
|
|
|
|
|
int is_blender_text = 0;
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
Script *script = NULL;
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &fname))
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_TypeError,
|
|
|
|
|
"expected a filename or a Blender Text name as argument");
|
|
|
|
|
|
|
|
|
|
if (!BLI_exists(fname)) { /* if there's no such filename ... */
|
|
|
|
|
text = G.main->text.first; /* try an already existing Blender Text */
|
|
|
|
|
|
|
|
|
|
while (text) {
|
|
|
|
|
if (!strcmp(fname, text->id.name + 2)) break;
|
|
|
|
|
text = text->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_AttributeError,
|
|
|
|
|
"no such file or Blender text");
|
|
|
|
|
}
|
|
|
|
|
else is_blender_text = 1; /* fn is already a Blender Text */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
text = add_text(fname);
|
|
|
|
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
|
|
|
|
|
"couldn't create Blender Text from given file");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9
BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00
|
|
|
/* (this is messy, check Draw.c's Method_Register and Window.c's file
|
|
|
|
|
* selector for more info)
|
|
|
|
|
* - caller script is the one that called this Blender_Run function;
|
|
|
|
|
* - called script is the argument to this function: fname;
|
|
|
|
|
* To mark scripts whose global dicts can't be freed right after
|
|
|
|
|
* the script execution (or better, 'first pass', since these scripts
|
|
|
|
|
* leave callbacks for gui or file/image selectors) we flag them. But to
|
|
|
|
|
* get a pointer to them we need to check which one is currently
|
|
|
|
|
* running (if none we're already at a spacescript). To make sure only
|
|
|
|
|
* the called script will have the SCRIPT_RUNNING flag on, we unset it
|
|
|
|
|
* for the caller script here: */
|
|
|
|
|
script = G.main->script.first;
|
|
|
|
|
while (script) {
|
|
|
|
|
if (script->flags & SCRIPT_RUNNING) break;
|
|
|
|
|
script = script->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (script) script->flags &= ~SCRIPT_RUNNING; /* unset */
|
|
|
|
|
|
|
|
|
|
BPY_txt_do_python_Text(text); /* call new script */
|
|
|
|
|
|
|
|
|
|
if (script) script->flags |= SCRIPT_RUNNING; /* set */
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
|
|
|
|
|
if (!is_blender_text) free_libblock(&G.main->text, text);
|
|
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-13 19:19:05 +00:00
|
|
|
static PyObject * Blender_UpdateMenus( PyObject * self )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BPyMenu_RemoveAllEntries();
|
|
|
|
|
|
|
|
|
|
if (BPyMenu_Init(1) == -1)
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"invalid scripts dir");
|
|
|
|
|
|
2006-09-21 18:25:40 +00:00
|
|
|
Py_RETURN_NONE;
|
2005-01-13 19:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-06 06:17:46 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Function: Blender_PackAll */
|
|
|
|
|
/* Python equivalent: Blender.PackAll */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static PyObject *Blender_PackAll( PyObject * self)
|
|
|
|
|
{
|
|
|
|
|
packAll();
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
2006-02-08 16:58:12 +00:00
|
|
|
|
2006-05-06 06:17:46 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Function: Blender_UnpackAll */
|
|
|
|
|
/* Python equivalent: Blender.UnpackAll */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static PyObject *Blender_UnpackAll( PyObject * self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
int mode;
|
|
|
|
|
PyArg_ParseTuple( args, "i", &mode );
|
|
|
|
|
unpackAll(mode);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Function: Blender_CountPackedFiles */
|
|
|
|
|
/* Python equivalent: Blender.CountPackedFiles */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
static PyObject *Blender_CountPackedFiles( PyObject * self )
|
|
|
|
|
{
|
|
|
|
|
int nfiles = countPackedFiles();
|
|
|
|
|
return PyInt_FromLong( nfiles );
|
|
|
|
|
}
|
|
|
|
|
static PyObject *Blender_UnpackModesDict( void )
|
|
|
|
|
{
|
|
|
|
|
PyObject *UnpackModes = PyConstant_New( );
|
|
|
|
|
if( UnpackModes ) {
|
|
|
|
|
BPy_constant *d = ( BPy_constant * ) UnpackModes;
|
|
|
|
|
PyConstant_Insert( d, "EQUAL", PyInt_FromLong((long)PF_EQUAL) );
|
|
|
|
|
PyConstant_Insert( d, "DIFFERS",PyInt_FromLong((long)PF_DIFFERS) );
|
|
|
|
|
PyConstant_Insert( d, "NOFILE", PyInt_FromLong((long)PF_NOFILE) );
|
|
|
|
|
PyConstant_Insert( d, "WRITE_ORIGINAL", PyInt_FromLong((long)PF_WRITE_ORIGINAL) );
|
|
|
|
|
PyConstant_Insert( d, "WRITE_LOCAL", PyInt_FromLong((long)PF_WRITE_LOCAL) );
|
|
|
|
|
PyConstant_Insert( d, "USE_LOCAL", PyInt_FromLong((long)PF_USE_LOCAL) );
|
|
|
|
|
PyConstant_Insert( d, "USE_ORIGINAL", PyInt_FromLong((long)PF_USE_ORIGINAL) );
|
|
|
|
|
PyConstant_Insert( d, "KEEP", PyInt_FromLong((long)PF_KEEP) );
|
|
|
|
|
PyConstant_Insert( d, "NOOP", PyInt_FromLong((long)PF_NOOP) );
|
|
|
|
|
PyConstant_Insert( d, "ASK", PyInt_FromLong((long)PF_EQUAL) );
|
|
|
|
|
}
|
|
|
|
|
return UnpackModes;
|
|
|
|
|
}
|
2006-02-08 16:58:12 +00:00
|
|
|
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Function: initBlender */
|
2003-03-08 18:10:20 +00:00
|
|
|
/*****************************************************************************/
|
2006-12-16 23:54:45 +00:00
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
void M_Blender_Init(void)
|
2003-03-08 18:10:20 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *module;
|
2007-01-15 07:54:08 +00:00
|
|
|
PyObject *dict, *smode, *SpaceHandlers, *UnpackModes;
|
2006-03-24 15:46:26 +00:00
|
|
|
|
|
|
|
|
/* G.scene should only aver be NULL if blender is executed in
|
|
|
|
|
background mode, not loading a blend file and executing a python script eg.
|
|
|
|
|
blender -P somescript.py -b
|
|
|
|
|
The if below solves the segfaults that happen when python runs and
|
|
|
|
|
G.scene is NULL */
|
2007-02-25 07:36:50 +00:00
|
|
|
if(G.background && G.main->scene.first==NULL) {
|
2006-03-24 15:46:26 +00:00
|
|
|
Scene *sce= add_scene("1");
|
2007-02-25 07:36:50 +00:00
|
|
|
/*set_scene(sce);*/ /* causes a crash */
|
2006-03-24 16:04:55 +00:00
|
|
|
G.scene= sce;
|
2006-03-24 15:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
module = Py_InitModule3("Blender", Blender_methods,
|
|
|
|
|
"The main Blender module");
|
2003-06-28 07:38:21 +00:00
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
types_InitAll(); /* set all our pytypes to &PyType_Type */
|
2003-06-28 07:38:21 +00:00
|
|
|
|
2007-02-25 07:36:50 +00:00
|
|
|
/* constants for packed files*/
|
2006-05-06 06:17:46 +00:00
|
|
|
UnpackModes = Blender_UnpackModesDict( );
|
|
|
|
|
if( UnpackModes )
|
|
|
|
|
PyModule_AddObject( module, "UnpackModes", UnpackModes );
|
|
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
SpaceHandlers = PyConstant_New();
|
BPython:
- Made Blender.event var (previously only used by script links) hold ascii value -- where it applies -- of current event during events callback registered with Draw.Register(gui, events, button_events). Useful for gui scripts like Campbell's Python console. No problem using this var to hold the value, since in gui scripts it was not used (always None).
- Updated Window and Window.Theme with new theme vars and the Time space.
- Script links:
-- Added "Render" event for script links (runs twice, second time as "PostEvent", for clean-up actions). Now FrameChanged links don't run when a single pic is rendered.
-- Added "Enable Script Links" button in the script buttons tab. Now this bit gets saved in .blends along with the rest of G.f, so users can define per .blend if they are on or off by default. "blender -y" also disables all slinks as happened before with OnLoad ones only.
-- Other small changes in the script buttons tab:
When a link is added (button "new"), it becomes the active one for the window, no need to press a button to reach it.
Also, a pupmenu showing all available texts is shown when "new" is pressed, so users can choose a text w/o having to type. Cancel the popup to leave the string button empty (link exists, but has no script assigned). A pulldown would be better UI-wise, but it's kinda weird to show both scripts and normal texts (Blender doesn't differentiate them) in a script links pulldown. With a popup we can show only texts ending in ".py" (not done in this commit, need opinions) and if the script has no or another extension, case of many in old and current .blend's, there's still the string box for writing its name.
-- Implemented Ton's space handler script links:
Right now only for the 3d View, but it's trivial to add for others. There are two types: EVENT, to receive 3d View events from a chosen window and DRAW, to draw on the window. Ton's idea was to give scripts a controlled way to integrate better within Blender.
Here's how it works:
- scripts must have a proper header, like:
# SPACEHANDLER.VIEW3D.EVENT
and then they are shown in 3d View's View menu, "Space Handler Scripts" submenu. Check (mark, click on it) a script to make it active.
EVENT handlers should consult the Blender.event var to get the current event, which can be compared with values from the Draw module:
import Blender
from Blender import Draw
evt = Blender.event
if evt == Draw.AKEY:
print "a"
elif evt == Draw.LEFTMOUSE:
print "left mouse button"
else:
return # ignore, pass event back to Blender
Blender.event = None # tell Blender not to process itself the event
DRAW handlers are free to draw to their owner 3D View. OpenGL attributes and modelview and projection matrices are pushed before running the handler and poped when it finishes.
To communicate between EVENT and DRAW handler scripts we have the Blender.Registry module, as always.
Still need to code some nice example, which should also serve to test properly space handlers. Simple tests went fine.
- doc updates about the additions.
=======
Note: the UI part of the space handlers and script links is of course open for changes, I just tried to make it understandable. Probably we won't use the scriptlinks icon for "None Available" (check 3d View -> View -> Space Handler Scripts), though it hints at what space handlers are. The tooltips may not be accepted either, since other menus don't use them. Opinions welcomed.
2005-05-08 21:20:34 +00:00
|
|
|
if (SpaceHandlers) {
|
|
|
|
|
BPy_constant *d = (BPy_constant *)SpaceHandlers;
|
|
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
PyConstant_Insert(d,"VIEW3D_EVENT",PyInt_FromLong(SPACEHANDLER_VIEW3D_EVENT));
|
|
|
|
|
PyConstant_Insert(d,"VIEW3D_DRAW", PyInt_FromLong(SPACEHANDLER_VIEW3D_DRAW));
|
BPython:
- Made Blender.event var (previously only used by script links) hold ascii value -- where it applies -- of current event during events callback registered with Draw.Register(gui, events, button_events). Useful for gui scripts like Campbell's Python console. No problem using this var to hold the value, since in gui scripts it was not used (always None).
- Updated Window and Window.Theme with new theme vars and the Time space.
- Script links:
-- Added "Render" event for script links (runs twice, second time as "PostEvent", for clean-up actions). Now FrameChanged links don't run when a single pic is rendered.
-- Added "Enable Script Links" button in the script buttons tab. Now this bit gets saved in .blends along with the rest of G.f, so users can define per .blend if they are on or off by default. "blender -y" also disables all slinks as happened before with OnLoad ones only.
-- Other small changes in the script buttons tab:
When a link is added (button "new"), it becomes the active one for the window, no need to press a button to reach it.
Also, a pupmenu showing all available texts is shown when "new" is pressed, so users can choose a text w/o having to type. Cancel the popup to leave the string button empty (link exists, but has no script assigned). A pulldown would be better UI-wise, but it's kinda weird to show both scripts and normal texts (Blender doesn't differentiate them) in a script links pulldown. With a popup we can show only texts ending in ".py" (not done in this commit, need opinions) and if the script has no or another extension, case of many in old and current .blend's, there's still the string box for writing its name.
-- Implemented Ton's space handler script links:
Right now only for the 3d View, but it's trivial to add for others. There are two types: EVENT, to receive 3d View events from a chosen window and DRAW, to draw on the window. Ton's idea was to give scripts a controlled way to integrate better within Blender.
Here's how it works:
- scripts must have a proper header, like:
# SPACEHANDLER.VIEW3D.EVENT
and then they are shown in 3d View's View menu, "Space Handler Scripts" submenu. Check (mark, click on it) a script to make it active.
EVENT handlers should consult the Blender.event var to get the current event, which can be compared with values from the Draw module:
import Blender
from Blender import Draw
evt = Blender.event
if evt == Draw.AKEY:
print "a"
elif evt == Draw.LEFTMOUSE:
print "left mouse button"
else:
return # ignore, pass event back to Blender
Blender.event = None # tell Blender not to process itself the event
DRAW handlers are free to draw to their owner 3D View. OpenGL attributes and modelview and projection matrices are pushed before running the handler and poped when it finishes.
To communicate between EVENT and DRAW handler scripts we have the Blender.Registry module, as always.
Still need to code some nice example, which should also serve to test properly space handlers. Simple tests went fine.
- doc updates about the additions.
=======
Note: the UI part of the space handlers and script links is of course open for changes, I just tried to make it understandable. Probably we won't use the scriptlinks icon for "None Available" (check 3d View -> View -> Space Handler Scripts), though it hints at what space handlers are. The tooltips may not be accepted either, since other menus don't use them. Opinions welcomed.
2005-05-08 21:20:34 +00:00
|
|
|
|
|
|
|
|
PyModule_AddObject(module, "SpaceHandlers", SpaceHandlers);
|
|
|
|
|
}
|
|
|
|
|
|
BPython:
- Scripts:
fixed error in "Save Current Theme" which prevented it from automatically updating script registration in menus.
cosmetic changes in a couple of Campbell's sel_same.py script strings + more descriptive name for its new menu place (3d view, face mode -> select menu).
small updates to help_browser.py script.
The above changes are related to this:
- Added new script menu entries: Render (for exporters to renderers), Themes, FaceSelect (this already at the proper place). Updated Scripts win->Scripts menu so it won't show all available entries, only the ones we mean to see there.
- Updated menu registration so that scripts folders can become trees. The release/scripts/ dir should be updated soon with subdirs like converters/, modifiers/, generators/ or whatever -- better discuss first (or is it? /me afraid of long irc discussions during meetings :) ).
- Modules:
Blender: added 'udatadir' option to .Get() function and added var Blender.mode to tell if Blender is in bg or interactive mode.
NMesh: added Campbell's nmesh.transform(matrix, recalc_normals = False) method (reworked, so my fault if it doesn't work).
- Bugs fixed:
#2123: http://projects.blender.org/tracker/?func=detail&atid=125&aid=2123&group_id=9
Reported by Ken Hughes (thanks!), who also found the exact problem later (it was in Text.Load, not with script links -- if only I had checked emails these days ... lost > 1 hour today to find the problem: passed filename to M_Text_Load was later being written over by a function called by add_text). Also saw that Text.Load wasn't checking existence of passed filename (duh!), now it does.
#1655: http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9
Reported by Chris Want (thanks!): command line "blender -P script" not working properly for bg mode ("blender -b blendfile -P script").
Had to make some small updates to get it working (bg mode for scripts was never explicitely handled, it worked due to collateral effects, let's say), interested readers can check the report after I update it or the API_intro.py doc file. After more testing we can make further updates. Updated many places to not call redraws if in bg mode, now it is officially available. Blender outputs its own info when rendering in bg mode, if that is considered a nuissance we'll have to add a few "if (during_script())" calls outside bpython.
- Removed a few warnings here and there and also updated docs.
2005-03-19 06:24:55 +00:00
|
|
|
if (G.background)
|
|
|
|
|
smode = PyString_FromString("background");
|
|
|
|
|
else
|
|
|
|
|
smode = PyString_FromString("interactive");
|
|
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
dict = PyModule_GetDict(module);
|
2004-04-24 20:04:37 +00:00
|
|
|
g_blenderdict = dict;
|
2004-05-04 14:27:41 +00:00
|
|
|
|
2005-08-17 14:26:00 +00:00
|
|
|
PyModule_AddIntConstant(module, "TRUE", 1);
|
2004-09-25 20:30:40 +00:00
|
|
|
PyModule_AddIntConstant( module, "FALSE", 0 );
|
2005-08-17 14:26:00 +00:00
|
|
|
|
2005-11-30 08:18:06 +00:00
|
|
|
EXPP_dict_set_item_str(dict, "bylink", EXPP_incr_ret_False());
|
|
|
|
|
PyDict_SetItemString(dict, "link", Py_None);
|
|
|
|
|
EXPP_dict_set_item_str(dict, "event", PyString_FromString(""));
|
|
|
|
|
EXPP_dict_set_item_str(dict, "mode", smode);
|
2005-08-17 14:26:00 +00:00
|
|
|
|
|
|
|
|
PyDict_SetItemString(dict, "Armature", Armature_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "BezTriple", BezTriple_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "BGL", BGL_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "CurNurb", CurNurb_Init());
|
2006-05-07 14:57:58 +00:00
|
|
|
PyDict_SetItemString(dict, "Constraint", Constraint_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Curve", Curve_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Camera", Camera_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Draw", Draw_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Effect", Effect_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Ipo", Ipo_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "IpoCurve", IpoCurve_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Image", Image_Init());
|
2005-09-09 01:31:10 +00:00
|
|
|
PyDict_SetItemString(dict, "Key", Key_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Lamp", Lamp_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Lattice", Lattice_Init());
|
2007-03-21 02:23:28 +00:00
|
|
|
PyDict_SetItemString(dict, "Library", oldLibrary_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Material", Material_Init());
|
2005-10-28 13:51:08 +00:00
|
|
|
PyDict_SetItemString(dict, "Mesh", Mesh_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Metaball", Metaball_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Mathutils", Mathutils_Init());
|
2006-07-02 15:28:28 +00:00
|
|
|
PyDict_SetItemString(dict, "Geometry", Geometry_Init());
|
2006-04-23 17:01:04 +00:00
|
|
|
PyDict_SetItemString(dict, "Modifier", Modifier_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "NMesh", NMesh_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Noise", Noise_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Object", Object_Init());
|
2006-03-18 14:47:26 +00:00
|
|
|
PyDict_SetItemString(dict, "Group", Group_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Registry", Registry_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Scene", Scene_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Sound", Sound_Init());
|
2006-08-28 04:44:16 +00:00
|
|
|
PyDict_SetItemString(dict, "SurfNurb", SurfNurb_Init());
|
2005-09-09 01:31:10 +00:00
|
|
|
PyDict_SetItemString(dict, "sys", sys_Init());
|
2005-08-17 14:26:00 +00:00
|
|
|
PyDict_SetItemString(dict, "Types", Types_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Text", Text_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Text3d", Text3d_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Texture", Texture_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "Window", Window_Init());
|
|
|
|
|
PyDict_SetItemString(dict, "World", World_Init());
|
|
|
|
|
|
2003-03-08 18:10:20 +00:00
|
|
|
}
|