forked from bartvdbraak/blender
Mech cleanup use new edge_keys
continual script stuff, minor stuff.. fix for bad return in group. Added back group.objects.append/remove but print deprectaed warning. also some epydoc changes.
This commit is contained in:
parent
c063e01f06
commit
ab06e52343
@ -808,7 +808,7 @@ def load_3ds(filename, PREF_UI= True):
|
||||
|
||||
'''
|
||||
for ob in importedObjects:
|
||||
if ob.getType()=='Mesh':
|
||||
if ob.type=='Mesh':
|
||||
me= ob.getData(mesh=1)
|
||||
me.verts.delete([me.verts[0],])
|
||||
'''
|
||||
|
@ -246,9 +246,9 @@ def main():
|
||||
'''
|
||||
|
||||
scn= Scene.GetCurrent()
|
||||
arm_ob= scn.getActiveObject()
|
||||
arm_ob= scn.objects.active
|
||||
|
||||
if not arm_ob or arm_ob.getType()!='Armature':
|
||||
if not arm_ob or arm_ob.type!='Armature':
|
||||
Blender.Draw.PupMenu('No Armature object selected.')
|
||||
return
|
||||
|
||||
|
@ -70,8 +70,8 @@ old_dist = None
|
||||
|
||||
def act_mesh_ob():
|
||||
scn = Scene.GetCurrent()
|
||||
ob = scn.getActiveObject()
|
||||
if ob == None or ob.getType() != 'Mesh':
|
||||
ob = scn.objects.active
|
||||
if ob == None or ob.type != 'Mesh':
|
||||
PupMenu('ERROR%t|Select a mesh object.')
|
||||
return
|
||||
return ob
|
||||
|
@ -394,7 +394,7 @@ def getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=Tru
|
||||
mesh.verts= None
|
||||
|
||||
|
||||
type = ob.getType()
|
||||
type = ob.type
|
||||
dataname = ob.getData(1)
|
||||
tempob= None
|
||||
if apply_modifiers or type != 'Mesh':
|
||||
|
@ -279,7 +279,7 @@ def ExportToIv(file_name):
|
||||
#elif obtype == "Camera":
|
||||
# cameras.append(object);
|
||||
#else:
|
||||
# print "Exporting %s objects isn't supported!" % object.getType()
|
||||
# print "Exporting %s objects isn't supported!" % object.type
|
||||
|
||||
# write header, footer and groups of object types
|
||||
WriteHeader(file);
|
||||
|
@ -89,9 +89,9 @@ def selSameWeights(me, PREF_TOLERENCE):
|
||||
|
||||
def main():
|
||||
scn= Scene.GetCurrent()
|
||||
ob= scn.getActiveObject()
|
||||
ob= scn.objects.active
|
||||
|
||||
if not ob or ob.getType() != 'Mesh':
|
||||
if not ob or ob.type != 'Mesh':
|
||||
Draw.PupMenu('Error, no active mesh object, aborting.')
|
||||
return
|
||||
|
||||
@ -99,7 +99,6 @@ def main():
|
||||
|
||||
PREF_TOLERENCE= Draw.Create(0.1)
|
||||
|
||||
|
||||
pup_block= [\
|
||||
('Tolerence:', PREF_TOLERENCE, 0.01, 1.0, 'Tolerence for selecting faces of the same weight.'),\
|
||||
]
|
||||
|
@ -253,7 +253,7 @@ class Node:
|
||||
def blender_export(self, level=[0]):
|
||||
if self.object:
|
||||
if options.verbose >= 2:
|
||||
print '\t' * level[0], self.name, self.object.getType()
|
||||
print '\t' * level[0], self.name, self.object.type
|
||||
|
||||
level[0] += 1
|
||||
|
||||
@ -294,7 +294,7 @@ class Node:
|
||||
self.header = header
|
||||
self.object = object
|
||||
if object:
|
||||
self.name = self.object.getName()
|
||||
self.name = self.object.name
|
||||
self.matrix = self.object.getMatrix('localspace')
|
||||
else:
|
||||
self.name = 'no name'
|
||||
@ -320,7 +320,7 @@ class Node:
|
||||
# Spawn children.
|
||||
self.has_object_child = False # For Database class.
|
||||
for child in self.child_objects:
|
||||
if child.getType() == 'Mesh':
|
||||
if child.type == 'Mesh':
|
||||
BlenderMesh(self, header, child, left_over)
|
||||
self.has_object_child = True
|
||||
else: # Treat all non meshes as emptys
|
||||
@ -371,7 +371,7 @@ class BlenderMesh(Node):
|
||||
|
||||
# Gather Material
|
||||
mat_desc = MaterialDesc()
|
||||
mat_desc.name = mat.getName()
|
||||
mat_desc.name = mat.name
|
||||
mat_desc.alpha = mat.getAlpha()
|
||||
mat_desc.shininess = mat.getSpec() * 64.0 # 2.0 => 128.0
|
||||
if options.use_mat_color:
|
||||
|
@ -1835,8 +1835,8 @@ def select_file(filename):
|
||||
|
||||
# FIX UP AFTER DUMMY VERT AND REMOVE DOUBLES
|
||||
Blender.Mesh.Mode(Blender.Mesh.SelectModes['VERTEX'])
|
||||
for ob in Blender.Object.GetSelected():
|
||||
if ob.getType()=='Mesh':
|
||||
for ob in scene.objects.context:
|
||||
if ob.type=='Mesh':
|
||||
me=ob.getData(mesh=1)
|
||||
me.verts.delete(0) # remove the dummy vert
|
||||
me.sel= 1
|
||||
|
@ -384,9 +384,9 @@ def auto_layout_tex(mesh_list, scn, PREF_IMAGE_PATH, PREF_IMAGE_SIZE, PREF_KEEP_
|
||||
|
||||
def main():
|
||||
scn= B.Scene.GetCurrent()
|
||||
ob= scn.getActiveObject()
|
||||
ob= scn.objects.active
|
||||
|
||||
if not ob or ob.getType() != 'Mesh':
|
||||
if not ob or ob.type != 'Mesh':
|
||||
B.Draw.PupMenu('Error, no active mesh object, aborting.')
|
||||
return
|
||||
|
||||
|
@ -216,17 +216,16 @@ def main():
|
||||
PREF_NO_XCROSS= PREF_NO_XCROSS.val
|
||||
quality= PREF_QUALITY.val
|
||||
|
||||
act_ob= scn.getActiveObject()
|
||||
act_ob= scn.objects.active
|
||||
if PREF_SEL_ONLY and act_ob==None:
|
||||
Blender.Draw.PupMenu('Error%t|When dealing with 2 or more meshes with vgroups|There must be an active object|to be used as a source|aborting.')
|
||||
return
|
||||
|
||||
sel=[]
|
||||
from_data= None
|
||||
act_ob= scn.getActiveObject()
|
||||
|
||||
for ob in contextSel:
|
||||
|
||||
if ob.getType()=='Mesh':
|
||||
if ob.type=='Mesh':
|
||||
me= ob.getData(mesh=1)
|
||||
groups= me.getVertGroupNames()
|
||||
|
||||
@ -242,7 +241,7 @@ def main():
|
||||
_ob.sel=0
|
||||
ob.sel=1
|
||||
Object.Duplicate(mesh=1)
|
||||
ob= scn.getActiveObject()
|
||||
ob= scn.objects.active
|
||||
me= ob.getData(mesh=1)
|
||||
# groups will be the same
|
||||
print '\tGenerating higher %ix quality weights.' % quality
|
||||
@ -262,7 +261,6 @@ def main():
|
||||
t= Blender.sys.time()
|
||||
Window.WaitCursor(1)
|
||||
|
||||
|
||||
# Now do the copy.
|
||||
print '\tCopying from "%s" to %i other mesh(es).' % (from_data[0].name, len(sel))
|
||||
for data in sel:
|
||||
|
@ -64,26 +64,20 @@ def rem_free_verts(me):
|
||||
|
||||
def rem_free_edges(me, limit=None):
|
||||
''' Only remove based on limit if a limit is set, else remove all '''
|
||||
def sortPair(a,b):
|
||||
if a>b:
|
||||
return b,a
|
||||
else:
|
||||
return a,b
|
||||
|
||||
edgeDict= {} # will use a set when python 2.4 is standard.
|
||||
|
||||
for f in me.faces:
|
||||
fidxs= [v.index for v in f.v]
|
||||
for i in xrange(len(fidxs)):
|
||||
edgeDict[sortPair(fidxs[i], fidxs[i-1])]= None
|
||||
for edkey in f.edge_keys:
|
||||
edgeDict[edkey] = None
|
||||
|
||||
edges_free= []
|
||||
for e in me.edges:
|
||||
if not edgeDict.has_key(sortPair(e.v1.index, e.v2.index)):
|
||||
if not edgeDict.has_key(e.key):
|
||||
edges_free.append(e)
|
||||
|
||||
if limit != None:
|
||||
edges_free= [e for e in edges_free if (e.v1.co-e.v2.co).length <= limit]
|
||||
edges_free= [e for e in edges_free if e.length <= limit]
|
||||
|
||||
me.edges.delete(edges_free)
|
||||
return len(edges_free)
|
||||
@ -196,8 +190,8 @@ def normalize_vweight(me, groupNames, vWeightDict):
|
||||
|
||||
def main():
|
||||
scn= Scene.GetCurrent()
|
||||
obsel= Object.GetSelected()
|
||||
actob= scn.getActiveObject()
|
||||
obsel= list(scn.objects.context)
|
||||
actob= scn.objects.active
|
||||
|
||||
is_editmode= Window.EditMode()
|
||||
|
||||
@ -262,11 +256,11 @@ def main():
|
||||
if CLEAN_ALL_DATA:
|
||||
if CLEAN_GROUP or CLEAN_VWEIGHT or CLEAN_WEIGHT_NORMALIZE:
|
||||
# For groups we need the objects linked to the mesh
|
||||
meshes= [ob.getData(mesh=1) for ob in Object.Get() if ob.getType() == 'Mesh']
|
||||
meshes= [ob.getData(mesh=1) for ob in Object.Get() if ob.type == 'Mesh']
|
||||
else:
|
||||
meshes= Mesh.Get()
|
||||
else:
|
||||
meshes= [ob.getData(mesh=1) for ob in obsel if ob.getType() == 'Mesh']
|
||||
meshes= [ob.getData(mesh=1) for ob in obsel if ob.type == 'Mesh']
|
||||
|
||||
rem_face_count= rem_edge_count= rem_vert_count= rem_material_count= rem_group_count= rem_vweight_count= 0
|
||||
|
||||
|
@ -262,7 +262,7 @@ static PyObject *Group_getFakeUser( BPy_Group * self )
|
||||
|
||||
static int Group_setFakeUser( BPy_Group * self, PyObject * value )
|
||||
{
|
||||
GROUP_DEL_CHECK_PY(self);
|
||||
GROUP_DEL_CHECK_INT(self);
|
||||
return SetIdFakeUser(&self->group->id, value);
|
||||
}
|
||||
|
||||
@ -803,6 +803,11 @@ static PyObject *GroupObSeq_link( BPy_GroupObSeq * self, PyObject *args )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *GroupObSeq_append( BPy_GroupObSeq * self, PyObject *args )
|
||||
{
|
||||
printf("WARNING: grp.objects.append() has been deprecated, use grp.objects.link() instead.\nBlender releases after 2.43 will not support .append()");
|
||||
return GroupObSeq_link(self, args);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, PyObject *args )
|
||||
@ -833,13 +838,26 @@ static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, PyObject *args )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *GroupObSeq_remove( BPy_GroupObSeq * self, PyObject *args )
|
||||
{
|
||||
printf("WARNING: grp.objects.remove() has been deprecated, use grp.objects.unlink() instead.\nBlender releases after 2.43 will not support .remove()");
|
||||
return GroupObSeq_unlink(self, args);
|
||||
}
|
||||
|
||||
|
||||
static struct PyMethodDef BPy_GroupObSeq_methods[] = {
|
||||
{"link", (PyCFunction)GroupObSeq_link, METH_VARARGS,
|
||||
"make the object a part of this group"},
|
||||
{"remove", (PyCFunction)GroupObSeq_unlink, METH_VARARGS,
|
||||
"remove object from this group"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
{"unlink", (PyCFunction)GroupObSeq_unlink, METH_VARARGS,
|
||||
"unlink an object from this group"},
|
||||
|
||||
/* Deprecated! use the above functions */
|
||||
{"append", (PyCFunction)GroupObSeq_append, METH_VARARGS,
|
||||
"make the object a part of this group - deprecated, use link"},
|
||||
{"remove", (PyCFunction)GroupObSeq_remove, METH_VARARGS,
|
||||
"remove an object from this group - deprecated, use unlink"},
|
||||
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -52,6 +52,21 @@ Example::
|
||||
ob.enableDupGroup= True
|
||||
ob.DupGroup= grp
|
||||
Window.RedrawAll()
|
||||
|
||||
|
||||
Example::
|
||||
|
||||
# Remove all non mesh objects from a group.
|
||||
|
||||
from Blender import *
|
||||
|
||||
scn= Scene.GetCurrent()
|
||||
|
||||
# New Group
|
||||
grp= Group.Get('mygroup')
|
||||
for ob in list(grp.objects): # Convert to a list before looping because we are removing items
|
||||
if ob.type != 'Mesh':
|
||||
grp.objects.unlink(ob)
|
||||
"""
|
||||
|
||||
def New (name = None):
|
||||
@ -77,6 +92,7 @@ def Get (name = None):
|
||||
def Unlink (group):
|
||||
"""
|
||||
Unlink (delete) this group from Blender.
|
||||
@Note: No objects will be removed, just the group that references them.
|
||||
@type group: group
|
||||
@param group: A group to remove from this blend file, does not remove objects that this group uses.
|
||||
"""
|
||||
@ -97,9 +113,12 @@ class Group:
|
||||
@ivar layers: Layer bitmask for this group.
|
||||
@type layers: int
|
||||
@ivar objects: Objects that this group uses.
|
||||
This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
|
||||
The groups objects can be set by assigning a list or iterator of objects to the groups objects.
|
||||
objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
|
||||
This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
|
||||
The groups objects can be set by assigning a list or iterator of objects to the groups objects.
|
||||
objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
|
||||
|
||||
B{Note}: append() and remove() have been deprecated and replaced by link() and unlink(),
|
||||
after Blender 2.43 append() and remove() will not be available.
|
||||
@type objects: custom object sequence
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user