| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | # Blender.Object module and the Object PyType object | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | The Blender.Object submodule | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-02 03:38:31 +00:00
										 |  |  | B{New}: L{Object.getData} now accepts an optional bool keyword argument to | 
					
						
							|  |  |  | define if the user wants the data object or just its name. | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  | Object | 
					
						
							|  |  |  | ====== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This module provides access to the B{Objects} in Blender. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Example:: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   import Blender | 
					
						
							| 
									
										
										
										
											2004-01-03 03:50:58 +00:00
										 |  |  |   scene = Blender.Scene.getCurrent ()   # get the current scene | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   ob = Blender.Object.New ('Camera')    # make camera object | 
					
						
							|  |  |  |   cam = Blender.Camera.New ('ortho')    # make ortho camera data object | 
					
						
							|  |  |  |   ob.link (cam)                         # link camera data with the object | 
					
						
							|  |  |  |   scene.link (ob)                       # link the object into the scene | 
					
						
							|  |  |  |   ob.setLocation (0.0, -5.0, 1.0)       # position the object in the scene | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Blender.Redraw()                      # redraw the scene to show the updates. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def New (type, name='type'): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Creates a new Object. | 
					
						
							|  |  |  |   @type type: string | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |   @param type: The Object type: 'Armature', 'Camera', 'Curve', 'Lamp', 'Mesh' | 
					
						
							|  |  |  |       or 'Empty'. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   @type name: string | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |   @param name: The name of the object. By default, the name will be the same | 
					
						
							|  |  |  |       as the object type. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   @return: The created Object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   I{B{Example:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   The example below creates a new Lamp object and puts it at the default | 
					
						
							|  |  |  |   location (0, 0, 0) in the current scene:: | 
					
						
							| 
									
										
										
										
											2004-06-08 04:41:02 +00:00
										 |  |  |     import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     object = Blender.Object.New ('Lamp') | 
					
						
							|  |  |  |     lamp = Blender.Lamp.New ('Spot') | 
					
						
							|  |  |  |     object.link (lamp) | 
					
						
							|  |  |  |     scene = Blender.Scene.getCurrent () | 
					
						
							|  |  |  |     scene.link (object) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Blender.Redraw() | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def Get (name = None): | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   Get the Object from Blender. | 
					
						
							|  |  |  |   @type name: string | 
					
						
							|  |  |  |   @param name: The name of the requested Object. | 
					
						
							|  |  |  |   @return: It depends on the 'name' parameter: | 
					
						
							|  |  |  |       - (name): The Object with the given name; | 
					
						
							|  |  |  |       - ():     A list with all Objects in the current scene. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   I{B{Example 1:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   The example below works on the default scene. The script returns the plane | 
					
						
							|  |  |  |   object and prints the location of the plane:: | 
					
						
							|  |  |  |     import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     object = Blender.Object.Get ('plane') | 
					
						
							|  |  |  |     print object.getLocation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   I{B{Example 2:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   The example below works on the default scene. The script returns all objects | 
					
						
							|  |  |  |   in the scene and prints the list of object names:: | 
					
						
							|  |  |  |     import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     objects = Blender.Object.Get () | 
					
						
							|  |  |  |     print objects | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def GetSelected (): | 
					
						
							|  |  |  |   """
 | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |   Get the selected objects from Blender. If no objects are selected, an empty | 
					
						
							|  |  |  |   list will be returned. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   @return: A list of all selected Objects in the current scene. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   I{B{Example:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   The example below works on the default scene. Select one or more objects and | 
					
						
							|  |  |  |   the script will print the selected objects:: | 
					
						
							|  |  |  |     import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     objects = Blender.Object.GetSelected () | 
					
						
							|  |  |  |     print objects | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Object: | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   The Object object | 
					
						
							|  |  |  |   ================= | 
					
						
							|  |  |  |     This object gives access to generic data from all objects in Blender. | 
					
						
							|  |  |  |     @cvar LocX: The X location coordinate of the object. | 
					
						
							|  |  |  |     @cvar LocY: The Y location coordinate of the object. | 
					
						
							|  |  |  |     @cvar LocZ: The Z location coordinate of the object. | 
					
						
							|  |  |  |     @cvar loc: The (X,Y,Z) location coordinates of the object (vector). | 
					
						
							|  |  |  |     @cvar dLocX: The delta X location coordinate of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar dLocY: The delta Y location coordinate of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar dLocZ: The delta Z location coordinate of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar dloc: The delta (X,Y,Z) location coordinates of the object (vector). | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar RotX: The X rotation angle (in radians) of the object. | 
					
						
							|  |  |  |     @cvar RotY: The Y rotation angle (in radians) of the object. | 
					
						
							|  |  |  |     @cvar RotZ: The Z rotation angle (in radians) of the object. | 
					
						
							|  |  |  |     @cvar rot: The (X,Y,Z) rotation angles (in radians) of the object (vector). | 
					
						
							|  |  |  |     @cvar dRotX: The delta X rotation angle (in radians) of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar dRotY: The delta Y rotation angle (in radians) of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar dRotZ: The delta Z rotation angle (in radians) of the object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     @cvar drot: The delta (X,Y,Z) rotation angles (in radians) of the object | 
					
						
							|  |  |  |         (vector). | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |         This variable applies to IPO Objects only. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar SizeX: The X size of the object. | 
					
						
							|  |  |  |     @cvar SizeY: The Y size of the object. | 
					
						
							|  |  |  |     @cvar SizeZ: The Z size of the object. | 
					
						
							|  |  |  |     @cvar size: The (X,Y,Z) size of the object (vector). | 
					
						
							|  |  |  |     @cvar dSizeX: The delta X size of the object. | 
					
						
							|  |  |  |     @cvar dSizeY: The delta Y size of the object. | 
					
						
							|  |  |  |     @cvar dSizeZ: The delta Z size of the object. | 
					
						
							|  |  |  |     @cvar dsize: The delta (X,Y,Z) size of the object. | 
					
						
							|  |  |  |     @cvar EffX: The X effector coordinate of the object. Only applies to IKA. | 
					
						
							|  |  |  |     @cvar EffY: The Y effector coordinate of the object. Only applies to IKA. | 
					
						
							|  |  |  |     @cvar EffZ: The Z effector coordinate of the object. Only applies to IKA. | 
					
						
							| 
									
										
										
										
											2004-05-20 07:21:07 +00:00
										 |  |  |     @cvar Layer: The object layer.  This value is a bitmask with one position | 
					
						
							|  |  |  |         set for each of the 20 possible layers starting from the low order bit. | 
					
						
							| 
									
										
										
										
											2004-06-08 04:41:02 +00:00
										 |  |  |         The easiest way to deal with these values in in hexadecimal notation. | 
					
						
							|  |  |  |         Example:: | 
					
						
							|  |  |  |           ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 ) | 
					
						
							|  |  |  |         After setting the Layer value, call Blender.Redraw( -1 ) to update | 
					
						
							|  |  |  |         the interface. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar parent: The parent object of the object. (Read-only) | 
					
						
							|  |  |  |     @cvar track: The object tracking this object. (Read-only) | 
					
						
							|  |  |  |     @cvar data: The data of the object. (Read-only) | 
					
						
							|  |  |  |     @cvar ipo: The ipo data associated with the object. (Read-only) | 
					
						
							| 
									
										
										
										
											2004-07-04 19:57:41 +00:00
										 |  |  |     @cvar mat: The matrix of the object relative to its parent. (Read-only) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |     @cvar matrix: The matrix of the object in world space. (Read-only) | 
					
						
							| 
									
										
										
										
											2004-07-04 19:57:41 +00:00
										 |  |  |     @cvar matrixLocal: The matrix of the object relative to its parent. (Read-only) | 
					
						
							|  |  |  |     @cvar matrixWorld: The matrix of the object in world space. (Read-only) | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     @cvar colbits: The Material usage mask. A set bit #n means: the Material | 
					
						
							|  |  |  |         #n in the Object's material list is used. Otherwise, the Material #n | 
					
						
							|  |  |  |         of the Objects Data material list is displayed. | 
					
						
							|  |  |  |     @cvar drawType: The object's drawing type used. 1 - Bounding box, | 
					
						
							|  |  |  |         2 - wire, 3 - Solid, 4- Shaded, 5 - Textured. | 
					
						
							|  |  |  |     @cvar drawMode: The object's drawing mode used. The value can be a sum | 
					
						
							|  |  |  |         of: 2 - axis, 4 - texspace, 8 - drawname, 16 - drawimage, | 
					
						
							|  |  |  |         32 - drawwire. | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |     @cvar name: The name of the object. | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |     @cvar sel: The selection state of the object, 1/0.   | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-25 19:53:42 +00:00
										 |  |  |   def buildParts(): | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     Recomputes the particle system. This method only applies to an Object of | 
					
						
							|  |  |  |     the type Effect. | 
					
						
							| 
									
										
										
										
											2003-07-25 19:53:42 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def clearIpo(): | 
					
						
							| 
									
										
										
										
											2003-10-28 23:25:59 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |     Unlinks the ipo from this object. | 
					
						
							|  |  |  |     @return: True if there was an ipo linked or False otherwise. | 
					
						
							| 
									
										
										
										
											2003-10-28 23:25:59 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   def clrParent(mode = 0, fast = 0): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Clears parent object. | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @type mode: Integer | 
					
						
							|  |  |  |     @type fast: Integer | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     @param mode: A mode flag. If mode flag is 2, then the object transform will | 
					
						
							|  |  |  |         be kept. Any other value, or no value at all will update the object | 
					
						
							|  |  |  |         transform. | 
					
						
							|  |  |  |     @param fast: If the value is 0, the scene hierarchy will not be updated. Any | 
					
						
							|  |  |  |         other value, or no value at all will update the scene hierarchy. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  |   def getData(name_only = False): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2005-02-02 03:38:31 +00:00
										 |  |  |     Returns the Datablock object (new: or just its name) containing the | 
					
						
							|  |  |  |     object's data. For example the Mesh, Lamp or the Camera. | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  |     @type name_only: bool | 
					
						
							|  |  |  |     @param name_only: if True on nonzero, only the name of the data object | 
					
						
							| 
									
										
										
										
											2005-02-02 03:38:31 +00:00
										 |  |  |         is returned. | 
					
						
							|  |  |  |     @rtype: Object type specific or string | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     @return: Depending on the type of the Object, it returns a specific object | 
					
						
							| 
									
										
										
										
											2005-02-09 05:19:24 +00:00
										 |  |  |         for the data requested.  If name_only is True, it returns a string. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getDeltaLocation(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object's delta location in a list (x, y, z) | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @rtype: A vector triple | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     @return: (x, y, z) | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getDrawMode(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object draw mode. | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @rtype: Integer | 
					
						
							|  |  |  |     @return: a sum of the following: | 
					
						
							|  |  |  |         - 2  - axis | 
					
						
							|  |  |  |         - 4  - texspace | 
					
						
							|  |  |  |         - 8  - drawname | 
					
						
							|  |  |  |         - 16 - drawimage | 
					
						
							|  |  |  |         - 32 - drawwire | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getDrawType(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object draw type | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @rtype: Integer | 
					
						
							|  |  |  |     @return: One of the following: | 
					
						
							|  |  |  |         - 1 - Bounding box | 
					
						
							|  |  |  |         - 2 - Wire | 
					
						
							|  |  |  |         - 3 - Solid | 
					
						
							|  |  |  |         - 4 - Shaded | 
					
						
							|  |  |  |         - 5 - Textured | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getEuler(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-03-25 06:18:56 +00:00
										 |  |  |     Returns the object's rotation as Euler rotation vector (rotX, rotY, rotZ).  Angles are in radians. | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |     @rtype: Py_Euler | 
					
						
							|  |  |  |     @return: A python euler  | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getInverseMatrix(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object's inverse matrix. | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |     @rtype: Py_Matrix | 
					
						
							|  |  |  |     @return: A python matrix 4x4 | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   def getIpo(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns the Ipo associated to this object or None if there's no linked ipo. | 
					
						
							|  |  |  |     @rtype: Ipo | 
					
						
							|  |  |  |     @return: the wrapped ipo or None. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |   def isSelected(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns the objects selection state as a boolean value True or False. | 
					
						
							|  |  |  |     @rtype: Boolean | 
					
						
							|  |  |  |     @return: Selection state as True or False | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   def getLocation(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object's location (x, y, z). | 
					
						
							|  |  |  |     @return: (x, y, z) | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     I{B{Example:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     The example below works on the default scene. It retrieves all objects in | 
					
						
							|  |  |  |     the scene and prints the name and location of each object:: | 
					
						
							|  |  |  |       import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       objects = Blender.Object.Get() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       for obj in objects: | 
					
						
							|  |  |  |           print obj.getName() | 
					
						
							|  |  |  |           print obj.getLocation() | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |   def getAction(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns an action if one is associated with this object (only useful for armature types). | 
					
						
							|  |  |  |     @rtype: Py_Action | 
					
						
							|  |  |  |     @return: a python action. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  |   def getMaterials(what = 0): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns a list of materials assigned to the object. | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  |     @type what: int | 
					
						
							|  |  |  |     @param what: if nonzero, empty slots will be returned as None's instead | 
					
						
							|  |  |  |         of being ignored (default way). See L{NMesh.NMesh.getMaterials}. | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     @rtype: list of Material Objects | 
					
						
							|  |  |  |     @return: list of Material Objects assigned to the object. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +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 getMatrix(space = 'worldspace'): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object matrix. | 
					
						
							| 
									
										
											  
											
												- 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
										 |  |  |     @type space: string | 
					
						
							|  |  |  |     @param space: The desired matrix: | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |       - worldspace (default): absolute, taking vertex parents, tracking and | 
					
						
							|  |  |  |           ipo's into account; | 
					
						
							|  |  |  |       - localspace: relative to the object's parent; | 
					
						
							|  |  |  |       - old_worldspace: old behavior, prior to Blender 2.34, where eventual | 
					
						
							|  |  |  |           changes made by the script itself were not taken into account until | 
					
						
							|  |  |  |           a redraw happened, either called by the script or upon its exit. | 
					
						
							| 
									
										
										
										
											2004-07-04 19:57:41 +00:00
										 |  |  |     Returns the object matrix. | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |     @rtype: Py_Matrix | 
					
						
							| 
									
										
											  
											
												- 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
										 |  |  |     @return: a python 4x4 matrix object | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getName(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the name of the object | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @return: The name of the object | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     I{B{Example:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     The example below works on the default scene. It retrieves all objects in | 
					
						
							|  |  |  |     the scene and prints the name of each object:: | 
					
						
							|  |  |  |       import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       objects = Blender.Object.Get() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       for obj in objects: | 
					
						
							|  |  |  |           print obj.getName() | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getParent(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object's parent object. | 
					
						
							|  |  |  |     @rtype: Object | 
					
						
							|  |  |  |     @return: The parent object of the object. If not available, None will be | 
					
						
							|  |  |  |     returned. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-23 19:24:45 +00:00
										 |  |  |   def getSize(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns the object's size. | 
					
						
							|  |  |  |     @return: (SizeX, SizeY, SizeZ) | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-02 19:53:53 +00:00
										 |  |  |   def getTimeOffset(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns the time offset of the object's animation. | 
					
						
							|  |  |  |     @return: TimeOffset | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   def getTracked(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the object's tracked object. | 
					
						
							|  |  |  |     @rtype: Object | 
					
						
							|  |  |  |     @return: The tracked object of the object. If not available, None will be | 
					
						
							|  |  |  |     returned. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getType(): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Returns the type of the object. | 
					
						
							|  |  |  |     @return: The type of object. | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     I{B{Example:}} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     The example below works on the default scene. It retrieves all objects in | 
					
						
							|  |  |  |     the scene and updates the location and rotation of the camera. When run, | 
					
						
							|  |  |  |     the camera will rotate 180 degrees and moved to the oposite side of the X | 
					
						
							|  |  |  |     axis. Note that the number 'pi' in the example is an approximation of the | 
					
						
							|  |  |  |     true number 'pi':: | 
					
						
							|  |  |  |         import Blender | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         objects = Blender.Object.Get() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for obj in objects: | 
					
						
							|  |  |  |             if obj.getType() == 'Camera': | 
					
						
							|  |  |  |                 obj.LocY = -obj.LocY | 
					
						
							|  |  |  |                 obj.RotZ = 3.141592 - obj.RotZ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Blender.Redraw() | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-12 12:31:33 +00:00
										 |  |  |   def getDupliVerts(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get state of DupliVerts anim propertie | 
					
						
							|  |  |  |     @return: a boolean value. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  |   def link(object): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Links Object with data provided in the argument. The data must match the | 
					
						
							|  |  |  |     Object's type, so you cannot link a Lamp to a Mesh type object. | 
					
						
							|  |  |  |     @type object: Blender Object | 
					
						
							|  |  |  |     @param object: A Blender Object. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def makeParent(objects, noninverse = 0, fast = 0): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Makes the object the parent of the objects provided in the argument which | 
					
						
							|  |  |  |     must be a list of valid Objects. | 
					
						
							|  |  |  |     @type objects: Blender Object | 
					
						
							|  |  |  |     @param objects: A Blender Object. | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @type noninverse: Integer | 
					
						
							|  |  |  |     @param noninverse: | 
					
						
							|  |  |  |         0 - make parent with inverse | 
					
						
							|  |  |  |         1 - make parent without inverse | 
					
						
							|  |  |  |     @type fast: Integer | 
					
						
							|  |  |  |     @param fast: | 
					
						
							|  |  |  |         0 - update scene hierarchy automatically | 
					
						
							|  |  |  |         1 - don't update scene hierarchy (faster). In this case, you must | 
					
						
							|  |  |  |         explicitely update the Scene hierarchy. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |   def setDeltaLocation(delta_location): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Sets the object's delta location which must be a vector triple. | 
					
						
							|  |  |  |     @type delta_location: A vector triple | 
					
						
							|  |  |  |     @param delta_location: A vector triple (x, y, z) specifying the new | 
					
						
							|  |  |  |     location. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |   def setDrawMode(drawmode): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Sets the object's drawing mode. The drawing mode can be a mix of modes. To | 
					
						
							|  |  |  |     enable these, add up the values. | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @type drawmode: Integer | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     @param drawmode: A sum of the following: | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |         - 2  - axis | 
					
						
							|  |  |  |         - 4  - texspace | 
					
						
							|  |  |  |         - 8  - drawname | 
					
						
							|  |  |  |         - 16 - drawimage | 
					
						
							|  |  |  |         - 32 - drawwire | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |   def setDrawType(drawtype): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Sets the object's drawing type. | 
					
						
							| 
									
										
										
										
											2003-08-06 17:04:36 +00:00
										 |  |  |     @type drawtype: Integer | 
					
						
							|  |  |  |     @param drawtype: One of the following: | 
					
						
							|  |  |  |         - 1 - Bounding box | 
					
						
							|  |  |  |         - 2 - Wire | 
					
						
							|  |  |  |         - 3 - Solid | 
					
						
							|  |  |  |         - 4 - Shaded | 
					
						
							|  |  |  |         - 5 - Textured | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |   def setEuler(euler): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |     Sets the object's rotation according to the specified Euler angles. | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |     @type euler: Py_Euler or a list of floats | 
					
						
							|  |  |  |     @param euler: a python euler or x,y,z rotations as floats | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   def setIpo(ipo): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Links an ipo to this object. | 
					
						
							|  |  |  |     @type ipo: Blender Ipo | 
					
						
							|  |  |  |     @param ipo: an object type ipo. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |   def setLocation(x, y, z): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-08-06 22:08:56 +00:00
										 |  |  |     Sets the object's location. | 
					
						
							|  |  |  |     @type x: float | 
					
						
							|  |  |  |     @param x: The X coordinate of the new location. | 
					
						
							|  |  |  |     @type y: float | 
					
						
							|  |  |  |     @param y: The Y coordinate of the new location. | 
					
						
							|  |  |  |     @type z: float | 
					
						
							|  |  |  |     @param z: The Z coordinate of the new location. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def setMaterials(materials): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Sets the materials. The argument must be a list of valid material objects. | 
					
						
							|  |  |  |     @type materials: Materials list | 
					
						
							|  |  |  |     @param materials: A list of Blender material objects. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-02 14:29:31 +00:00
										 |  |  |   def setMatrix(matrix): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Sets the object's matrix and updates it's tranformation.  | 
					
						
							|  |  |  |     @type matrix: Py_Matrix 4x4 | 
					
						
							|  |  |  |     @param matrix: a python matrix 4x4. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |   def setName(name): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     Sets the name of the object. | 
					
						
							|  |  |  |     @type name: String | 
					
						
							|  |  |  |     @param name: The new name for the object. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-01-23 19:24:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def setSize(x, y, z): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Sets the object's size. | 
					
						
							|  |  |  |     @type x: float | 
					
						
							|  |  |  |     @param x: The X size multiplier. | 
					
						
							|  |  |  |     @type y: float | 
					
						
							|  |  |  |     @param y: The Y size multiplier. | 
					
						
							|  |  |  |     @type z: float | 
					
						
							|  |  |  |     @param z: The Z size multiplier. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-02 19:53:53 +00:00
										 |  |  |   def setTimeOffset(timeOffset): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Sets the time offset of the object's animation. | 
					
						
							|  |  |  |     @type timeOffset: float | 
					
						
							|  |  |  |     @param timeOffset: The new time offset for the object's animation. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-06-08 04:41:02 +00:00
										 |  |  |    | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |   def shareFrom(object): | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  |     Link data of object specified in the argument with self. This works only | 
					
						
							| 
									
										
										
										
											2003-07-30 20:52:35 +00:00
										 |  |  |     if self and the object specified are of the same type. | 
					
						
							|  |  |  |     @type object: Blender Object | 
					
						
							|  |  |  |     @param object: A Blender Object of the same type. | 
					
						
							| 
									
										
										
										
											2003-07-12 18:21:07 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   def select(boolean): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Sets the object's selection state. | 
					
						
							|  |  |  |     @type boolean: Integer | 
					
						
							|  |  |  |     @param boolean: | 
					
						
							|  |  |  |         - 0  - unselected | 
					
						
							|  |  |  |         - 1  - selected | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  |   def getBoundBox(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Returns the bounding box of this object.  This works for meshes (out of | 
					
						
							|  |  |  |     edit mode) and curves. | 
					
						
							|  |  |  |     @rtype: list of 8 (x,y,z) float coordinate vectors | 
					
						
							|  |  |  |     @return: The coordinates of the 8 corners of the bounding box. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def makeDisplayList(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Updates this object's display list.  Blender uses display lists to store | 
					
						
							|  |  |  |     already transformed data (like a mesh with its vertices already modified | 
					
						
							|  |  |  |     by coordinate transformations and armature deformation).  If the object | 
					
						
							|  |  |  |     isn't modified, there's no need to recalculate this data.  This method is | 
					
						
							|  |  |  |     here for the *few cases* where a script may need it, like when toggling | 
					
						
							|  |  |  |     the "SubSurf" mode for a 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  |     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
										 |  |  |      object = Blender.Object.Get("Sphere") | 
					
						
							|  |  |  |      nmesh = object.getData() | 
					
						
							|  |  |  |      nmesh.setMode("SubSurf") | 
					
						
							|  |  |  |      nmesh.update() # don't forget to update! | 
					
						
							|  |  |  |      object.makeDisplayList() | 
					
						
							|  |  |  |      Blender.Window.Redraw() | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     If you try this example without the line to update the display list, the | 
					
						
							|  |  |  |     object will disappear from the screen until you press "SubSurf". | 
					
						
							|  |  |  |     @warn: If after running your script objects disappear from the screen or | 
					
						
							|  |  |  |        are not displayed correctly, try this method function.  But if the script | 
					
						
							|  |  |  |        works properly without it, there's no reason to use it. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | 
 | 
					
						
							|  |  |  |   def getScriptLinks (event): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get a list with this Object's script links of type 'event'. | 
					
						
							|  |  |  |     @type event: string | 
					
						
							|  |  |  |     @param event: "FrameChanged" or "Redraw". | 
					
						
							|  |  |  |     @rtype: list | 
					
						
							|  |  |  |     @return: a list with Blender L{Text} names (the script links of the given | 
					
						
							|  |  |  |         'event' type) or None if there are no script links at all. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def clearScriptLinks (): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Delete all this Object's script links. | 
					
						
							|  |  |  |     @rtype: bool | 
					
						
							|  |  |  |     @return: 0 if some internal problem occurred or 1 if successful. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def addScriptLink (text, event): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Add a new script link to this Object. | 
					
						
							|  |  |  |     @type text: string | 
					
						
							|  |  |  |     @param text: the name of an existing Blender L{Text}. | 
					
						
							|  |  |  |     @type event: string | 
					
						
							|  |  |  |     @param event: "FrameChanged" or "Redraw". | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def makeTrack (tracked, fast = 0): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Make this Object track another. | 
					
						
							|  |  |  |     @type tracked: Blender Object | 
					
						
							|  |  |  |     @param tracked: the object to be tracked. | 
					
						
							|  |  |  |     @type fast: int (bool) | 
					
						
							|  |  |  |     @param fast: if zero, the scene hierarchy is updated automatically.  If | 
					
						
							|  |  |  |         you set 'fast' to a nonzero value, don't forget to update the scene | 
					
						
							|  |  |  |         yourself (see L{Scene.Scene.update}). | 
					
						
							|  |  |  |     @note: you also need to clear the rotation (L{setEuler}) of this object | 
					
						
							|  |  |  |        if it was not (0,0,0) already. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def clearTrack (mode = 0, fast = 0): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Make this Object not track another anymore. | 
					
						
							|  |  |  |     @type mode: int (bool) | 
					
						
							|  |  |  |     @param mode: if nonzero the matrix transformation used for tracking is kept. | 
					
						
							|  |  |  |     @type fast: int (bool) | 
					
						
							|  |  |  |     @param fast: if zero, the scene hierarchy is updated automatically.  If | 
					
						
							|  |  |  |         you set 'fast' to a nonzero value, don't forget to update the scene | 
					
						
							|  |  |  |         yourself (see L{Scene.Scene.update}). | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2004-07-04 19:57:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def getAllProperties (): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Return a list of properties from this object. | 
					
						
							|  |  |  |     @rtype: PyList | 
					
						
							|  |  |  |     @return: List of Property objects. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getProperty (name): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Return a properties from this object based on name. | 
					
						
							|  |  |  |     @type name: string | 
					
						
							|  |  |  |     @param name: the name of the property to get. | 
					
						
							|  |  |  |     @rtype: Property object | 
					
						
							|  |  |  |     @return: The first property that matches name. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def addProperty (name, data, type): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Add a property to object. | 
					
						
							|  |  |  |     @type name: string | 
					
						
							|  |  |  |     @param name: the property name. | 
					
						
							|  |  |  |     @type data: string, int or float | 
					
						
							|  |  |  |     @param data: depends on what is passed in: | 
					
						
							|  |  |  |       - string:  string type property | 
					
						
							|  |  |  |       - int:  integer type property | 
					
						
							|  |  |  |       - float:  float type property | 
					
						
							|  |  |  |     @type type: string (optional) | 
					
						
							|  |  |  |     @param type: can be the following: | 
					
						
							|  |  |  |       - 'BOOL' | 
					
						
							|  |  |  |       - 'INT' | 
					
						
							|  |  |  |       - 'FLOAT' | 
					
						
							|  |  |  |       - 'TIME' | 
					
						
							|  |  |  |       - 'STRING' | 
					
						
							|  |  |  |     @warn: If a type is not declared string data will | 
					
						
							|  |  |  |     become string type, int data will become int type | 
					
						
							|  |  |  |     and float data will become float type. Override type | 
					
						
							|  |  |  |     to declare bool type, and time type. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def addProperty (property): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Add a property to object. | 
					
						
							|  |  |  |     @type property: Property object | 
					
						
							|  |  |  |     @param property: property object to add to object. | 
					
						
							|  |  |  |     @warn:  A property object can be added only once to an object' | 
					
						
							|  |  |  |     you must remove the property from an object to add it elsewhere. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def removeProperty (name): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Remove a property from an object by name. | 
					
						
							|  |  |  |     @type property: Property object | 
					
						
							|  |  |  |     @param property: property to remove by name. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def removeProperty (property): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Remove a property from an object. | 
					
						
							|  |  |  |     @type property: Property object | 
					
						
							|  |  |  |     @param property: property object to remove. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def removeAllProperties(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Removes all properties from an object.  | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def copyAllPropertiesTo (object): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Copies all properties from one object to another. | 
					
						
							|  |  |  |     @type object: Object object | 
					
						
							|  |  |  |     @param object: Object that will recieve the properties. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-12 12:31:33 +00:00
										 |  |  |   def setDupliVerts(data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set state of DupliVerts anim propertie | 
					
						
							|  |  |  |     @param data: boolean value True, False, 0 or not 0. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-04 19:57:41 +00:00
										 |  |  | class Property: | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  |   The Property object | 
					
						
							|  |  |  |   =================== | 
					
						
							|  |  |  |     This property gives access to object property data in Blender. | 
					
						
							|  |  |  |     @cvar name: The property name. | 
					
						
							|  |  |  |     @cvar data: Data for this property. Depends on property type. | 
					
						
							|  |  |  |     @cvar type: The property type. | 
					
						
							|  |  |  |     @warn:  Comparisons between properties will only be true when | 
					
						
							|  |  |  |     both the name and data pairs are the same. | 
					
						
							|  |  |  |   """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getName (): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the name of this property. | 
					
						
							|  |  |  |     @rtype: string | 
					
						
							|  |  |  |     @return: The property name. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setName (name): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set the name of this property. | 
					
						
							|  |  |  |     @type name: string | 
					
						
							|  |  |  |     @param name: The new name of the property | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getData (): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the data for this property. | 
					
						
							|  |  |  |     @rtype: string, int, or float | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setData (data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Set the data for this property. | 
					
						
							|  |  |  |     @type data: string, int, or float | 
					
						
							|  |  |  |     @param data: The data to set for this property. | 
					
						
							|  |  |  |     @warn:  See object.setProperty().  Changing data | 
					
						
							|  |  |  |     which is of a different type then the property is  | 
					
						
							|  |  |  |     set to (i.e. setting an int value to a float type' | 
					
						
							|  |  |  |     property) will change the type of the property  | 
					
						
							|  |  |  |     automatically. | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def getType (): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Get the type for this property. | 
					
						
							|  |  |  |     @rtype: string | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2005-03-12 12:31:33 +00:00
										 |  |  | 
 |