diff --git a/release/scripts/3ds_export.py b/release/scripts/3ds_export.py index 2ea6efc2080..7cf7bb2cf5e 100644 --- a/release/scripts/3ds_export.py +++ b/release/scripts/3ds_export.py @@ -47,6 +47,7 @@ from the lib3ds project (http://lib3ds.sourceforge.net/) sourcecode. ###################################################### import Blender +import bpy from Blender import Object, Material import BPyMesh @@ -877,7 +878,7 @@ def save_3ds(filename): time1= Blender.sys.time() Blender.Window.WaitCursor(1) - scn= Blender.Main.scenes.active + scn= bpy.scenes.active # Initialize the main chunk (primary): primary = _3ds_chunk(PRIMARY) diff --git a/release/scripts/3ds_import.py b/release/scripts/3ds_import.py index ab85b7f750f..6cec591ac4f 100644 --- a/release/scripts/3ds_import.py +++ b/release/scripts/3ds_import.py @@ -117,7 +117,8 @@ Loader is based on 3ds loader from www.gametutorials.com (Thanks DigiBen). # Importing modules import Blender -from Blender import Mesh, Main, Object, Material, Image, Texture, Lamp, Mathutils +import bpy +from Blender import Mesh, Object, Material, Image, Texture, Lamp, Mathutils from Blender.Mathutils import Vector import BPyImage @@ -864,7 +865,7 @@ def load_3ds(filename, PREF_UI= True): ##IMAGE_SEARCH - scn= Main.scenes.active + scn= bpy.scenes.active SCN_OBJECTS = scn.objects SCN_OBJECTS.selected = [] # de select all diff --git a/release/scripts/armature_symmetry.py b/release/scripts/armature_symmetry.py index 85e4d1a3afe..8d861aaf72d 100644 --- a/release/scripts/armature_symmetry.py +++ b/release/scripts/armature_symmetry.py @@ -39,7 +39,7 @@ Hidden bones are ignored, and optionally only operate on selected bones. # -------------------------------------------------------------------------- import Blender -from Blender import Main +import bpy Vector= Blender.Mathutils.Vector @@ -248,7 +248,7 @@ def main(): User interface function that gets the options and calls armature_symetry() ''' - scn= Main.scenes.active + scn= bpy.scenes.active arm_ob= scn.objects.active if not arm_ob or arm_ob.type!='Armature': diff --git a/release/scripts/bpymodules/BPyMesh.py b/release/scripts/bpymodules/BPyMesh.py index 8aec94ca555..b28ec58c84d 100644 --- a/release/scripts/bpymodules/BPyMesh.py +++ b/release/scripts/bpymodules/BPyMesh.py @@ -19,6 +19,7 @@ import Blender +import bpy import BPyMesh_redux # seperated because of its size. # reload(BPyMesh_redux) redux= BPyMesh_redux.redux @@ -384,14 +385,13 @@ def getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=Tru ''' if not scn: - scn= Blender.Main.scenes.active + scn= bpy.scenes.active if not container_mesh: - mesh = Blender.Mesh.New() + mesh = bpy.meshes.new(ob.name) else: mesh= container_mesh mesh.verts= None - ob_type = ob.type dataname = ob.getData(1) tempob= None diff --git a/release/scripts/bpymodules/BPyMesh_redux.py b/release/scripts/bpymodules/BPyMesh_redux.py index 86a2975caba..4c45a3846a4 100644 --- a/release/scripts/bpymodules/BPyMesh_redux.py +++ b/release/scripts/bpymodules/BPyMesh_redux.py @@ -22,6 +22,7 @@ # -------------------------------------------------------------------------- import Blender +import bpy Vector= Blender.Mathutils.Vector Ang= Blender.Mathutils.AngleBetweenVecs CrossVecs= Blender.Mathutils.CrossVecs @@ -642,7 +643,7 @@ def redux(ob, REDUX=0.5, BOUNDRY_WEIGHT=2.0, REMOVE_DOUBLES=False, FACE_AREA_WEI # Example usage def main(): Blender.Window.EditMode(0) - scn= Blender.Main.scenes.active + scn= bpy.scenes.active active_ob= scn.objects.active t= Blender.sys.time() redux(active_ob, 0.5) diff --git a/release/scripts/bvh_import.py b/release/scripts/bvh_import.py index e8648715d91..68e4bf3aac4 100644 --- a/release/scripts/bvh_import.py +++ b/release/scripts/bvh_import.py @@ -39,6 +39,7 @@ as empties or armatures. # -------------------------------------------------------------------------- import Blender +import bpy import BPyMessages Vector= Blender.Mathutils.Vector Euler= Blender.Mathutils.Euler @@ -310,7 +311,7 @@ def bvh_node_dict2objects(bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOOP= False): if IMPORT_START_FRAME<1: IMPORT_START_FRAME= 1 - scn= Blender.Main.scenes.active + scn= bpy.scenes.active scn.objects.selected = [] objects= [] @@ -442,7 +443,7 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOOP= False) - scn= Blender.Main.scenes.active + scn= bpy.scenes.active scn.objects.selected = [] @@ -749,7 +750,7 @@ def main(): if __name__ == '__main__': main() ''' - scn = Blender.Main.scenes.active + scn = bpy.scenes.active for ob in list(scn.objects): scn.objects.unlink(ob) load_bvh_ui('/test.bvh', False) ''' diff --git a/release/scripts/console.py b/release/scripts/console.py index 827ac4c5320..ea7e87efba2 100644 --- a/release/scripts/console.py +++ b/release/scripts/console.py @@ -812,4 +812,5 @@ cmdBuffer.append(cmdLine(' ', 0, 0)) def main(): Draw.Register(draw_gui, handle_event, handle_button_event) -main() \ No newline at end of file +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/release/scripts/mesh_skin.py b/release/scripts/mesh_skin.py index 7673209bcca..c417e2059ed 100644 --- a/release/scripts/mesh_skin.py +++ b/release/scripts/mesh_skin.py @@ -50,6 +50,7 @@ A pop-up will provide further options, if the results of a method are not adequa # Made by Ideasman/Campbell 2005/06/15 - cbarton@metavr.com import Blender +import bpy from Blender import Window from Blender.Mathutils import MidpointVecs, Vector, CrossVecs from Blender.Mathutils import AngleBetweenVecs as _AngleBetweenVecs_ @@ -520,7 +521,7 @@ def main(): is_editmode = Window.EditMode() if is_editmode: Window.EditMode(0) - ob = Blender.Main.scenes.active.objects.active + ob = bpy.scenes.active.objects.active if ob == None or ob.type != 'Mesh': BPyMessages.Error_NoMeshActive() return diff --git a/release/scripts/mesh_solidify.py b/release/scripts/mesh_solidify.py index dca45b9c377..2e58513845c 100644 --- a/release/scripts/mesh_solidify.py +++ b/release/scripts/mesh_solidify.py @@ -17,6 +17,7 @@ Optionaly you can skin between the original and new faces to make a watertight s from Blender import * +import bpy import BPyMesh # reload(BPyMesh) import BPyMessages @@ -100,7 +101,7 @@ def lengthFromAngle(angle): def main(): - scn = Main.scenes.active + scn = bpy.scenes.active ob = scn.objects.active if not ob or ob.type != 'Mesh': diff --git a/release/scripts/object_apply_def.py b/release/scripts/object_apply_def.py index 77dff67acb9..e7cdf4089b1 100644 --- a/release/scripts/object_apply_def.py +++ b/release/scripts/object_apply_def.py @@ -63,6 +63,7 @@ This script will work with object types: Mesh, Metaballs, Text3d, Curves and Nur import Blender +import bpy import BPyMesh def copy_vgroups(source_ob, target_ob): @@ -85,7 +86,7 @@ def copy_vgroups(source_ob, target_ob): def apply_deform(): - scn= Blender.Main.scenes.active + scn= bpy.scenes.active #Blender.Window.EditMode(0) NAME_LENGTH = 19 diff --git a/release/scripts/object_batch_name_edit.py b/release/scripts/object_batch_name_edit.py index eff43e05fa8..d9725c66ea8 100644 --- a/release/scripts/object_batch_name_edit.py +++ b/release/scripts/object_batch_name_edit.py @@ -43,10 +43,11 @@ menu of the 3d View. # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- from Blender import * +import bpy global renameCount renameCount = 0 -obsel = Main.scenes.active.objects.context +obsel = bpy.scenes.active.objects.context def setDataNameWrapper(ob, newname): if ob.getData(name_only=1) == newname: diff --git a/release/scripts/uvcalc_follow_active_coords.py b/release/scripts/uvcalc_follow_active_coords.py index c932106a751..2a6648ab4e6 100644 --- a/release/scripts/uvcalc_follow_active_coords.py +++ b/release/scripts/uvcalc_follow_active_coords.py @@ -39,11 +39,11 @@ http://mediawiki.blender.org/index.php/Scripts/Manual/UV_Calculate/Follow_active from Blender import * +import bpy import BPyMesh -reload(BPyMesh) def extend(): - scn = Main.scenes.active + scn = bpy.scenes.active ob = scn.objects.active # print ob, ob.type diff --git a/release/scripts/uvcalc_from_adjacent.py b/release/scripts/uvcalc_from_adjacent.py index ccf24c4ac52..e5cd64fe5b0 100644 --- a/release/scripts/uvcalc_from_adjacent.py +++ b/release/scripts/uvcalc_from_adjacent.py @@ -38,7 +38,7 @@ Use this script in face select mode for texturing between textured faces. from Blender import * - +import bpy def mostUsedImage(imageList): # Returns the image most used in the list. if not imageList: @@ -70,7 +70,7 @@ def mostUsedImage(imageList): # Returns the image most used in the list. def main(): - scn = Main.scenes.active + scn = bpy.scenes.active ob = scn.objects.active if ob == None or ob.type != 'Mesh': Draw.PupMenu('ERROR: No mesh object in face select mode.') diff --git a/release/scripts/uvcalc_lightmap.py b/release/scripts/uvcalc_lightmap.py index a9faa7c9350..9fda4d44f85 100644 --- a/release/scripts/uvcalc_lightmap.py +++ b/release/scripts/uvcalc_lightmap.py @@ -35,6 +35,7 @@ __bpydoc__ = """\ from Blender import * +import bpy import BPyMesh # reload(BPyMesh) @@ -504,7 +505,7 @@ PREF_MARGIN_DIV= 512): Window.RedrawAll() def main(): - scn = Main.scenes.active + scn = bpy.scenes.active PREF_ACT_ONLY = Draw.Create(1) PREF_SEL_ONLY = Draw.Create(1) diff --git a/release/scripts/uvcalc_quad_clickproj.py b/release/scripts/uvcalc_quad_clickproj.py index dfaf653ecf3..760d9ab2767 100644 --- a/release/scripts/uvcalc_quad_clickproj.py +++ b/release/scripts/uvcalc_quad_clickproj.py @@ -40,6 +40,7 @@ http://mediawiki.blender.org/index.php/Scripts/Manual/UV_Calculate/Click_project # -------------------------------------------------------------------------- import Blender +import bpy import BPyMesh import BPyWindow @@ -74,7 +75,7 @@ def mousedown_wait(): def main(): - scn = Blender.Main.scenes.active + scn = bpy.scenes.active ob = scn.objects.active if not ob or ob.type!='Mesh': return diff --git a/release/scripts/uvcalc_smart_project.py b/release/scripts/uvcalc_smart_project.py index 205a2cc5dbe..35bb1b2d4ee 100644 --- a/release/scripts/uvcalc_smart_project.py +++ b/release/scripts/uvcalc_smart_project.py @@ -827,20 +827,18 @@ def main(): global USER_STRETCH_ASPECT global USER_ISLAND_MARGIN - objects= Main.scenes.active.objects + objects= bpy.scenes.active.objects - # Use datanames as kesy so as not to unwrap a mesh more then once. - obList = dict([(ob.getData(name_only=1), ob) for ob in objects.context if ob.type == 'Mesh']) + # we can will tag them later. + obList = [ob for ob in objects.context if ob.type == 'Mesh'] # Face select object may not be selected. ob = objects.active if ob and ob.sel == 0 and ob.type == 'Mesh': # Add to the list - obList[ob.getData(name_only=1)] = ob + obList =[ob] del objects - obList = obList.values() # turn from a dict to a list. - if not obList: Draw.PupMenu('error, no selected mesh objects') return @@ -913,30 +911,34 @@ def main(): # Assume face select mode! an annoying hack to toggle face select mode because Mesh dosent like faceSelectMode. if USER_SHARE_SPACE: - # Sort by data name so we get consistand results + # Sort by data name so we get consistant results try: obList.sort(key = lambda ob: ob.getData(name_only=1)) except: obList.sort(lambda ob1, ob2: cmp( ob1.getData(name_only=1), ob2.getData(name_only=1) )) collected_islandList= [] Window.WaitCursor(1) - + time1 = sys.time() + + # Tag as False se we dont operate on teh same mesh twice. + bpy.meshes.tag = False + for ob in obList: me = ob.getData(mesh=1) + if me.tag or me.lib: + continue + + # Tag as used + me.tag = True + if not me.faceUV: # Mesh has no UV Coords, dont bother. me.faceUV= True if USER_ONLY_SELECTED_FACES: SELECT_FLAG = Mesh.FaceFlags.SELECT - HIDE_FLAG = Mesh.FaceFlags.HIDE - def use_face(f_flag): - if f_flag & HIDE_FLAG: return False - elif f_flag & SELECT_FLAG: return True - else: return False - - meshFaces = [thickface(f) for f in me.faces if use_face(f.flag)] + meshFaces = [thickface(f) for f in me.faces if f.flag & SELECT_FLAG] else: meshFaces = map(thickface, me.faces) @@ -945,7 +947,6 @@ def main(): Window.DrawProgressBar(0.1, 'SmartProj UV Unwrapper, mapping "%s", %i faces.' % (me.name, len(meshFaces))) - # ======= # Generate a projection list from face normals, this is ment to be smart :) diff --git a/release/scripts/widgetwizard.py b/release/scripts/widgetwizard.py index 9edab0f6151..8ace2129e11 100644 --- a/release/scripts/widgetwizard.py +++ b/release/scripts/widgetwizard.py @@ -66,6 +66,7 @@ The widget is added and you are returned to the first screen for adding another ################################################################### import Blender +import bpy from Blender import Mesh,Object,Material,Window,IpoCurve,Ipo,Text3d from Blender.BGL import * from Blender.Draw import * @@ -103,7 +104,7 @@ def delCurve(ipo): def verifyIpocurve(ky,index): ipo = ky.ipo if ipo == None: - nip = Ipo.New("Key","keyipo") + nip = bpy.ipos.new("keyipo", "Key") ky.ipo = nip ipo = ky.ipo if index == 0: @@ -342,8 +343,8 @@ def setupDrivers(ob,ctrl,type): ipo.driverObject = ctrl ipo.driverChannel = IpoCurve.LOC_Z delCurve(ipo) - ipo.v((0,0)) - ipo.v((1,1)) + ipo.append((0,0)) + ipo.append((1,1)) ipo.recalc() ipo2 = verifyIpocurve(ky,shapes[1].val) @@ -351,8 +352,8 @@ def setupDrivers(ob,ctrl,type): ipo2.driverObject = ctrl ipo2.driverChannel = IpoCurve.LOC_X delCurve(ipo2) - ipo2.v((0,0)) - ipo2.v((1,1)) + ipo2.append((0,0)) + ipo2.append((1,1)) ipo2.recalc() ipo3 = verifyIpocurve(ky,shapes[2].val) @@ -360,7 +361,7 @@ def setupDrivers(ob,ctrl,type): ipo3.driverObject = ctrl ipo3.driverChannel = IpoCurve.LOC_X delCurve(ipo3) - ipo3.v((-1,1)) + ipo3.append((-1,1)) ipo3.append((0,0)) ipo3.recalc() @@ -388,13 +389,9 @@ def build(type): return loc = Window.GetCursorPos() - range = makeRange(type,rangename.val) - controller = makeController(rangename.val) - text = makeText(rangename.val) - - sce.link(range) - sce.link(controller) - sce.link(text) + range = makeRange(sce, type,rangename.val) + controller = makeController(sce, rangename.val) + text = makeText(sce, rangename.val) range.restrictRender = True controller.restrictRender = True @@ -413,179 +410,158 @@ def build(type): #Create the text -def makeText(name): - ob = Object.New("Text",name+".name") +def makeText(sce, name): txt = Text3d.New(name+".name") + txt.setDrawMode(Text3d.DRAW3D) txt.setAlignment(Text3d.MIDDLE) txt.setText(name) - ob.link(txt) + ob = sce.objects.new(txt) ob.setEuler((3.14159/2,0,0)) return ob #Create the mesh controller -def makeController(name): - ob = Object.New("Mesh",name+".ctrl") - me = Mesh.New(name+".ctrl") - - me.verts.extend(-0.15,0, 0) - me.verts.extend( 0,0, 0.15) - me.verts.extend( 0.15,0, 0) - me.verts.extend( 0,0,-0.15) - v = me.verts - c = [(v[0],v[1],v[2],v[3])] - me.edges.extend(c) - ob.link(me) +def makeController(sce, name): + me = bpy.meshes.new(name+".ctrl") + ob = sce.objects.new(me) + me.verts.extend([\ + (-0.15,0, 0),\ + ( 0,0, 0.15),\ + ( 0.15,0, 0),\ + ( 0,0,-0.15)]) + + me.edges.extend([(0,1,2,3)]) return ob #Create the mesh range -def makeRange(type,name): - ob = Object.New("Mesh",name) +def makeRange(sce,type,name): #ob.setDrawMode(8) # Draw Name - me = Mesh.New(name) - - l=[] + me = bpy.meshes.new(name) + ob = sce.objects.new(me) if type == SHAPE1_ONE_ZERO: - me.verts.extend(-0.15,0,0) - me.verts.extend( 0.15,0,0) - me.verts.extend(-0.15,0,1) - me.verts.extend( 0.15,0,1) - me.verts.extend(-0.25,0,.1) - me.verts.extend(-0.25,0,-.10) - me.verts.extend(0.25,0,.1) - me.verts.extend(0.25,0,-0.10) - v = me.verts - l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[0]),(v[6],v[7],v[1])] - me.edges.extend(l) - ob.link(me) + me.verts.extend([\ + (-0.15,0,0),\ + ( 0.15,0,0),\ + (-0.15,0,1),\ + ( 0.15,0,1),\ + (-0.25,0,.1),\ + (-0.25,0,-.10),\ + (0.25,0,.1),\ + (0.25,0,-0.10)]) + + me.edges.extend([(0,1,3,2),(4,5,0),(6,7,1)]) elif type == SHAPE1_TOGGLE: - me.verts.extend(-0.15,0,-0.5) - me.verts.extend( 0.15,0,-0.5) - me.verts.extend( 0.15,0, 0.5) - me.verts.extend(-0.15,0, 0.5) - me.verts.extend(-0.15,0, 1.5) - me.verts.extend( 0.15,0, 1.5) - v = me.verts - l = [(v[0],v[1],v[2],v[3]),(v[3],v[4],v[5],v[2])] - me.edges.extend(l) - ob.link(me) + me.verts.extend([\ + (-0.15,0,-0.5),\ + ( 0.15,0,-0.5),\ + ( 0.15,0, 0.5),\ + (-0.15,0, 0.5),\ + (-0.15,0, 1.5),\ + ( 0.15,0, 1.5)]) + + me.edges.extend([(0,1,2,3),(3,4,5,2)]) elif type == SHAPE1_ZERO_MONE: - me.verts.extend(-0.15,0,0) - me.verts.extend( 0.15,0,0) - me.verts.extend(-0.15,0,-1) - me.verts.extend( 0.15,0,-1) - me.verts.extend(-0.25,0,.1) - me.verts.extend(-0.25,0,-.10) - me.verts.extend(0.25,0,.1) - me.verts.extend(0.25,0,-0.10) - v = me.verts - l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[0]),(v[6],v[7],v[1])] - me.edges.extend(l) - ob.link(me) + me.verts.extend([\ + (-0.15,0,0),\ + ( 0.15,0,0),\ + (-0.15,0,-1),\ + ( 0.15,0,-1),\ + (-0.25,0,.1),\ + (-0.25,0,-.10),\ + (0.25,0,.1),\ + (0.25,0,-0.10)]) + + me.edges.extend([(0,1,3,2),(4,5,0),(6,7,1)]) elif type in [SHAPE1_ONE_MONE,SHAPE2_EXCLUSIVE]: - me.verts.extend(-0.15,0,-1) - me.verts.extend( 0.15,0,-1) - me.verts.extend(-0.15,0,1) - me.verts.extend( 0.15,0,1) - me.verts.extend(-0.25,0,.1) - me.verts.extend(-0.25,0,-.10) - me.verts.extend(0.25,0,.1) - me.verts.extend(0.25,0,-0.10) - me.verts.extend(-0.15,0,0) - me.verts.extend( 0.15,0,0) + me.verts.extend([\ + (-0.15,0,-1),\ + ( 0.15,0,-1),\ + (-0.15,0,1),\ + ( 0.15,0,1),\ + (-0.25,0,.1),\ + (-0.25,0,-.10),\ + (0.25,0,.1),\ + (0.25,0,-0.10),\ + (-0.15,0,0),\ + ( 0.15,0,0)]) - v = me.verts - l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[8]),(v[6],v[7],v[9])] + l = [(0,1,3,2),(4,5,8),(6,7,9)] me.edges.extend(l) - ob.link(me) elif type == SHAPE2_T: - me.verts.extend(-1,0,0) - me.verts.extend( 1,0,0) - me.verts.extend( 1,0,-1) - me.verts.extend(-1,0,-1) + me.verts.extend([\ + (-1,0,0),\ + ( 1,0,0),\ + ( 1,0,-1),\ + (-1,0,-1)]) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) + me.edges.extend([(0,1,2,3)]) elif type == SHAPE2_INVT: - me.verts.extend(-1,0,0) - me.verts.extend( 1,0,0) - me.verts.extend( 1,0,1) - me.verts.extend(-1,0,1) + me.verts.extend([\ + (-1,0,0),\ + ( 1,0,0),\ + ( 1,0,1),\ + (-1,0,1)]) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) + me.edges.extend([(0,1,2,3)]) elif type == SHAPE2_PLUS: - me.verts.extend(-1,0,-1) - me.verts.extend( 1,0,-1) - me.verts.extend( 1,0,1) - me.verts.extend(-1,0,1) + me.verts.extend([\ + (-1,0,-1),\ + ( 1,0,-1),\ + ( 1,0,1),\ + (-1,0,1)]) + me.edges.extend([(0,1,2,3)]) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) - elif type == SHAPE2_V: - me.verts.extend(0,0,0) - me.verts.extend(1,0,0) - me.verts.extend(1,0,1) - me.verts.extend(0,0,1) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) + me.verts.extend([\ + (0,0,0),\ + (1,0,0),\ + (1,0,1),\ + (0,0,1)]) + + me.edges.extend([(0,1,2,3)]) ob.setEuler((0,-0.78539,0)) elif type == SHAPE3_INVT: - me.verts.extend(-1,0,0) - me.verts.extend( 1,0,0) - me.verts.extend( 1,0,1) - me.verts.extend(-1,0,1) + me.verts.extend([\ + (-1,0,0),\ + ( 1,0,0),\ + ( 1,0,1),\ + (-1,0,1)]) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) + me.edges.extend([(0,1,2,3)]) elif type == SHAPE3_T: - me.verts.extend(-1,0,0) - me.verts.extend( 1,0,0) - me.verts.extend( 1,0,-1) - me.verts.extend(-1,0,-1) + me.verts.extend([\ + (-1,0,0),\ + ( 1,0,0),\ + ( 1,0,-1),\ + (-1,0,-1)]) - v = me.verts - l = [(v[0],v[1],v[2],v[3])] - me.edges.extend(l) - ob.link(me) + me.edges.extend([(0,1,2,3)]) - + elif type == SHAPE4_X: - me.verts.extend(0,0,-1) - me.verts.extend(1,0,-1) - me.verts.extend(1,0,0) - me.verts.extend(1,0,1) - me.verts.extend(0,0,1) - me.verts.extend(-1,0,1) - me.verts.extend(-1,0,0) - me.verts.extend(-1,0,-1) - v = me.verts - l = [(v[0],v[1]),(v[1],v[2]),(v[2],v[3]),(v[3],v[4]),(v[4],v[5]),(v[5],v[6]),(v[6],v[7]),(v[7],v[0])] - me.edges.extend(l) - ob.link(me) + me.verts.extend([\ + (0,0,-1),\ + (1,0,-1),\ + (1,0,0),\ + (1,0,1),\ + (0,0,1),\ + (-1,0,1),\ + (-1,0,0),\ + (-1,0,-1)]) + + me.edges.extend([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,0)]) ob.setEuler((0,-0.78539,0)) return ob @@ -606,7 +582,7 @@ EVENT_BACK = 103 #get the list of shapes from the selected object def shapeMenuText(): - ob = Blender.Scene.GetCurrent().objects.active + ob = bpy.scenes.active.objects.active if not ob: return "" diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index c8173866f97..a6f150fe1e9 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -65,7 +65,7 @@ #include "api2_2x/Camera.h" #include "api2_2x/Draw.h" #include "api2_2x/Registry.h" -#include "api2_2x/Main.h" /* for the "bpy" default module */ +#include "api2_2x/BPyModule.h" /* for the "bpy" default module */ /* for scriptlinks */ #include "DNA_lamp_types.h" @@ -116,6 +116,7 @@ int setup_armature_weakrefs() *support for packages here e.g. import `package.module` */ static struct _inittab BPy_Inittab_Modules[] = { {"Blender", M_Blender_Init}, + {"bpy", M_BPy_Init}, {NULL, NULL} }; @@ -1972,8 +1973,9 @@ void init_ourImport( void ) m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); - /* add in "bpy" as a default module */ - PyDict_SetItemString(d, "bpy", Main_Init() ); + /* add in "bpy" as a default module + * This has been disabled, import like Blender*/ + /*PyDict_SetItemString(d, "bpy", M_BPy_Init() );*/ EXPP_dict_set_item_str( d, "__import__", import ); } diff --git a/source/blender/python/api2_2x/Main.c b/source/blender/python/api2_2x/BPyModule.c similarity index 81% rename from source/blender/python/api2_2x/Main.c rename to source/blender/python/api2_2x/BPyModule.c index 276d0b04660..6a49aa56a79 100644 --- a/source/blender/python/api2_2x/Main.c +++ b/source/blender/python/api2_2x/BPyModule.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" /* for MEM_callocN */ #include "DNA_space_types.h" /* SPACE_VIEW3D, SPACE_SEQ */ #include "DNA_scene_types.h" -#include "DNA_object_types.h" /* MainSeq_new */ +#include "DNA_object_types.h" /* LibBlockSeq_new */ #include "DNA_texture_types.h" #include "DNA_curve_types.h" #include "DNA_ipo_types.h" @@ -103,7 +103,7 @@ #include "Text.h" #include "Sound.h" #include "NLA.h" -#include "Main.h" +#include "BPyModule.h" #include "Scene.h" #include "Library.h" @@ -115,22 +115,22 @@ #include "DNA_screen_types.h" -static PyObject *MainSeq_CreatePyObject( Link *iter, int type ) +static PyObject *LibBlockSeq_CreatePyObject( Link *iter, int type ) { - BPy_MainSeq *seq = PyObject_NEW( BPy_MainSeq, &MainSeq_Type); + BPy_LibBlockSeq *seq = PyObject_NEW( BPy_LibBlockSeq, &LibBlockSeq_Type); seq->iter = iter; seq->type = type; return (PyObject *)seq; } -static int MainSeq_len( BPy_MainSeq * self ) +static int LibBlockSeq_len( BPy_LibBlockSeq * self ) { ListBase *lb = wich_libbase(G.main, self->type); return BLI_countlist( lb ); } -static PyObject * MainSeq_subscript(BPy_MainSeq * self, PyObject *key) +static PyObject * LibBlockSeq_subscript(BPy_LibBlockSeq * self, PyObject *key) { char *name; char *lib= NULL; @@ -188,16 +188,16 @@ static PyObject * MainSeq_subscript(BPy_MainSeq * self, PyObject *key) ( PyExc_KeyError, "Requested data does not exist") ); } -static PyMappingMethods MainSeq_as_mapping = { - ( inquiry ) MainSeq_len, /* mp_length */ - ( binaryfunc ) MainSeq_subscript, /* mp_subscript */ +static PyMappingMethods LibBlockSeq_as_mapping = { + ( inquiry ) LibBlockSeq_len, /* mp_length */ + ( binaryfunc ) LibBlockSeq_subscript, /* mp_subscript */ ( objobjargproc ) 0, /* mp_ass_subscript */ }; /************************************************************************ * - * Python MainSeq_Type iterator (iterates over GroupObjects) + * Python LibBlockSeq_Type iterator (iterates over GroupObjects) * ************************************************************************/ @@ -205,7 +205,7 @@ static PyMappingMethods MainSeq_as_mapping = { * Initialize the interator index */ -static PyObject *MainSeq_getIter( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_getIter( BPy_LibBlockSeq * self ) { /* we need to get the first base, but for selected context we may need to advance to the first selected or first conext base */ @@ -221,15 +221,15 @@ static PyObject *MainSeq_getIter( BPy_MainSeq * self ) self->iter = link; return EXPP_incr_ret ( (PyObject *) self ); } else { - return MainSeq_CreatePyObject(link, self->type); + return LibBlockSeq_CreatePyObject(link, self->type); } } /* - * Return next MainOb. + * Return next LibBlockSeq iter. */ -static PyObject *MainSeq_nextIter( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_nextIter( BPy_LibBlockSeq * self ) { PyObject *object; Link *link; @@ -246,7 +246,7 @@ static PyObject *MainSeq_nextIter( BPy_MainSeq * self ) return object; } -PyObject *MainSeq_getActive(BPy_MainSeq *self) +PyObject *LibBlockSeq_getActive(BPy_LibBlockSeq *self) { switch (self->type) { case ID_SCE: @@ -280,7 +280,7 @@ PyObject *MainSeq_getActive(BPy_MainSeq *self) "Only Scene and Image types have the active attribute" ); } -static int MainSeq_setActive(BPy_MainSeq *self, PyObject *value) +static int LibBlockSeq_setActive(BPy_LibBlockSeq *self, PyObject *value) { switch (self->type) { case ID_SCE: @@ -350,7 +350,7 @@ static int MainSeq_setActive(BPy_MainSeq *self, PyObject *value) "Only Scene and Image types have the active attribute" ); } -static int MainSeq_setTag(BPy_MainSeq *self, PyObject *value) +static int LibBlockSeq_setTag(BPy_LibBlockSeq *self, PyObject *value) { int param = PyObject_IsTrue( value ); ID *id; @@ -390,7 +390,7 @@ Mesh *add_mesh__internal(char *name) } /* used for new and load */ -PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args, PyObject *kwd) +PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) { ID *id = NULL; char *name=NULL, *filename=NULL, *ipo_type; @@ -581,7 +581,7 @@ PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args, PyObject *kwd) } -PyObject *MainSeq_unlink(BPy_MainSeq *self, PyObject * args) +PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) { PyObject *pyobj; @@ -660,7 +660,7 @@ PyObject *MainSeq_unlink(BPy_MainSeq *self, PyObject * args) "Only types Scene, Group and Text can unlink" ); } -static int MainSeq_compare( BPy_MainSeq * a, BPy_MainSeq * b ) +static int LibBlockSeq_compare( BPy_LibBlockSeq * a, BPy_LibBlockSeq * b ) { return ( a->type == b->type) ? 0 : -1; } @@ -669,40 +669,40 @@ static int MainSeq_compare( BPy_MainSeq * a, BPy_MainSeq * b ) * repr function * callback functions building meaninful string to representations */ -static PyObject *MainSeq_repr( BPy_MainSeq * self ) +static PyObject *LibBlockSeq_repr( BPy_LibBlockSeq * self ) { - return PyString_FromFormat( "[Main Iterator]"); + return PyString_FromFormat( "[LibBlockSeq Iterator]"); } -static PyGetSetDef MainSeq_getseters[] = { +static PyGetSetDef LibBlockSeq_getseters[] = { {"active", - (getter)MainSeq_getActive, (setter)MainSeq_setActive, + (getter)LibBlockSeq_getActive, (setter)LibBlockSeq_setActive, "active object", NULL}, {"tag", - (getter)NULL, (setter)MainSeq_setTag, + (getter)NULL, (setter)LibBlockSeq_setTag, "tag all data in True or False (write only)", NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; -static struct PyMethodDef BPy_MainSeq_methods[] = { - {"new", (PyCFunction)MainSeq_new, METH_VARARGS | METH_KEYWORDS, +static struct PyMethodDef BPy_LibBlockSeq_methods[] = { + {"new", (PyCFunction)LibBlockSeq_new, METH_VARARGS | METH_KEYWORDS, "(name) - Create a new object in this scene from the obdata given and return a new object"}, - {"unlink", (PyCFunction)MainSeq_unlink, METH_VARARGS, + {"unlink", (PyCFunction)LibBlockSeq_unlink, METH_VARARGS, "unlinks the object from the scene"}, {NULL, NULL, 0, NULL} }; /*****************************************************************************/ -/* Python MainSeq_Type structure definition: */ +/* Python LibBlockSeq_Type structure definition: */ /*****************************************************************************/ -PyTypeObject MainSeq_Type = { +PyTypeObject LibBlockSeq_Type = { PyObject_HEAD_INIT( NULL ) /* required py macro */ 0, /* ob_size */ /* For printing, in format "." */ - "Blender MainSeq", /* char *tp_name; */ - sizeof( BPy_MainSeq ), /* int tp_basicsize; */ + "Blender LibBlockSeq", /* char *tp_name; */ + sizeof( BPy_LibBlockSeq ), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ /* Methods to implement standard operations */ @@ -711,14 +711,14 @@ PyTypeObject MainSeq_Type = { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - ( cmpfunc ) MainSeq_compare, /* cmpfunc tp_compare; */ - ( reprfunc ) MainSeq_repr, /* reprfunc tp_repr; */ + ( cmpfunc ) LibBlockSeq_compare, /* cmpfunc tp_compare; */ + ( reprfunc ) LibBlockSeq_repr, /* reprfunc tp_repr; */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ NULL, /* PySequenceMethods *tp_as_sequence; */ - &MainSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &LibBlockSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ @@ -751,13 +751,13 @@ PyTypeObject MainSeq_Type = { /*** Added in release 2.2 ***/ /* Iterators */ - ( getiterfunc) MainSeq_getIter, /* getiterfunc tp_iter; */ - ( iternextfunc ) MainSeq_nextIter, /* iternextfunc tp_iternext; */ + ( getiterfunc) LibBlockSeq_getIter, /* getiterfunc tp_iter; */ + ( iternextfunc ) LibBlockSeq_nextIter, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - BPy_MainSeq_methods, /* struct PyMethodDef *tp_methods; */ + BPy_LibBlockSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - MainSeq_getseters, /* struct PyGetSetDef *tp_getset; */ + LibBlockSeq_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -780,50 +780,46 @@ PyTypeObject MainSeq_Type = { }; -/*-----------------------Main module Init())-----------------------------*/ +/*-----------------------------BPy module Init())-----------------------------*/ -static char M_Main_doc[] = "The Blender.Main submodule"; +static char M_BPy_Init_doc[] = "The bpy module"; -PyObject *Main_Init( void ) +void M_BPy_Init( void ) { - PyObject *submodule; + PyObject *module; PyObject *dict; - - - if( PyType_Ready( &MainSeq_Type ) < 0 ) - return NULL; - if( PyType_Ready( &Config_Type ) < 0 ) /* see Config.c */ - return NULL; - submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc ); - dict = PyModule_GetDict( submodule ); + + PyType_Ready( &LibBlockSeq_Type ); + PyType_Ready( &Config_Type ); + + /*submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc );*/ + module = Py_InitModule3( "bpy", NULL, M_BPy_Init_doc ); + dict = PyModule_GetDict( module ); PyDict_SetItemString( dict, "libraries", Library_Init( ) ); - /* Python Data Types */ - PyModule_AddObject( submodule, "scenes", MainSeq_CreatePyObject(NULL, ID_SCE) ); - PyModule_AddObject( submodule, "objects", MainSeq_CreatePyObject(NULL, ID_OB) ); - PyModule_AddObject( submodule, "meshes", MainSeq_CreatePyObject(NULL, ID_ME) ); - PyModule_AddObject( submodule, "curves", MainSeq_CreatePyObject(NULL, ID_CU) ); - PyModule_AddObject( submodule, "metaballs", MainSeq_CreatePyObject(NULL, ID_MB) ); - PyModule_AddObject( submodule, "materials", MainSeq_CreatePyObject(NULL, ID_MA) ); - PyModule_AddObject( submodule, "textures", MainSeq_CreatePyObject(NULL, ID_TE) ); - PyModule_AddObject( submodule, "images", MainSeq_CreatePyObject(NULL, ID_IM) ); - PyModule_AddObject( submodule, "lattices", MainSeq_CreatePyObject(NULL, ID_LT) ); - PyModule_AddObject( submodule, "lamps", MainSeq_CreatePyObject(NULL, ID_LA) ); - PyModule_AddObject( submodule, "cameras", MainSeq_CreatePyObject(NULL, ID_CA) ); - PyModule_AddObject( submodule, "ipos", MainSeq_CreatePyObject(NULL, ID_IP) ); - PyModule_AddObject( submodule, "worlds", MainSeq_CreatePyObject(NULL, ID_WO) ); - PyModule_AddObject( submodule, "fonts", MainSeq_CreatePyObject(NULL, ID_VF) ); - PyModule_AddObject( submodule, "texts", MainSeq_CreatePyObject(NULL, ID_TXT) ); - PyModule_AddObject( submodule, "sounds", MainSeq_CreatePyObject(NULL, ID_SO) ); - PyModule_AddObject( submodule, "groups", MainSeq_CreatePyObject(NULL, ID_GR) ); - PyModule_AddObject( submodule, "armatures", MainSeq_CreatePyObject(NULL, ID_AR) ); - PyModule_AddObject( submodule, "actions", MainSeq_CreatePyObject(NULL, ID_AC) ); + PyModule_AddObject( module, "scenes", LibBlockSeq_CreatePyObject(NULL, ID_SCE) ); + PyModule_AddObject( module, "objects", LibBlockSeq_CreatePyObject(NULL, ID_OB) ); + PyModule_AddObject( module, "meshes", LibBlockSeq_CreatePyObject(NULL, ID_ME) ); + PyModule_AddObject( module, "curves", LibBlockSeq_CreatePyObject(NULL, ID_CU) ); + PyModule_AddObject( module, "metaballs", LibBlockSeq_CreatePyObject(NULL, ID_MB) ); + PyModule_AddObject( module, "materials", LibBlockSeq_CreatePyObject(NULL, ID_MA) ); + PyModule_AddObject( module, "textures", LibBlockSeq_CreatePyObject(NULL, ID_TE) ); + PyModule_AddObject( module, "images", LibBlockSeq_CreatePyObject(NULL, ID_IM) ); + PyModule_AddObject( module, "lattices", LibBlockSeq_CreatePyObject(NULL, ID_LT) ); + PyModule_AddObject( module, "lamps", LibBlockSeq_CreatePyObject(NULL, ID_LA) ); + PyModule_AddObject( module, "cameras", LibBlockSeq_CreatePyObject(NULL, ID_CA) ); + PyModule_AddObject( module, "ipos", LibBlockSeq_CreatePyObject(NULL, ID_IP) ); + PyModule_AddObject( module, "worlds", LibBlockSeq_CreatePyObject(NULL, ID_WO) ); + PyModule_AddObject( module, "fonts", LibBlockSeq_CreatePyObject(NULL, ID_VF) ); + PyModule_AddObject( module, "texts", LibBlockSeq_CreatePyObject(NULL, ID_TXT) ); + PyModule_AddObject( module, "sounds", LibBlockSeq_CreatePyObject(NULL, ID_SO) ); + PyModule_AddObject( module, "groups", LibBlockSeq_CreatePyObject(NULL, ID_GR) ); + PyModule_AddObject( module, "armatures", LibBlockSeq_CreatePyObject(NULL, ID_AR) ); + PyModule_AddObject( module, "actions", LibBlockSeq_CreatePyObject(NULL, ID_AC) ); /* Other Types */ - PyModule_AddObject( submodule, "config", Config_CreatePyObject() ); - - return submodule; + PyModule_AddObject( module, "config", Config_CreatePyObject() ); } diff --git a/source/blender/python/api2_2x/Main.h b/source/blender/python/api2_2x/BPyModule.h similarity index 87% rename from source/blender/python/api2_2x/Main.h rename to source/blender/python/api2_2x/BPyModule.h index f1dd6c0782e..ea11cce9810 100644 --- a/source/blender/python/api2_2x/Main.h +++ b/source/blender/python/api2_2x/BPyModule.h @@ -1,5 +1,4 @@ /* - * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -30,16 +29,16 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -#ifndef EXPP_MAIN_H -#define EXPP_MAIN_H +#ifndef EXPP_BPYMODULE_H +#define EXPP_BPYMODULE_H #include /* The Main PyType Object defined in Main.c */ -extern PyTypeObject MainSeq_Type; +extern PyTypeObject LibBlockSeq_Type; -#define BPy_MainSeq_Check(v) \ - ((v)->ob_type == &MainSeq_Type) +#define BPy_LibBlockSeq_Check(v) \ + ((v)->ob_type == &LibBlockSeq_Type) /* Main sequence, iterate on the libdatas listbase*/ typedef struct { @@ -47,9 +46,9 @@ typedef struct { Link *iter; /* so we can iterate over the listbase */ short type; /* store the ID type such as ID_ME */ -} BPy_MainSeq; +} BPy_LibBlockSeq; -PyObject *Main_Init( void ); +void M_BPy_Init( void ); #endif /* EXPP_MAIN_H */ diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index d940b6eb2c7..9423eb27c5c 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -93,7 +93,6 @@ struct ID; /*keep me up here */ #include "Window.h" #include "World.h" #include "Types.h" -#include "Main.h" /**********************************************************/ /* Python API function prototypes for the Blender module. */ @@ -987,6 +986,5 @@ void M_Blender_Init(void) PyDict_SetItemString(dict, "Texture", Texture_Init()); PyDict_SetItemString(dict, "Window", Window_Init()); PyDict_SetItemString(dict, "World", World_Init()); - PyDict_SetItemString(dict, "Main", Main_Init()); } diff --git a/source/blender/python/api2_2x/doc/API_intro.py b/source/blender/python/api2_2x/doc/API_intro.py index dbc8e13e7d5..4e2c71f3afc 100644 --- a/source/blender/python/api2_2x/doc/API_intro.py +++ b/source/blender/python/api2_2x/doc/API_intro.py @@ -12,7 +12,7 @@ The Blender Python API Reference ----------- - L{Blender} - - L{bpy} (automatically imported) + - L{bpy} Submodules: ----------- diff --git a/source/blender/python/api2_2x/doc/Bpy.py b/source/blender/python/api2_2x/doc/Bpy.py index 25eca7ab6a8..ef755c64976 100644 --- a/source/blender/python/api2_2x/doc/Bpy.py +++ b/source/blender/python/api2_2x/doc/Bpy.py @@ -60,10 +60,10 @@ Example:: import os sound_dir = '/home/me/soundfiles/' sounds_new = [] - for filename in os.listdir(sound_dir): - if filename.lower().endswith('.wav'): + for fname in os.listdir(sound_dir): + if fname.lower().endswith('.wav'): try: - snd = bpy.sounds.load(sound_dir + filename) + snd = bpy.sounds.new(filename = sound_dir + fname) except: snd = None @@ -93,50 +93,50 @@ Example:: Window.RedrawAll() @var scenes: iterator for L{scene} data -@type scenes: L{dataIterator} +@type scenes: L{LibBlockSeq} @var objects: iterator for L{object} data -@type objects: L{dataIterator} +@type objects: L{LibBlockSeq} @var meshes: iterator for L{mesh} data -@type meshes: L{dataIterator} +@type meshes: L{LibBlockSeq} @var curves: iterator for L{curve} data -@type curves: L{dataIterator} +@type curves: L{LibBlockSeq} @var metaballs: iterator for L{metaball} data -@type metaballs: L{dataIterator} +@type metaballs: L{LibBlockSeq} @var materials: iterator for L{material} data -@type materials: L{dataIterator} +@type materials: L{LibBlockSeq} @var textures: iterator for L{texture} data -@type textures: L{dataIterator} +@type textures: L{LibBlockSeq} @var images: iterator for L{image} data -@type images: L{dataIterator} +@type images: L{LibBlockSeq} @var lattices: iterator for L{lattice} data -@type lattices: L{dataIterator} +@type lattices: L{LibBlockSeq} @var lamps: iterator for L{lamp} data -@type lamps: L{dataIterator} +@type lamps: L{LibBlockSeq} @var cameras: iterator for L{camera} data -@type cameras: L{dataIterator} +@type cameras: L{LibBlockSeq} @var ipos: iterator for L{ipo} data -@type ipos: L{dataIterator} +@type ipos: L{LibBlockSeq} @var worlds: iterator for L{world} data -@type worlds: L{dataIterator} +@type worlds: L{LibBlockSeq} @var fonts: iterator for L{font} data -@type fonts: L{dataIterator} +@type fonts: L{LibBlockSeq} @var texts: iterator for L{text} data -@type texts: L{dataIterator} +@type texts: L{LibBlockSeq} @var sounds: iterator for L{sound} data -@type sounds: L{dataIterator} +@type sounds: L{LibBlockSeq} @var groups: iterator for L{group} data -@type groups: L{dataIterator} +@type groups: L{LibBlockSeq} @var armatures: iterator for L{armature} data -@type armatures: L{dataIterator} +@type armatures: L{LibBlockSeq} @var actions: iterator for L{action} data -@type actions: L{dataIterator} -@var libraries: L{New library} submodule -@type libraries: L{New library} +@type actions: L{LibBlockSeq} +@var libraries: L{librarySeq} submodule +@type libraries: L{librarySeq} """ -class dataIterator: +class LibBlockSeq: """ Generic Data Access =================== @@ -208,21 +208,28 @@ class dataIterator: - L{texts} This can also be used to set the active data. - >>> bpy.images.active = bpy.images.load('/home/me/someimage.jpg') + >>> bpy.images.active = bpy.images.new(filename = '/home/me/someimage.jpg') """ - def new(name): + def new(name="", filename=""): """ - This function returns a new datablock + This function returns a new datablock containing no data or loaded from a file. Exceptions ========== - - Images optionally accept 2 extra arguments: bpy.images.new(name, width=256, height=256) + + Use the filename keyword string values to load data from a file, this works with L{images}, L{texts}, L{sounds}, L{fonts} only. + + >>> sound = bpy.sounds.new('newsound', '~/mysound.wav') # uses the first string given for the name. + + >>> sound = bpy.sounds.new(filename = '~/mysound.wav') # will use the filename to make the name. + + + Images optionally accept 3 arguments: bpy.images.new(name, width=256, height=256) The width and height must br between 4 and 5000 if no args are given they will be 256. - Ipos need 2 arguments: bpy.ipos.new(name, type) type must be a string can be + Ipos need 2 arguments: bpy.ipos.new(name, type) type must be a string (use in place of filename) can be... - 'Camera' - 'World' - 'Material' @@ -243,17 +250,6 @@ class dataIterator: @rtype: datablock """ - - def load(filename): - """ - This function loads a new datablock from a file. - applies to: - - L{fonts} - - L{sounds} - - L{images} - Other types will raise an error. - @rtype: datablock - """ def unlink(datablock): """