If I use “bpy.ops.uv.project_from_view()” on a button it works
class TFPPanel(bpy.types.Panel):
bl_label = "Texture from Projection"
bl_idname = "TFPPanel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
row = layout.row(align = True)
row.alignment = 'EXPAND'
row.operator("start.button", text = "Start")
#BUTTON START
class OBJECT_OT_StartButton(bpy.types.Operator):
bl_idname = "start.button"
bl_label = "Start it"
bl_description = "start script"
def execute(self, context):
main(context)
t_current = bpy.context.scene.frame_current
t_all = bpy.context.scene.frame_end
ob = bpy.context.object
me = ob.data
t_current = bpy.context.scene.frame_current
t_all = bpy.context.scene.frame_end
#set UVs
me.uv_textures["uvUNW"].active = False
me.uv_textures["uvPFV"].active = True
<b>#project from view
bpy.ops.uv.project_from_view()</b>
#add 1 to t_currrent
t_current + 1
#go to next frame
bpy.context.scene.frame_current += 1
print(t_current)
return{'FINISHED'}
bpy.utils.register_module(__name__)
but if I use it in a while loop it stops working, but I don’t get an error-message in the terminal
import bpy
import os
def main(context):
ob = bpy.context.object
me = ob.data
#get current frame
t_current = bpy.context.scene.frame_current
#get scenelength
t_all = bpy.context.scene.frame_end
#LAYOUT
class TFPPanel(bpy.types.Panel):
bl_label = "Texture from Projection"
bl_idname = "TFPPanel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
row = layout.row(align = True)
row.alignment = 'EXPAND'
row.operator("start.button", text = "Start")
#BUTTON START
class OBJECT_OT_StartButton(bpy.types.Operator):
bl_idname = "start.button"
bl_label = "Start it"
bl_description = "start script"
def execute(self, context):
main(context)
t_current = bpy.context.scene.frame_current
t_all = bpy.context.scene.frame_end
ob = bpy.context.object
me = ob.data
while (t_current <= t_all) :
t_current = bpy.context.scene.frame_current
t_all = bpy.context.scene.frame_end
#set UVs
me.uv_textures["uvUNW"].active = False
me.uv_textures["uvPFV"].active = True
<b> #project from view
bpy.ops.uv.project_from_view()</b>
#add 1 to t_currrent
t_current + 1
#go to next frame
bpy.context.scene.frame_current += 1
print(t_current)
return{'FINISHED'}
Can you tell me what I’m doing wrong? I’m relative new to python scripting.