Scripts:
- Fixing bug #5950 reported by Stewart Andreason (thanks): http://projects.blender.org/tracker/?func=detail&atid=125&aid=5950&group_id=9 Importing .ac models created Blender objects with user count equal to 2, instead of 1 (so they couldn't be deleted in Blender), because the script kept a second reference to each created Blender object and so Python didn't deallocate things properly at the end of the script. Now these extra references are deleted in the script, preventing the problem. But this is surely something to fix in the API itself.
This commit is contained in:
@@ -460,6 +460,8 @@ class AC3DImport:
|
||||
olist = self.objlist[1:]
|
||||
olist.reverse()
|
||||
|
||||
scene = self.scene
|
||||
|
||||
newlist = []
|
||||
|
||||
for o in olist:
|
||||
@@ -473,9 +475,7 @@ class AC3DImport:
|
||||
children.remove(parent)
|
||||
o.bl_obj = parent.bl_obj
|
||||
else: # not found, use an empty
|
||||
empty = Object.New('Empty', o.name)
|
||||
self.scene.link(empty)
|
||||
empty.select(True)
|
||||
empty = scene.objects.new('Empty', o.name)
|
||||
o.bl_obj = empty
|
||||
|
||||
bl_children = [c.bl_obj for c in children if c.bl_obj != None]
|
||||
@@ -513,6 +513,13 @@ class AC3DImport:
|
||||
o.loc = Vector(0.0, 0.0, 0.0)
|
||||
blob.setLocation(o.loc) # forces DAG update, so we do it even for 0, 0, 0
|
||||
|
||||
# XXX important: until we fix the BPy API so it doesn't increase user count
|
||||
# when wrapping a Blender object, this piece of code is needed for proper
|
||||
# object (+ obdata) deletion in Blender:
|
||||
for o in self.objlist:
|
||||
if o.bl_obj:
|
||||
o.bl_obj = None
|
||||
|
||||
def testAC3DImport(self):
|
||||
|
||||
FACE_TWOSIDE = Mesh.FaceModes['TWOSIDE']
|
||||
@@ -555,7 +562,7 @@ class AC3DImport:
|
||||
elif obj.type == AC_LIGHT:
|
||||
light = Lamp.New('Lamp')
|
||||
object = scene.objects.new(light, obj.name)
|
||||
object.select(True)
|
||||
#object.select(True)
|
||||
obj.bl_obj = object
|
||||
if obj.data:
|
||||
light.name = obj.data
|
||||
@@ -570,7 +577,7 @@ class AC3DImport:
|
||||
|
||||
mesh = Mesh.New()
|
||||
object = scene.objects.new(mesh, obj.name)
|
||||
object.select(True)
|
||||
#object.select(True)
|
||||
obj.bl_obj = object
|
||||
if obj.data: mesh.name = obj.data
|
||||
mesh.degr = obj.crease # will auto clamp to [1, 80]
|
||||
|
||||
Reference in New Issue
Block a user