I have a Blender project which won't allow me to use object operators (in this case bpy.ops.object.parent_clear(type='CLEAR')), without crashing.

I have tried it on different objects in my scene and get the same result. I have tried adding a cube object and trying to clear its parent and it also causes a crash. Running Blender from the command line doesn't help as Blender stops responding before printing anything to the command line. The same thing happens when I try any object operator. Trying to execute the operation from the console also causes the crash.

I've never had this problem with any other projects, but something about the way this Blender project is set up is causing Blender to crash. I try to avoid operators in general, but I need to run a script to set the object origin to a certain point and have not found a way to do so without using an object operator.

I wish I could give more information but I have no idea what's causing this.

Here's the first few lines of my code (which run fine until the dreaded operator must be used):

def origin_to_bottom(obj):
    ''' obj is a Blender object containing a mesh'''

    # pedantically make sure that I don't affect the wrong object
    for selected in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj

    # get parent and clear parent
    parent = obj.parent
  • 2
    $\begingroup$ As commented when you asked this before, can set the origin without using operators (links posted to prior) IMO without more info, eg full code, test blend, or test code that when you run crashes your blender, as opposed to a single method which doesn't appear to have any "danger" in it. ... as you say "something about the way this Blender project is set up is causing Blender to crash" Without a genie or a crystal ball to rub would be a minor miracle to answer this. $\endgroup$ – batFINGER Aug 6 at 8:46
  • 1
    $\begingroup$ As @batFINGER said, this code totally work fine on its own. So, did you call your function in anyway Blender doesn't like? eg. Thread. There is a full article in API document elaborate something might go wrong when you are not aware of these problem $\endgroup$ – HikariTW Aug 6 at 8:50
  • $\begingroup$ @batFINGER even running the single line of code calling the clear parent function crashes blender. I've tried running this in the Blender python console. Strangely, if I right click the object and select Parent > Clear Parent works fine. Copying the code from the Info Editor into the blender console crashes. Even if it's possible to set origin without operators, I would like to understand how this is happening. Happy to send my project file but not sure how to do this. Can send a dropbox link? $\endgroup$ – JakeRSA Aug 6 at 9:46
  • $\begingroup$ @HikariTW I'm not in edit mode, don't get a poll incorrect error message, only running one line and not referencing a data block so not sure how it could be an issue with memory allocation. Not a big project file, surely not running out of memory. I've read through the Gotcha stuff and don't see where I'm going wrong! $\endgroup$ – JakeRSA Aug 6 at 9:49
  • $\begingroup$ @JakeRSA Upload to blend-exchange.giantcowfilms.com this one is the most acceptable place for BSE $\endgroup$ – HikariTW Aug 6 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.