Is there a quick way to force a script to run in a specific area while pushing the “Run script” button, without having to put the following and do an F3 > “operator name”?
class SimpleOperator(bpy.types.Operator):
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def execute(self, context):
do this
do that
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
For example, could I just loop through the areas in the current screen and when its type matches the one I’m looking for (e.g. 'VIEW3D'
), run the script in that area instead of the text editor?
for a in bpy.context.screen.areas:
if a.type=='VIEW_3D':
myViewport = some area property
break
[something to run the following in myViewport]:
my code
or something different but as short as possible.