I have an external app that should sync with blender by Scene.frame_current.
I was thinking to use something like Python threading.Timer (or dummy_threading.Timer) to change frame_current repeatedly from script, but it’s a potentially problematic solution. I’ve also tried to change Scene.frame_current from “draw” method of a new class derived from bpy.types.Panel somehow like that:
and got “AttributeError: Writing to ID classes in this context is not allowed: Scene, Scene datablock, error setting Scene.frame_current”, though it worked perfectly from blender Python console.
Then I’ve run out of ideas, could anyone suggest anything, please? I suppose, I don’t understand something important about whole that new Blender context concept so long as there’s almost no documentation
my explanation was a bit messy, but the major point is that callbacks for some custom property update cannot be used, and SyncCurrentFrame() should be called repeatedly while this script is running
External app doesn’t know anything about blender, python script executed within blender simply fetching some data from that app as XMLRPC client. This is a bit weird but this part is working just fine.
>> bpy.data.scenes[0].frame_current = newFrame
Still “Writing to ID classes in this context is not allowed: Scene, Scene datablock, error setting Scene.frame_current”, unfortunately
import bpy
def GetNewFrameNumber() :
return 10
def SyncCurrentFrame():
newFrame = GetNewFrameNumber()
if( newFrame ):
bpy.data.scenes[0].frame_current = newFrame
# or this to use the current scene :
#bpy.context.scene.frame_current = newFrame
SyncCurrentFrame()
Yes, SyncCurrentFrame() call works outside SomeNewPanel.draw method. But this way it is only called once while I need it to be called repeatedly.
The only way I could find to do that is to put it to “draw” method of something, or as a callback for update of some property that is changing constantly =)
Does anyone know such property?)
Because this is working fine:
def SyncCurrentFrame( self, context ):
newFrame = GetNewFrameNumber()
if( newFrame ):
bpy.data.scenes[0].frame_current = newFrame
# or this to use the current scene :
#bpy.context.scene.frame_current = newFrame
...
...
screen = bpy.types.Scene
StringProperty = bpy.props.StringProperty
screen.someString = StringProperty( name="some str", default="str", description = "str", update = SyncCurrentFrame )