Previous Thread  Next Thread

chat icon Bake to texture in python

karljj1

Posted: Mon Jun 20, 2011 6:12 pm
Joined: 25 May 2011
Posts: 5
Hello,

I am trying to bake all the textures of a model into a single texture. I have managed to do this manually and am now trying to write a script to do this. However some of the blender operations do not show me the python calls so i am a little stuck. Here is what i do so far:

Code:
   def CreateAtlas() :   
      
      bpy.ops.mesh.uv_texture_add()      
      bpy.ops.object.editmode_toggle()
      bpy.ops.uv.smart_project( angle_limit = 66, island_margin = 0 )
      img = bpy.ops.image.new( name='Atlas', width = 1024, height = 1024 )
      #How do i assign the image to the uvs???
      bpy.context.scene.render.bake_type = 'TEXTURE' # Set to bake texures only
      bpy.ops.object.bake_image()


After i uv project i need to change the image that is used to a new image however i do not know the python command to do this. It is the ittle icon of an image with a drop down list of images that lets me select the new image. Any suggestions? When i hover my mouse over it the tool tip is 'Browse Images to be linkled', it does not show the python command in the tooltip Sad


Thanks
Reply with quote


underdoeg

Posted: Wed Dec 21, 2011 8:15 pm
Joined: 29 Apr 2010
Posts: 5
I'm struggling with the exact same problem.

Did you ever get it working?


So far I have
Code:
bpy.data.screens['UV Editing'].areas[1].spaces[0].image = image

But I am not entirely sure if this is a good way to go?
_________________
http://www.undef.ch
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group