It works like it should, but i get this message. In what way am I calling this in “an invalid context”?
Alternatively: Can I just stop the message from displaying in the system console?
You are getting the error because the translate op uses the view. The op you posted has a translation of (0, 0, 0) so it may have appeared to have worked… how would you tell?
operators require a certain context, which means mouse cursor has to be in certain area/region, for example, transform operators require the 3d view, they can’t work in file browser.
@batFinger: i should rather be
obj.location += Vector((1,0,0)) # tuple, not list!
As far as I know, you shouldn’t set the context. Rather, you can copy the context, change the copy and then give it as an argument to the operator as an override context. I don’t have example code here as I only have my tablet at hand, sorry. Just google override context blender python, or something similar.
Thanks for trying … BUT… context changing is WEL done at other steps of my application (building a mesh)
Even needed! E.g. I have a button in PROPERTIES part of the screen to activate a step, and somtimes (without changing context)
the PROPERTIES became VIEW_3D context, so a step sets it back to PROPERTIES … and it works as meant ;-).
I just do not understand : convertViewVec called in an invalid context
What is wrong and how to give it the RIGHT context and evt. again back to PROPERTIES???
I don’t get understand how you can be in the wrong context and only get a warning. Maybe you should make a new thread that has not been marked solved, as to attract attention from people wiser than me, like CoDEmanX.
Got my stepwise script more or less working again for Blender 2.76b
But that strange error occurs nevertheless and I do not understand here part of what I printed to the console:
step20 create een oog, op goede plaats en iets plat
step20 bpy.context.active_object.name= Sphere
step20 bpy.context.active_object.name= Gus_ogen
dupliceer oog en zet de kleur
step21-0 bpy.context.active_object.name= Gus_ogen
convertViewVec: called in an invalid context
step21-1 bpy.context.active_object.name= Gus_ogen
step21-2 bpy.context.active_object.name= Gus_ogen
step22 create de mond, op goede plaats en iets plat
PKHG, as I alluded to in a previous answer, I believe the
bpy.ops.mesh.duplicate_move
operator uses the matrix of the 3d view to translate, and the error is due to it being run instead from the text editor
I tried wrapping with a change of area, or changing area and context members of context.copy() but unfortunately it crashes my blender.