Page 1 of 1
short Python code on Blender
Posted: Tue May 29, 2012 1:18 pm
If we move the cursor above a button or something on Blender, we can see a short and simple code in python. For example :
Python : Scene.frame_current()
so what's the meaning of that? does it mean bpy.ops.Scene?
But, i see on API Doc for Blender 2.62.3 there is no attribute/methode 'frame_current' in bpy.ops.Scene.
I hope some explanations and maybe another examples soi can understand it
huge thanks before!
Posted: Tue May 29, 2012 7:58 pm
Scene.frame_current means, all Scene objects got a property called frame_current (it's not a function!)
first scene in current file:
currently active scene:
accessing frame_current of active scene:
But if you see RenderSettins.filepath, it doesn't mean that there is
You rather need to have a RenderSettings object, thus you need to know where they are stored, e.g.
Posted: Wed May 30, 2012 11:19 am
I get it, but i have another question ^^
so, how could you know it will be part of 'context'? i mean there are also bpy.data.scenes or bpy.ops.scene.
and how about SpaceView3D.cursor_location? will it be bpy.context also? or bpy.ops.view3d?
and what i read on some sources in internet, that i should in 3D view with active camera if i want to use bpy.ops.view3d. is that right? what does it mean?
sorry, i have a lot of questions.
again, thanks a loooooooooooooooooot!
Posted: Wed May 30, 2012 5:22 pm
properties are located in bpy.data or bpy.context
bpy.ops allows you to access operators (derived classes from bpy.types.Operator), basically Blender-Python functions.
The problem with operators is, that some require a certain context. If you run a script from text editor or type into pyconsole, the context is SpaceConsole or TextEditor or something. But view3d ops require View3D, the most simple way to run in this context is to hit Spacebar in 3d viewport and type the operator name and run it from there.
if you wrote and registered your own operator with bl_idname "view3d.do_something", it becomes available as bpy.ops.view3d.do_something()
in Spacebar menu, displayed name equals bl_label