diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 23:44:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 23:44:44 +0400 |
commit | 2b8bed8598004683bb20efad6e9bd15243ad2d24 (patch) | |
tree | 740c4ad4f81b7c2ad5a06f89514cf1a044b4a2cc /release | |
parent | e968f6ec4bdfdacb1148340c137e2a50ce740139 (diff) |
py api
* stopped bpy from importing automaticaly as decieded in the meeting.
* removed Blender.Main, since we agree it will be called bpy, renamed files also.
* updated epydocs from this and last commit.
* updated scripts to use bpy.*, and bugfix's for widgetwizard
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/3ds_export.py | 3 | ||||
-rw-r--r-- | release/scripts/3ds_import.py | 5 | ||||
-rw-r--r-- | release/scripts/armature_symmetry.py | 4 | ||||
-rw-r--r-- | release/scripts/bpymodules/BPyMesh.py | 6 | ||||
-rw-r--r-- | release/scripts/bpymodules/BPyMesh_redux.py | 3 | ||||
-rw-r--r-- | release/scripts/bvh_import.py | 7 | ||||
-rw-r--r-- | release/scripts/console.py | 3 | ||||
-rw-r--r-- | release/scripts/mesh_skin.py | 3 | ||||
-rw-r--r-- | release/scripts/mesh_solidify.py | 3 | ||||
-rw-r--r-- | release/scripts/object_apply_def.py | 3 | ||||
-rw-r--r-- | release/scripts/object_batch_name_edit.py | 3 | ||||
-rw-r--r-- | release/scripts/uvcalc_follow_active_coords.py | 4 | ||||
-rw-r--r-- | release/scripts/uvcalc_from_adjacent.py | 4 | ||||
-rw-r--r-- | release/scripts/uvcalc_lightmap.py | 3 | ||||
-rw-r--r-- | release/scripts/uvcalc_quad_clickproj.py | 3 | ||||
-rw-r--r-- | release/scripts/uvcalc_smart_project.py | 33 | ||||
-rw-r--r-- | release/scripts/widgetwizard.py | 262 |
17 files changed, 170 insertions, 182 deletions
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 "" |