0
$\begingroup$

I'm trying to make an operator for my algorithm that worked fine runned just from script main function, but bmesh in edit mode loaded from operator is dead... So i just can't do anything with it.

code:

def execute(cls, context):
    if context.mode == 'EDIT_MESH':
        bm = bmesh.from_edit_mesh(context.active_object.data)
        print(bm)
    bm.any_operation_at_bmesh()

Console output:

<BMesh dead at 0x7f1f5558a670>
Traceback (most recent call last):
  File "/home/michal/untitled.blend/paper_models.py", line 491, in poll
ReferenceError: BMesh data of type BMesh has been removed

location: <unknown location>:-1

location: <unknown location>:-1

And on second try of running anything from my script blender crashes...

In object mode loading mesh by:

bm = bmesh.new()
bm.from_mesh(context.active_object.data)

works just fine but the object mode is just not appropriate for this operator.

What am I doing wrong?

My blender version is 2.71

$\endgroup$
  • $\begingroup$ Ok. I've got the answer... I've tried to check something on bmesh in poll() method so it was loaded maybe to fast one after another. When poll method is only checking the context mode it works fine. $\endgroup$ – 8siem Aug 28 '14 at 21:56
  • $\begingroup$ possible duplicate of poll() failed, context incorrect? - Example: bpy.ops.view3d.background_image_add() $\endgroup$ – someonewithpc Aug 29 '14 at 21:02
  • $\begingroup$ Dying Bmeshes are not related to poll errors, it rather happens if you try to a bmesh object reference between functions in global scope, or if mode is changed and bmesh is wrapped. $\endgroup$ – CoDEmanX Aug 29 '14 at 21:47

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.