Fix T82405: Check if active object's data is None
Check if the active object's data is `None` before attempting to call functions on it. It is `None` if the object is an empty. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D9456
This commit is contained in:
parent
40e0792c3c
commit
6975199131
Notes:
blender-bot
2023-02-14 18:46:44 +01:00
Referenced by issue #96970, Empty plain axes should not be too empty (object.data should not be None in python) Referenced by issue #82405, Unable to add extra objects if an empty is selected
|
@ -428,7 +428,8 @@ class add_mesh_bolt(Operator, AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Bolt' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Bolt' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -885,7 +885,8 @@ class add_mesh_wallb(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Wall' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Wall' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -761,7 +761,8 @@ class addBeam(Operator, object_utils.AddObjectHelper):
|
|||
if bpy.context.mode == "OBJECT":
|
||||
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Beam' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Beam' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -689,7 +689,8 @@ class AddGear(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Gear' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Gear' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -910,7 +911,8 @@ class AddWormGear(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('WormGear' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('WormGear' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -284,7 +284,8 @@ class AddDiamond(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Diamond' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Diamond' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -433,7 +434,8 @@ class AddGem(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Gem' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Gem' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -278,7 +278,8 @@ class add_mesh_honeycomb(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('HoneyComb' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('HoneyComb' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -230,7 +230,8 @@ class AddElbowJoint(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if (context.selected_objects != []) and context.active_object and \
|
||||
('ElbowJoint' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('ElbowJoint' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -496,7 +497,8 @@ class AddTeeJoint(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if (context.selected_objects != []) and context.active_object and \
|
||||
('TeeJoint' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('TeeJoint' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -779,7 +781,8 @@ class AddWyeJoint(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if (context.selected_objects != []) and context.active_object and \
|
||||
('WyeJoint' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('WyeJoint' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -1126,7 +1129,8 @@ class AddCrossJoint(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if (context.selected_objects != []) and context.active_object and \
|
||||
('CrossJoint' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('CrossJoint' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
@ -1370,7 +1374,8 @@ class AddNJoint(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if (context.selected_objects != []) and context.active_object and \
|
||||
('NJoint' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('NJoint' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -168,7 +168,8 @@ class AddPyramid(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Pyramid' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Pyramid' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -428,7 +428,8 @@ class MESH_OT_primitive_brilliant_add(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Brilliant' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Brilliant' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -405,7 +405,8 @@ class AddRoundCube(Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Roundcube' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Roundcube' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -208,7 +208,8 @@ class AddStar(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('Star' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('Star' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -223,7 +223,8 @@ class add_supertoroid(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('SuperToroid' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('SuperToroid' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -144,7 +144,8 @@ class AddTorusKnot(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('TorusKnot' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('TorusKnot' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -236,7 +236,8 @@ class AddTwistedTorus(bpy.types.Operator, object_utils.AddObjectHelper):
|
|||
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('TwistedTorus' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and ('TwistedTorus' in context.active_object.data.keys()) and \
|
||||
(self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
|
@ -1293,7 +1293,8 @@ class GenerateGeodesicDome(Operator, object_utils.AddObjectHelper):
|
|||
if mesh != None:
|
||||
if bpy.context.mode == "OBJECT":
|
||||
if context.selected_objects != [] and context.active_object and \
|
||||
('GeodesicDome' in context.active_object.data.keys()) and (self.change == True):
|
||||
(context.active_object.data is not None) and \
|
||||
('GeodesicDome' in context.active_object.data.keys()) and (self.change == True):
|
||||
obj = context.active_object
|
||||
oldmesh = obj.data
|
||||
oldmeshname = obj.data.name
|
||||
|
|
Loading…
Reference in New Issue