This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/python/api2_2x/EXPP_interface.c
Willian Padovani Germano d65fc84a68 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

139 lines
3.9 KiB
C

/*
* $Id$
*
* ***** 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,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include <stdio.h>
#include <Python.h>
#include <BKE_global.h>
#include <BKE_library.h>
#include <BKE_main.h>
#include <BLI_blenlib.h>
#include <DNA_space_types.h> /* for FILE_MAXDIR, FILE_MAXFILE */
#include "EXPP_interface.h"
#include "Blender.h"
#include "Registry.h"
#include "gen_utils.h"
extern char bprogname[]; /* argv[0] from creator.c */
void initBlenderApi2_2x( void )
{
g_blenderdict = NULL;
M_Blender_Init( );
}
/* this makes sure BLI_gethome() returns a path with '.blender' appended
* Besides, this function now either returns userhome/.blender (if it exists)
* or blenderInstallDir/.blender/ otherwise (can also be cvs dir).
* If append_scriptsdir is non NULL, "scripts/" is appended to the dir, to
* get the path to the scripts folder ("release/scripts/" if cvs dir).
* Finally, if all else fails BLI_gethome() is returned
* (or NULL if append_scriptdir != 0).
*/
char *bpy_gethome(int append_scriptsdir)
{
static char homedir[FILE_MAXDIR];
static char scriptsdir[FILE_MAXDIR];
char tmpdir[FILE_MAXDIR];
char bprogdir[FILE_MAXDIR];
char *s;
int i;
if (append_scriptsdir) {
if (scriptsdir[0] != '\0')
return scriptsdir;
}
else if (homedir[0] != '\0')
return homedir;
s = BLI_gethome();
if( strstr( s, ".blender" ) )
PyOS_snprintf( homedir, FILE_MAXDIR, s );
else
BLI_make_file_string( "/", homedir, s, ".blender" );
/* if userhome/.blender/ exists, return it */
if( BLI_exists( homedir ) ) {
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, homedir, "scripts");
if (BLI_exists (scriptsdir)) return scriptsdir;
}
else return homedir;
}
else homedir[0] = '\0';
/* if either:
* no homedir was found or
* append_scriptsdir = 1 but there's no scripts/ inside homedir,
* use argv[0] (bprogname) to get .blender/ in
* Blender's installation dir */
s = BLI_last_slash( bprogname );
i = s - bprogname + 1;
PyOS_snprintf( bprogdir, i, "%s", bprogname );
/* using tmpdir to preserve homedir (if) found above:
* the ideal is to have a home dir with scripts dir inside
* it, but if that isn't available, it's possible to
* have a 'broken' home dir somewhere and a scripts dir in the
* cvs sources */
BLI_make_file_string( "/", tmpdir, bprogdir, ".blender" );
if (BLI_exists(tmpdir)) {
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, tmpdir, "scripts");
if (BLI_exists(scriptsdir)) {
PyOS_snprintf(homedir, FILE_MAXDIR, "%s", tmpdir);
return scriptsdir;
}
else {
homedir[0] = '\0';
scriptsdir[0] = '\0';
}
}
else return homedir;
}
/* last try for scripts dir: blender in cvs dir, scripts/ inside release/: */
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts");
if (BLI_exists(scriptsdir)) return scriptsdir;
else scriptsdir[0] = '\0';
}
return NULL;
}