2003-06-28 07:38:21 +00:00
|
|
|
# Blender.Window module and the Window PyType object
|
|
|
|
|
|
|
|
"""
|
|
|
|
The Blender.Window submodule.
|
|
|
|
|
2005-04-21 19:44:52 +00:00
|
|
|
B{New}: renamed ViewLayer to L{ViewLayers} (actually added an alias, so both
|
|
|
|
forms will work).
|
|
|
|
|
2003-06-28 07:38:21 +00:00
|
|
|
Window
|
|
|
|
======
|
|
|
|
|
|
|
|
This module provides access to B{Window} functions in Blender.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
--------
|
|
|
|
|
|
|
|
FileSelector::
|
|
|
|
|
|
|
|
import Blender
|
|
|
|
from Blender import Window
|
|
|
|
#
|
|
|
|
def my_callback(filename): # callback for the FileSelector
|
|
|
|
print "You chose the file:", filename # do something with the chosen file
|
|
|
|
#
|
|
|
|
Window.FileSelector (my_callback, "Choose one!")
|
|
|
|
|
|
|
|
Example:
|
|
|
|
--------
|
|
|
|
|
|
|
|
DrawProgressBar::
|
|
|
|
|
|
|
|
import Blender
|
|
|
|
from Blender.Window import DrawProgressBar
|
|
|
|
#
|
|
|
|
# substitute the bogus_*() function calls for your own, of course.
|
|
|
|
#
|
|
|
|
DrawProgressBar (0.0, "Importing data ...")
|
|
|
|
bogus_importData()
|
|
|
|
DrawProgressBar (0.3, "Building something")
|
|
|
|
bogus_build()
|
|
|
|
DrawProgressBar (0.8, "Updating Blender")
|
|
|
|
bogus_update()
|
|
|
|
DrawProgressBar (1.0, "Finished")
|
|
|
|
#
|
|
|
|
# another example:
|
|
|
|
#
|
|
|
|
number = 1
|
|
|
|
while number < 20:
|
|
|
|
file = filename + "00%d" % number
|
|
|
|
DrawProgressBar (number / 20.0, "Loading texture: %s" % file)
|
|
|
|
Blender.Image.Load(file)
|
|
|
|
number += 1
|
|
|
|
|
|
|
|
DrawProgressBar (1.0, "Finished loading")
|
|
|
|
|
2003-07-22 00:27:03 +00:00
|
|
|
|
|
|
|
@type Types: readonly dictionary
|
|
|
|
@var Types: The available Window Types.
|
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
|
|
|
- ACTION
|
2003-07-22 00:27:03 +00:00
|
|
|
- BUTS
|
|
|
|
- FILE
|
|
|
|
- IMAGE
|
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
|
|
|
- IMASEL
|
2003-07-22 00:27:03 +00:00
|
|
|
- INFO
|
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
|
|
|
- IPO
|
|
|
|
- NLA
|
|
|
|
- OOPS
|
|
|
|
- SCRIPT
|
2003-07-22 00:27:03 +00:00
|
|
|
- SEQ
|
|
|
|
- SOUND
|
|
|
|
- TEXT
|
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
|
|
|
- VIEW3D
|
2004-07-16 03:08:43 +00:00
|
|
|
|
|
|
|
@type Qual: readonly dictionary
|
|
|
|
@var Qual: Qualifier keys (shift, control, alt) bitmasks.
|
|
|
|
- LALT: left ALT key
|
|
|
|
- RALT: right ALT key
|
|
|
|
- ALT: any ALT key, ...
|
|
|
|
- LCTRL
|
|
|
|
- RCTRL
|
|
|
|
- CTRL
|
|
|
|
- LSHIFT
|
|
|
|
- RSHIFT
|
|
|
|
- SHIFT
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
|
|
|
|
@type MButs: readonly dictionary
|
|
|
|
@var MButs: Mouse buttons.
|
|
|
|
- L: left mouse button
|
|
|
|
- M: middle mouse button
|
|
|
|
- R: right mouse button
|
2004-11-02 05:13:52 +00:00
|
|
|
|
|
|
|
@warn: The event system in Blender needs a rewrite, though we don't know when that will happen. Until then, event related functions here (L{QAdd}, L{QRead},
|
|
|
|
L{QHandle}, etc.) can be used, but they are actually experimental and can be
|
|
|
|
substituted for a better method when the rewrite happens. In other words, use
|
|
|
|
them at your own risk, because though they should work well and allow many
|
|
|
|
interesting and powerful possibilities, they can be deprecated in some future
|
|
|
|
version of Blender / Blender Python.
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
def Redraw (spacetype = '<Types.VIEW3D>'):
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
Force a redraw of a specific space type.
|
|
|
|
@type spacetype: int
|
|
|
|
@param spacetype: the space type, see L{Types}. By default the 3d Views are
|
|
|
|
redrawn. If spacetype < 0, all currently visible spaces are redrawn.
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def RedrawAll ():
|
|
|
|
"""
|
|
|
|
Redraw all windows.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def QRedrawAll ():
|
|
|
|
"""
|
|
|
|
Redraw all windows by queue event.
|
|
|
|
"""
|
|
|
|
|
BPython: cleaning some bug tracker entries:
(excuse me for doing all in a single commit, but they are tiny
fixes and it's bpython, that dark corner ...)
#1025 - FileSelector SEGV on dynamic callback Category:
Can't reproduce with current cvs, I'd say recent changes to fix
another crash related to FileSelector in gui-less scripts solved this
one, too.
#1028 - Reserved button event number:
Menu choices generate two events, one extra related to the menu
itself, with value=4. Made bpython ignore this extra event.
#1068 - FileSelector No file extension support:
As Ton wrote there, Blender itself doesn't support this yet. But the
requester also wanted Window.File/ImageSelector to accept a pathname. Done. Also updated doc.
#959 - Segfault on background rendering:
This happened in bg mode (blender -b filename -a, for example) when
a script with the line "Blender.Redraw()" was linked to FRAMECHANGED events. As reported in the bug page, it was because curarea is NULL in bg mode. Made Redraw() check for this and not call functions that expected curarea in Redraw, like one to swap buffers.
#1072 - Blender.Redraw() Segfault:
Good catch : ). Scripts called from the scripts win that called
Blender.Redraw() or Blender.Window.Redraw() would crash Blender because of a dirty pointer in Spacescript->script. Fixed.
2004-04-11 04:41:33 +00:00
|
|
|
def FileSelector (callback, title = 'SELECT FILE', filename = '<default>'):
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
Open the file selector window in Blender. After the user selects a filename,
|
|
|
|
it is passed as parameter to the function callback given to FileSelector().
|
|
|
|
Example::
|
|
|
|
import Blender
|
|
|
|
#
|
|
|
|
def my_function(filename):
|
|
|
|
print 'The selected file was:', filename
|
|
|
|
#
|
|
|
|
Blender.Window.FileSelector (my_function, 'SAVE FILE')
|
|
|
|
@type callback: function that accepts a string: f(str)
|
|
|
|
@param callback: The function that must be provided to FileSelector() and
|
|
|
|
will receive the selected filename as parameter.
|
|
|
|
@type title: string
|
|
|
|
@param title: The string that appears in the button to confirm the selection
|
|
|
|
and return from the file selection window.
|
BPython: cleaning some bug tracker entries:
(excuse me for doing all in a single commit, but they are tiny
fixes and it's bpython, that dark corner ...)
#1025 - FileSelector SEGV on dynamic callback Category:
Can't reproduce with current cvs, I'd say recent changes to fix
another crash related to FileSelector in gui-less scripts solved this
one, too.
#1028 - Reserved button event number:
Menu choices generate two events, one extra related to the menu
itself, with value=4. Made bpython ignore this extra event.
#1068 - FileSelector No file extension support:
As Ton wrote there, Blender itself doesn't support this yet. But the
requester also wanted Window.File/ImageSelector to accept a pathname. Done. Also updated doc.
#959 - Segfault on background rendering:
This happened in bg mode (blender -b filename -a, for example) when
a script with the line "Blender.Redraw()" was linked to FRAMECHANGED events. As reported in the bug page, it was because curarea is NULL in bg mode. Made Redraw() check for this and not call functions that expected curarea in Redraw, like one to swap buffers.
#1072 - Blender.Redraw() Segfault:
Good catch : ). Scripts called from the scripts win that called
Blender.Redraw() or Blender.Window.Redraw() would crash Blender because of a dirty pointer in Spacescript->script. Fixed.
2004-04-11 04:41:33 +00:00
|
|
|
@type filename: string
|
|
|
|
@param filename: A filename. This defaults to Blender.Get('filename').
|
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
|
|
|
@warn: script links are not allowed to call the File / Image Selectors. This
|
|
|
|
is because script links global dictionaries are removed when they finish
|
|
|
|
execution and the File Selector needs the passed callback to stay around.
|
|
|
|
An alternative is calling the File Selector from another script (see
|
|
|
|
L{Blender.Run}).
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
|
BPython: cleaning some bug tracker entries:
(excuse me for doing all in a single commit, but they are tiny
fixes and it's bpython, that dark corner ...)
#1025 - FileSelector SEGV on dynamic callback Category:
Can't reproduce with current cvs, I'd say recent changes to fix
another crash related to FileSelector in gui-less scripts solved this
one, too.
#1028 - Reserved button event number:
Menu choices generate two events, one extra related to the menu
itself, with value=4. Made bpython ignore this extra event.
#1068 - FileSelector No file extension support:
As Ton wrote there, Blender itself doesn't support this yet. But the
requester also wanted Window.File/ImageSelector to accept a pathname. Done. Also updated doc.
#959 - Segfault on background rendering:
This happened in bg mode (blender -b filename -a, for example) when
a script with the line "Blender.Redraw()" was linked to FRAMECHANGED events. As reported in the bug page, it was because curarea is NULL in bg mode. Made Redraw() check for this and not call functions that expected curarea in Redraw, like one to swap buffers.
#1072 - Blender.Redraw() Segfault:
Good catch : ). Scripts called from the scripts win that called
Blender.Redraw() or Blender.Window.Redraw() would crash Blender because of a dirty pointer in Spacescript->script. Fixed.
2004-04-11 04:41:33 +00:00
|
|
|
def ImageSelector (callback, title = 'SELECT IMAGE', filename = '<default>'):
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
Open the image selector window in Blender. After the user selects a filename,
|
|
|
|
it is passed as parameter to the function callback given to ImageSelector().
|
|
|
|
Example::
|
|
|
|
import Blender
|
|
|
|
#
|
|
|
|
def my_function(imagename):
|
|
|
|
print 'The selected image was:', imagename
|
|
|
|
#
|
|
|
|
Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
|
|
|
|
@type callback: function that accepts a string: f(str)
|
|
|
|
@param callback: The function that must be provided to ImageSelector() and
|
|
|
|
will receive the selected filename as parameter.
|
|
|
|
@type title: string
|
|
|
|
@param title: The string that appears in the button to confirm the selection
|
|
|
|
and return from the image selection window.
|
BPython: cleaning some bug tracker entries:
(excuse me for doing all in a single commit, but they are tiny
fixes and it's bpython, that dark corner ...)
#1025 - FileSelector SEGV on dynamic callback Category:
Can't reproduce with current cvs, I'd say recent changes to fix
another crash related to FileSelector in gui-less scripts solved this
one, too.
#1028 - Reserved button event number:
Menu choices generate two events, one extra related to the menu
itself, with value=4. Made bpython ignore this extra event.
#1068 - FileSelector No file extension support:
As Ton wrote there, Blender itself doesn't support this yet. But the
requester also wanted Window.File/ImageSelector to accept a pathname. Done. Also updated doc.
#959 - Segfault on background rendering:
This happened in bg mode (blender -b filename -a, for example) when
a script with the line "Blender.Redraw()" was linked to FRAMECHANGED events. As reported in the bug page, it was because curarea is NULL in bg mode. Made Redraw() check for this and not call functions that expected curarea in Redraw, like one to swap buffers.
#1072 - Blender.Redraw() Segfault:
Good catch : ). Scripts called from the scripts win that called
Blender.Redraw() or Blender.Window.Redraw() would crash Blender because of a dirty pointer in Spacescript->script. Fixed.
2004-04-11 04:41:33 +00:00
|
|
|
@type filename: string
|
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
|
|
|
@param filename: A filename. This defaults to L{Blender.Get}('filename').
|
|
|
|
@warn: script links are not allowed to call the File / Image Selectors. This
|
|
|
|
is because script links global dictionaries are removed when they finish
|
|
|
|
execution and the File Selector needs the passed callback to stay around.
|
|
|
|
An alternative is calling the File Selector from another script (see
|
|
|
|
L{Blender.Run}).
|
2003-06-28 07:38:21 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def DrawProgressBar (done, text):
|
|
|
|
"""
|
|
|
|
Draw a progress bar in the upper right corner of the screen. To cancel it
|
2003-07-12 18:02:54 +00:00
|
|
|
prematurely, users can press the "Esc" key. Start it with done = 0 and end
|
|
|
|
it with done = 1.
|
2003-06-28 07:38:21 +00:00
|
|
|
@type done: float
|
2003-07-12 18:02:54 +00:00
|
|
|
@param done: A float in [0.0, 1.0] that tells the advance in the progress
|
2003-06-28 07:38:21 +00:00
|
|
|
bar.
|
|
|
|
@type text: string
|
|
|
|
@param text: Info about what is currently being done "behind the scenes".
|
|
|
|
"""
|
2003-09-03 04:04:17 +00:00
|
|
|
|
|
|
|
def GetCursorPos ():
|
2007-03-30 08:20:37 +00:00
|
|
|
"""
|
|
|
|
Get the current 3d cursor position.
|
|
|
|
@rtype: list of three floats
|
|
|
|
@return: the current position: [x, y, z].
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetActiveLayer ():
|
|
|
|
"""
|
|
|
|
Get the bitmask for the active layer.
|
|
|
|
@note: if there is no 3d view it will return zero.
|
|
|
|
@rtype: int
|
|
|
|
@return: layer bitmask
|
|
|
|
"""
|
|
|
|
|
|
|
|
def SetActiveLayer(layermask):
|
|
|
|
"""
|
|
|
|
Set the bitmask for the active layer.
|
|
|
|
@type layermask: int
|
|
|
|
@param layermask: An integer bitmask, to use humanly readable values do (1<<0) for the first layer, (1<<19) for the last layer.
|
|
|
|
"""
|
2004-07-16 03:08:43 +00:00
|
|
|
|
2003-09-18 00:54:43 +00:00
|
|
|
def SetCursorPos (coords):
|
2007-03-30 08:20:37 +00:00
|
|
|
"""
|
|
|
|
Change the 3d cursor position.
|
|
|
|
@type coords: 3 floats or a list of 3 floats
|
|
|
|
@param coords: The new x, y, z coordinates.
|
|
|
|
@note: if visible, the 3d View must be redrawn to display the change. This
|
|
|
|
can be done with L{Redraw}.
|
|
|
|
"""
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
|
2007-11-22 10:10:57 +00:00
|
|
|
def GetPivot ():
|
|
|
|
"""
|
|
|
|
Get the pivot for the active 3D view.
|
|
|
|
@rtype: int
|
|
|
|
@return: constant - Window.PivotTypes
|
|
|
|
"""
|
|
|
|
|
|
|
|
def SetPivot (pivot):
|
|
|
|
"""
|
|
|
|
Set the pivot on the active 3D view.
|
|
|
|
@type pivot: int
|
|
|
|
@param pivot: constant - Window.PivotTypes
|
|
|
|
"""
|
|
|
|
|
2010-06-08 00:02:42 +00:00
|
|
|
def GetBgImage():
|
|
|
|
"""
|
2010-06-08 11:09:20 +00:00
|
|
|
Get Background Image from current 3D-View (or None).
|
2010-06-08 00:02:42 +00:00
|
|
|
@return: Blender Image or None
|
|
|
|
"""
|
|
|
|
|
|
|
|
def SetBgImage(image):
|
|
|
|
"""
|
2010-06-08 11:09:20 +00:00
|
|
|
Set the Image as Background Image in current 3D-View and turn it on.
|
|
|
|
@param image: the new Image.
|
2010-06-08 00:02:42 +00:00
|
|
|
@type image: Blender Image or None.
|
2010-06-08 11:09:20 +00:00
|
|
|
@None removes current Background Image.
|
2010-06-08 00:02:42 +00:00
|
|
|
"""
|
|
|
|
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
def WaitCursor (bool):
|
|
|
|
"""
|
|
|
|
Set cursor to wait or back to normal mode.
|
|
|
|
|
|
|
|
Example::
|
|
|
|
Blender.Window.WaitCursor(1)
|
|
|
|
Blender.sys.sleep(2000) # do something that takes some time
|
|
|
|
Blender.Window.WaitCursor(0) # back
|
|
|
|
|
|
|
|
@type bool: int (bool)
|
|
|
|
@param bool: if nonzero the cursor is set to wait mode, otherwise to normal
|
|
|
|
mode.
|
|
|
|
@note: when the script finishes execution, the cursor is set to normal by
|
|
|
|
Blender itself.
|
2003-09-18 00:54:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def GetViewVector ():
|
|
|
|
"""
|
|
|
|
Get the current 3d view vector.
|
|
|
|
@rtype: list of three floats
|
|
|
|
@return: the current vector: [x, y, z].
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetViewMatrix ():
|
|
|
|
"""
|
|
|
|
Get the current 3d view matrix.
|
2005-11-15 21:14:24 +00:00
|
|
|
@rtype: 4x4 float matrix (WRAPPED DATA)
|
2003-09-18 00:54:43 +00:00
|
|
|
@return: the current matrix.
|
|
|
|
"""
|
2004-07-16 03:08:43 +00:00
|
|
|
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
def GetPerspMatrix ():
|
|
|
|
"""
|
|
|
|
Get the current 3d perspective matrix.
|
2005-11-15 21:14:24 +00:00
|
|
|
@rtype: 4x4 float matrix (WRAPPED DATA)
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
@return: the current matrix.
|
|
|
|
"""
|
|
|
|
|
2006-01-16 02:06:02 +00:00
|
|
|
def EditMode(enable = -1, undo_msg = 'From script', undo = 1):
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
Get and optionally set the current edit mode status: in or out.
|
|
|
|
|
|
|
|
Example::
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
in_editmode = Window.EditMode()
|
|
|
|
# MUST leave edit mode before changing an active mesh:
|
|
|
|
if in_editmode: Window.EditMode(0)
|
2004-07-16 03:08:43 +00:00
|
|
|
# ...
|
|
|
|
# make changes to the mesh
|
|
|
|
# ...
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
# be nice to the user and return things to how they were:
|
|
|
|
if in_editmode: Window.EditMode(1)
|
2004-07-16 03:08:43 +00:00
|
|
|
@type enable: int
|
|
|
|
@param enable: get/set current status:
|
|
|
|
- -1: just return current status (default);
|
|
|
|
- 0: leave edit mode;
|
|
|
|
- 1: enter edit mode.
|
|
|
|
|
|
|
|
It's not an error to try to change to a state that is already the
|
2004-08-17 04:26:00 +00:00
|
|
|
current one, the function simply ignores the request.
|
|
|
|
@type undo_msg: string
|
|
|
|
@param undo_msg: only needed when exiting edit mode (EditMode(0)). This
|
|
|
|
string is used as the undo message in the Mesh->Undo History submenu in
|
|
|
|
the 3d view header. Max length is 63, strings longer than that get
|
|
|
|
clamped.
|
2006-01-16 02:06:02 +00:00
|
|
|
@param undo: don't save Undo information (only needed when exiting edit
|
|
|
|
mode).
|
|
|
|
@type undo: int
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: int (bool)
|
|
|
|
@return: 0 if Blender is not in edit mode right now, 1 otherwise.
|
|
|
|
@warn: this is an important function. NMesh operates on normal Blender
|
|
|
|
meshes, not edit mode ones. If a script changes an active mesh while in
|
|
|
|
edit mode, when the user leaves the mode the changes will be lost,
|
|
|
|
because the normal mesh will be rebuilt based on its unchanged edit mesh.
|
|
|
|
"""
|
|
|
|
|
2007-10-26 08:19:40 +00:00
|
|
|
def PoseMode(enable = -1):
|
|
|
|
"""
|
|
|
|
Get and optionally set the current pose mode status: in or out.
|
|
|
|
@type enable: int
|
|
|
|
@param enable: get/set current status:
|
|
|
|
- -1: just return current status (default);
|
|
|
|
- 0: leave edit mode;
|
|
|
|
- 1: enter edit mode.
|
|
|
|
|
|
|
|
@return: 0 if Blender is not in edit mode right now, 1 otherwise.
|
|
|
|
@warn: This uses the active armature objects posemode status, enabling pose
|
|
|
|
mode for non armature objects will always fail.
|
|
|
|
"""
|
|
|
|
|
2007-06-08 15:41:31 +00:00
|
|
|
def ViewLayers (layers = [], winid = None):
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
Get and optionally set the currently visible layers in all 3d Views.
|
|
|
|
@type layers: list of ints
|
|
|
|
@param layers: a list with indexes of the layers that will be visible. Each
|
|
|
|
index must be in the range [1, 20]. If not given or equal to [], the
|
|
|
|
function simply returns the visible ones without changing anything.
|
2007-06-08 15:41:31 +00:00
|
|
|
@type winid: window id from as redurned by GetScreenInfo
|
|
|
|
@param winid: An optional argument to set the layer of a window
|
|
|
|
rather then setting the scene layers. For this to display in the 3d view
|
|
|
|
the layer lock must be disabled (unlocked).
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: list of ints
|
|
|
|
@return: the currently visible layers.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetViewQuat ():
|
|
|
|
"""
|
|
|
|
Get the current VIEW3D view quaternion values.
|
|
|
|
@rtype: list of floats
|
|
|
|
@return: the quaternion as a list of four float values.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def SetViewQuat (quat):
|
|
|
|
"""
|
|
|
|
Set the current VIEW3D view quaternion.
|
|
|
|
@type quat: floats or list of floats
|
|
|
|
@param quat: four floats or a list of four floats.
|
|
|
|
"""
|
|
|
|
|
2005-03-01 02:37:19 +00:00
|
|
|
def GetViewOffset ():
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
Get the current VIEW3D offset values.
|
|
|
|
@rtype: list of floats
|
|
|
|
@return: a list with three floats: [x,y,z].
|
2006-06-23 23:58:50 +00:00
|
|
|
@note: The 3 values returned are flipped in comparison object locations.
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
|
2005-03-01 02:37:19 +00:00
|
|
|
def SetViewOffset (ofs):
|
|
|
|
"""
|
2006-06-23 23:58:50 +00:00
|
|
|
Set the current VIEW3D offset values.
|
2005-03-01 02:37:19 +00:00
|
|
|
@type ofs: 3 floats or list of 3 floats
|
|
|
|
@param ofs: the new view offset values.
|
2006-06-23 23:58:50 +00:00
|
|
|
@note: The value you give flipped in comparison object locations.
|
2005-03-01 02:37:19 +00:00
|
|
|
"""
|
|
|
|
|
2004-07-16 03:08:43 +00:00
|
|
|
def CameraView (camtov3d = 0):
|
|
|
|
"""
|
|
|
|
Set the current VIEW3D view to the active camera's view. If there's no
|
|
|
|
active object or it is not of type 'Camera', the active camera for the
|
|
|
|
current scene is used instead.
|
|
|
|
@type camtov3d: int (bool)
|
|
|
|
@param camtov3d: if nonzero it's the camera that gets positioned at the
|
|
|
|
current view, instead of the view being changed to that of the camera.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def QTest ():
|
|
|
|
"""
|
|
|
|
Check if there are pending events in the event queue.
|
2005-11-28 22:49:59 +00:00
|
|
|
@rtype: int
|
|
|
|
@return: 0 if there are no pending events, non-zero otherwise.
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def QRead ():
|
|
|
|
"""
|
|
|
|
Get the next pending event from the event queue.
|
|
|
|
|
|
|
|
Example::
|
|
|
|
# let's catch all events and move the 3D Cursor when user presses
|
|
|
|
# the left mouse button.
|
|
|
|
from Blender import Draw, Window
|
2004-11-02 05:13:52 +00:00
|
|
|
|
2005-03-17 14:41:36 +00:00
|
|
|
v3d = Window.GetScreenInfo(Window.Types.VIEW3D)
|
2004-11-02 05:13:52 +00:00
|
|
|
id = v3d[0]['id'] # get the (first) VIEW3D's id
|
|
|
|
|
2004-07-16 03:08:43 +00:00
|
|
|
done = 0
|
2004-11-02 05:13:52 +00:00
|
|
|
|
2004-07-16 03:08:43 +00:00
|
|
|
while not done: # enter a 'get event' loop
|
|
|
|
evt, val = Window.QRead() # catch next event
|
2004-11-02 05:13:52 +00:00
|
|
|
if evt in [Draw.MOUSEX, Draw.MOUSEY]:
|
|
|
|
continue # speeds things up, ignores mouse movement
|
|
|
|
elif evt in [Draw.ESCKEY, Draw.QKEY]: done = 1 # end loop
|
2004-07-16 03:08:43 +00:00
|
|
|
elif evt == Draw.SPACEKEY:
|
|
|
|
Draw.PupMenu("Hey!|What did you expect?")
|
|
|
|
elif evt == Draw.Redraw: # catch redraw events to handle them
|
|
|
|
Window.RedrawAll() # redraw all areas
|
2004-11-02 05:13:52 +00:00
|
|
|
elif evt == Draw.LEFTMOUSE: # left button pressed
|
|
|
|
Window.QAdd(id, evt, 1) # add the caught mouse event to our v3d
|
2004-07-16 03:08:43 +00:00
|
|
|
# actually we should check if the event happened inside that area,
|
|
|
|
# using Window.GetMouseCoords() and v3d[0]['vertices'] values.
|
|
|
|
Window.QHandle(id) # process the event
|
|
|
|
# do something fancy like putting some object where the
|
|
|
|
# user positioned the 3d cursor, then:
|
|
|
|
Window.Redraw() # show the change in the VIEW3D areas.
|
|
|
|
|
|
|
|
@rtype: list
|
|
|
|
@return: [event, val], where:
|
|
|
|
- event: int - the key or mouse event (see L{Draw});
|
|
|
|
- val: int - 1 for a key press, 0 for a release, new x or y coordinates
|
2004-11-02 05:13:52 +00:00
|
|
|
for mouse movement events.
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def QAdd (win, event, val, after = 0):
|
|
|
|
"""
|
|
|
|
Add an event to some window's (actually called areas in Blender) event queue.
|
|
|
|
@type win: int
|
|
|
|
@param win: the window id, see L{GetScreenInfo}.
|
|
|
|
@type event: positive int
|
|
|
|
@param event: the event to add, see events in L{Draw}.
|
|
|
|
@type val: int
|
|
|
|
@param val: 1 for a key press, 0 for a release.
|
|
|
|
@type after: int (bool)
|
|
|
|
@param after: if nonzero the event is put after the current queue and added
|
|
|
|
later.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def QHandle (winId):
|
|
|
|
"""
|
|
|
|
Process immediately all pending events for the given window (area).
|
|
|
|
@type winId: int
|
|
|
|
@param winId: the window id, see L{GetScreenInfo}.
|
|
|
|
@note: see L{QAdd} for how to send events to a particular window.
|
|
|
|
"""
|
2008-03-06 22:45:11 +00:00
|
|
|
def TestBreak ():
|
|
|
|
"""
|
|
|
|
Return true if the user has pressed escape
|
|
|
|
@rtype: bool
|
|
|
|
@return: a boolean from a test if the user pressed escape
|
|
|
|
"""
|
2004-07-16 03:08:43 +00:00
|
|
|
|
|
|
|
def GetMouseCoords ():
|
|
|
|
"""
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
Get mouse's current screen coordinates.
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: list with two ints
|
|
|
|
@return: a [x, y] list with the coordinates.
|
|
|
|
"""
|
|
|
|
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
def SetMouseCoords (coords):
|
|
|
|
"""
|
|
|
|
Set mouse's current screen coordinates.
|
|
|
|
@type coords: (list of) two ints
|
|
|
|
@param coords: can be passed as x, y or [x, y] and are clamped to stay inside
|
|
|
|
the screen. If not given they default to the coordinates of the middle
|
|
|
|
of the screen.
|
|
|
|
"""
|
|
|
|
|
2004-07-16 03:08:43 +00:00
|
|
|
def GetMouseButtons ():
|
|
|
|
"""
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
Get the current mouse button state (see / compare against L{MButs}).
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: int
|
2005-10-11 15:11:39 +00:00
|
|
|
@return: an OR'ed flag with the currently pressed buttons.
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def GetKeyQualifiers ():
|
|
|
|
"""
|
|
|
|
Get the current qualifier keys state (see / compare against L{Qual}).
|
|
|
|
@rtype: int
|
2005-10-11 15:11:39 +00:00
|
|
|
@return: an OR'ed combination of values in L{Qual}.
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def SetKeyQualifiers (qual):
|
|
|
|
"""
|
|
|
|
Fake qualifier keys state. This is useful because some key events require
|
|
|
|
one or more qualifiers to be active (see L{QAdd}).
|
|
|
|
@type qual: int
|
2005-10-11 15:11:39 +00:00
|
|
|
@param qual: an OR'ed combination of values in L{Qual}.
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: int
|
|
|
|
@return: the current state, that should be equal to 'qual'.
|
|
|
|
@warn: remember to reset the qual keys to 0 once they are not necessary
|
|
|
|
anymore.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetAreaID ():
|
|
|
|
"""
|
|
|
|
Get the current area's ID.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetAreaSize ():
|
|
|
|
"""
|
|
|
|
Get the current area's size.
|
|
|
|
@rtype: list with two ints
|
|
|
|
@return: a [width, height] list.
|
|
|
|
@note: the returned values are 1 pixel bigger than what L{GetScreenInfo}
|
|
|
|
returns for the 'vertices' of the same area.
|
|
|
|
"""
|
|
|
|
|
BPython:
- new submodule Scene.Radio, for radiosity: still incomplete, but in shape for demos, updated SConscript to include it;
- new functions in Window module;
- doc updates: adding a todo file and a new start page for our docs: API_intro.py + other updates;
- small fix in Ipo.c provided by Damien McGuinnes (thanks!): Nathan has a patch with IPO additions and fixes for this and more, but until it is committed, there's this fix for Ipo.getCurve('LocX'), LocY, Z and QuatW,X,Y,Z too, according to Damien.
Other files:
- radpreprocess.c: added check for "during_script()" so eventual msgs don't popup during scripts;
- drawmesh.c: made a pointer (display list) be checked before accessed, fixes crash in scripts that forget to update display lists for subsurf meshes when a 3d view is in textured view mode.
Script: updated bevel_center by Loic Berthe.
2004-07-25 16:55:45 +00:00
|
|
|
def GetScreenSize ():
|
|
|
|
"""
|
|
|
|
Get Blender's screen size.
|
|
|
|
@rtype: list with two ints
|
|
|
|
@return: a [width, height] list.
|
|
|
|
"""
|
|
|
|
|
2004-07-20 08:16:46 +00:00
|
|
|
def GetScreens ():
|
|
|
|
"""
|
|
|
|
Get the names of all available screens.
|
|
|
|
@rtype: list of strings
|
|
|
|
@return: a list of names that can be passed to L{SetScreen}.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def SetScreen (name):
|
|
|
|
"""
|
|
|
|
Set as current screen the one with the given name.
|
|
|
|
@type name: string
|
|
|
|
@param name: the name of an existing screen. Use L{GetScreens} to get
|
|
|
|
a list with all screen names.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def GetScreenInfo (type = -1, rect = 'win', screen = ''):
|
2004-07-16 03:08:43 +00:00
|
|
|
"""
|
|
|
|
Get info about the current screen setup.
|
|
|
|
@type type: int
|
2005-10-11 15:11:39 +00:00
|
|
|
@param type: the space type (see L{Types}) to restrict the
|
2004-07-16 03:08:43 +00:00
|
|
|
results to. If -1 (the default), info is reported about all available
|
|
|
|
areas.
|
|
|
|
@type rect: string
|
|
|
|
@param rect: the rectangle of interest. This defines if the corner
|
|
|
|
coordinates returned will refer to:
|
|
|
|
- the whole area: 'total'
|
|
|
|
- only the header: 'header'
|
|
|
|
- only the window content part (default): 'win'
|
2004-07-20 08:16:46 +00:00
|
|
|
@type screen: string
|
|
|
|
@param screen: the name of an available screen. The current one is used by
|
|
|
|
default.
|
2004-07-16 03:08:43 +00:00
|
|
|
@rtype: list of dictionaries
|
|
|
|
@return: a list of dictionaries, one for each area in the screen. Each
|
|
|
|
dictionary has these keys (all values are ints):
|
|
|
|
- 'vertices': [xmin, ymin, xmax, ymax] area corners;
|
|
|
|
- 'win': window type, see L{Types};
|
|
|
|
- 'id': this area's id.
|
|
|
|
"""
|