From 30fb777971de40db481074e4ac3ab3de6502d8f3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 27 Mar 2007 14:49:37 +0000 Subject: [PATCH] py api bpy.*libBlickSeq*.new() - name is now an optiona arg. moved some more scripts to bpy.* api. --- release/scripts/3ds_import.py | 28 ++++++++--------------- release/scripts/bpymodules/BPyImage.py | 10 ++++---- release/scripts/bvh_import.py | 21 ++++++----------- release/scripts/import_obj.py | 11 +++++---- source/blender/python/api2_2x/BPyModule.c | 4 ++-- source/blender/python/api2_2x/doc/Bpy.py | 5 +++- 6 files changed, 34 insertions(+), 45 deletions(-) diff --git a/release/scripts/3ds_import.py b/release/scripts/3ds_import.py index 6cec591ac4f..2931e45c274 100644 --- a/release/scripts/3ds_import.py +++ b/release/scripts/3ds_import.py @@ -143,7 +143,7 @@ BOUNDS_3DS= [] #which shold be more useful. def createBlenderTexture(material, name, image): - texture= Texture.New(name) + texture= bpy.textures.new(name) texture.setType('Image') texture.image= image material.setTexture(0, texture, Texture.TexCo.UV, Texture.MapTo.COL) @@ -365,8 +365,8 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): vertsToUse = [i for i in xrange(len(myContextMesh_vertls)) if faceVertUsers[i]] myVertMapping = dict( [ (ii, i) for i, ii in enumerate(vertsToUse) ] ) - ##bmesh = Mesh.New(contextMesh.name) - bmesh = Mesh.New() + tempName= '%s_%s' % (contextObName, matName) # matName may be None. + bmesh = bpy.meshes.new(tempName) if matName == None: img= None @@ -398,12 +398,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): if img: targetFace.image= img - tempName= '%s_%s' % (contextObName, matName) # matName may be None. - bmesh.name= tempName - # bmesh.transform(contextMatrix) - # ob = Object.New('Mesh', tempName) - # ob.link(bmesh) ob = SCN_OBJECTS.new(bmesh, tempName) ''' if contextMatrix_tx: @@ -466,7 +461,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): #is it a material chunk? elif (new_chunk.ID==MATERIAL): #print 'elif (new_chunk.ID==MATERIAL):' - contextMaterial= Material.New() + contextMaterial= bpy.materials.new('Material') elif (new_chunk.ID==MAT_NAME): #print 'elif (new_chunk.ID==MAT_NAME):' @@ -525,7 +520,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): elif (new_chunk.ID==MAT_TEXTURE_MAP): #print 'elif (new_chunk.ID==MAT_TEXTURE_MAP):' - new_texture= Blender.Texture.New('Diffuse') + new_texture= bpy.textures.new('Diffuse') new_texture.setType('Image') img = None while (new_chunk.bytes_readtype == ID_IM) { /* Image, accepts width and height*/ - if( !PyArg_ParseTuple( args, "s|ii", &name, &img_width, &img_height ) ) + if( !PyArg_ParseTuple( args, "|sii", &name, &img_width, &img_height ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "one string and two ints expected as arguments" ); CLAMP(img_width, 4, 5000); @@ -497,7 +497,7 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) } else { /* Other types only need the name */ - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !PyArg_ParseTuple( args, "|s", &name ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "new(name) - name must be a string argument" ); } diff --git a/source/blender/python/api2_2x/doc/Bpy.py b/source/blender/python/api2_2x/doc/Bpy.py index 8ba9ef20469..8f95a84dbe5 100644 --- a/source/blender/python/api2_2x/doc/Bpy.py +++ b/source/blender/python/api2_2x/doc/Bpy.py @@ -132,7 +132,6 @@ Example:: @type actions: L{libBlockSeq} @var libraries: L{librarySeq} submodule @type libraries: L{librarySeq} - """ @@ -218,6 +217,10 @@ class libBlockSeq: Most datatypes accept a name for their argument except for L{sounds}, L{fonts}, L{ipos} and L{curves} that need an additional argument. + The name argument is optional if not given a default name will be assigned. + + The name given may be modified by blender to make it unique. + Loading From File ================= For L{images}, L{texts}, L{sounds}, L{fonts} types you can use the filename keyword to make a new datablock from a file.