1
$\begingroup$

I'm trying to create a default mapping mode for an object. I followed through understanding the python API for blender, and things are making more sense at this point, however I'm not able to create the UV map I wish on the object. Code below:

import bpy
from os import getcwd

file = getcwd()+'/data/naturalSat/models/2_Pallas_101.obj'
print("Testing")
imported_object = bpy.ops.import_scene.obj(filepath=file)
obj_object = bpy.context.selected_objects[0]
print("processing: "+obj_object.name)
#Extract the mesh and smooth all polygons
output = obj_object.data
for face in output.polygons:
    face.use_smooth = True

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.unwrap()
bpy.ops.uv.cylinder_project(direction='VIEW_ON_EQUATOR', scale_to_bounds=True)

#export
filePath = getcwd()+'/'+obj_object.name+'.obj'
bpy.ops.export_scene.obj(filepath=filePath)

Am I doing this correctly? one of the concerns I have is that the cylindrical_project arguments is direction = 'VIEW'. I'm loading a python script using the command line, so headless mode.

$\endgroup$

1 Answer 1

0
$\begingroup$

I am not a professional myself, but the code looks okay, I guess. Your direction isn't "view", though, but "VIEW_ON_EQUATOR", you could also use "VIEW_ON_POLES", "ALIGN_TO_OBJECT", though: see the documentation

If it's "right" or "wrong" depends a little on the shape of your objects and how you want the unwrap to be aligned to it. Maybe try out all three and see which one fits best?

$\endgroup$
1
  • $\begingroup$ They don’t change the mapping which is currently the texture mapped on every face $\endgroup$
    – triple7
    Jan 26, 2019 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.