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 *****
|
|
|
|
|
*/
|
|
|
|
|
|
2004-05-18 03:23:45 +00:00
|
|
|
#include <Python.h>
|
|
|
|
|
#include <stdio.h>
|
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>
|
2004-09-25 20:30:40 +00:00
|
|
|
#ifndef WIN32
|
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
|
|
|
#include <unistd.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
#include <BDR_editobject.h> /* exit_editmode() */
|
2004-05-18 03:23:45 +00:00
|
|
|
#include <BIF_usiblender.h>
|
|
|
|
|
#include <BLI_blenlib.h>
|
2004-06-24 09:43:13 +00:00
|
|
|
#include <BLO_writefile.h>
|
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
|
|
|
#include <BKE_exotic.h>
|
2004-05-18 03:23:45 +00:00
|
|
|
#include <BKE_global.h>
|
2004-06-24 09:43:13 +00:00
|
|
|
#include <BKE_packedFile.h>
|
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
|
|
|
#include <BKE_object.h>
|
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
|
|
|
#include <BKE_text.h>
|
2004-05-18 03:23:45 +00:00
|
|
|
#include <BPI_script.h>
|
|
|
|
|
#include <BSE_headerbuttons.h>
|
|
|
|
|
#include <DNA_ID.h>
|
|
|
|
|
#include <DNA_object_types.h>
|
|
|
|
|
#include <DNA_scene_types.h>
|
2004-09-25 20:30:40 +00:00
|
|
|
#include <DNA_screen_types.h> /* for SPACE_VIEW3D */
|
|
|
|
|
#include <DNA_space_types.h> /* for SPACE_VIEW3D */
|
2004-05-18 03:23:45 +00:00
|
|
|
#include <DNA_userdef_types.h>
|
|
|
|
|
#include <BKE_ipo.h>
|
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
|
|
|
#include <blendef.h>
|
2004-05-18 03:23:45 +00:00
|
|
|
|
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"
|
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 */
|
2004-05-18 03:23:45 +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
|
|
|
extern PyObject *bpy_registryDict; /* defined in ../BPY_interface.c */
|
|
|
|
|
|
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);
|
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.";
|
|
|
|
|
|
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},
|
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
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char *name;
|
|
|
|
|
PyObject *arg;
|
|
|
|
|
int framenum;
|
|
|
|
|
|
|
|
|
|
if( !PyArg_ParseTuple( args, "sO", &name, &arg ) ) {
|
2004-04-24 20:04:37 +00:00
|
|
|
/* TODO: Do we need to generate a nice error message here? */
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( NULL );
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( StringEqual( name, "curframe" ) ) {
|
|
|
|
|
if( !PyArg_Parse( arg, "i", &framenum ) ) {
|
|
|
|
|
/* TODO: Do we need to generate a nice error message here? */
|
|
|
|
|
return ( NULL );
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G.scene->r.cfra = framenum;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
update_for_newframe( );
|
|
|
|
|
} else {
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"bad request identifier" ) );
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( EXPP_incr_ret( Py_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
|
|
|
{
|
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
|
|
|
PyObject *ret = NULL, *dict = NULL;
|
|
|
|
|
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 ) );
|
|
|
|
|
else if( StringEqual( str, "staframe" ) )
|
|
|
|
|
ret = PyInt_FromLong( G.scene->r.sfra );
|
|
|
|
|
else if( StringEqual( str, "endframe" ) )
|
|
|
|
|
ret = PyInt_FromLong( G.scene->r.efra );
|
|
|
|
|
else if( StringEqual( str, "filename" ) )
|
|
|
|
|
ret = PyString_FromString( G.sce );
|
|
|
|
|
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);
|
|
|
|
|
}
|
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( );
|
|
|
|
|
|
|
|
|
|
PyDict_SetItemString( dict, "twoside",
|
|
|
|
|
PyInt_FromLong( U.vrmlflag & USER_VRML_TWOSIDED ) );
|
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
|
|
|
PyDict_SetItemString( dict, "layers",
|
|
|
|
|
PyInt_FromLong( U.vrmlflag & USER_VRML_LAYERS ) );
|
|
|
|
|
|
|
|
|
|
PyDict_SetItemString( dict, "autoscale",
|
|
|
|
|
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
|
|
|
{
|
2004-04-24 20:04:37 +00:00
|
|
|
int wintype = SPACE_VIEW3D;
|
2003-03-08 18:10:20 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "|i", &wintype ) ) {
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected int argument (or nothing)" );
|
2004-04-24 20:04:37 +00:00
|
|
|
}
|
2003-03-08 18:10:20 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return M_Window_Redraw( self, Py_BuildValue( "(i)", wintype ) );
|
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
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2004-05-18 03:23:45 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
|
|
"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 ) {
|
|
|
|
|
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 )
|
|
|
|
|
exit_editmode( 1 );
|
2004-08-17 04:26:00 +00:00
|
|
|
|
2004-05-18 03:23:45 +00:00
|
|
|
/* 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. */
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
|
|
|
|
|
BIF_read_homefile( );
|
2004-05-18 03:23:45 +00:00
|
|
|
else
|
2004-09-25 20:30:40 +00:00
|
|
|
BIF_read_file( fname );
|
2003-05-13 01:54:28 +00:00
|
|
|
|
2004-09-25 20:30:40 +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
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2004-04-24 20:04:37 +00:00
|
|
|
return Py_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 */
|
|
|
|
|
|
|
|
|
|
if( BLI_testextensie( fname, ".blend" ) ) {
|
|
|
|
|
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 );
|
|
|
|
|
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
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2004-06-24 09:43:13 +00:00
|
|
|
return Py_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
|
|
|
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!");
|
|
|
|
|
|
|
|
|
|
PyDict_SetItemString(rkeyd, "script", script);
|
|
|
|
|
PyDict_SetItemString(bpy_registryDict, "__help_browser", rkeyd);
|
|
|
|
|
|
|
|
|
|
arglist = Py_BuildValue("(s)", hspath);
|
|
|
|
|
Blender_Run(self, arglist);
|
|
|
|
|
Py_DECREF(arglist);
|
|
|
|
|
|
|
|
|
|
return 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
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
return EXPP_incr_ret(Py_None);
|
|
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
Py_INCREF( Py_None );
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/*****************************************************************************/
|
2004-09-25 20:30:40 +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;
|
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
|
|
|
PyObject *dict, *smode;
|
2003-06-28 07:38:21 +00:00
|
|
|
|
2004-04-24 20:04:37 +00:00
|
|
|
g_blenderdict = NULL;
|
2003-06-28 07:38:21 +00:00
|
|
|
|
2005-02-09 15:53:35 +00:00
|
|
|
module = Py_InitModule3( "Blender", Blender_methods,
|
|
|
|
|
"The main Blender module" );
|
2003-06-28 07:38:21 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
types_InitAll( ); /* set all our pytypes to &PyType_Type */
|
2004-04-23 13:11:48 +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 (G.background)
|
|
|
|
|
smode = PyString_FromString("background");
|
|
|
|
|
else
|
|
|
|
|
smode = PyString_FromString("interactive");
|
|
|
|
|
|
2004-09-25 20:30:40 +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-02-09 15:53:35 +00:00
|
|
|
PyDict_SetItemString( dict, "bylink", EXPP_incr_ret_False() );
|
|
|
|
|
PyDict_SetItemString( dict, "link", EXPP_incr_ret ( Py_None ) );
|
2004-09-25 20:30:40 +00:00
|
|
|
PyDict_SetItemString( dict, "event", PyString_FromString( "" ) );
|
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
|
|
|
PyDict_SetItemString( dict, "mode", smode );
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
PyDict_SetItemString( dict, "Types", Types_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "sys", sys_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Registry", Registry_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Scene", Scene_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Object", Object_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Material", Material_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Camera", Camera_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Lamp", Lamp_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Lattice", Lattice_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Curve", Curve_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Armature", Armature_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Ipo", Ipo_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "IpoCurve", IpoCurve_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Metaball", Metaball_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Image", Image_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Window", Window_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Draw", Draw_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "BGL", BGL_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Effect", Effect_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Text", Text_Init( ) );
|
2005-03-06 14:55:00 +00:00
|
|
|
PyDict_SetItemString( dict, "Text3d", Text3d_Init( ) );
|
2004-09-25 20:30:40 +00:00
|
|
|
PyDict_SetItemString( dict, "World", World_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Texture", Texture_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "NMesh", NMesh_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Noise", Noise_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Mathutils", Mathutils_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Library", Library_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "Sound", Sound_Init( ) );
|
|
|
|
|
|
|
|
|
|
PyDict_SetItemString( dict, "CurNurb", CurNurb_Init( ) );
|
|
|
|
|
|
|
|
|
|
PyModule_AddIntConstant( module, "TRUE", 1 );
|
|
|
|
|
PyModule_AddIntConstant( module, "FALSE", 0 );
|
2003-03-08 18:10:20 +00:00
|
|
|
}
|