Started python scripting for blender a few days ago to be able to make a exporter to a certain game. So far I’m just messing around and preparing the object for export.
Like that I stumbled upon a possable error, which I (so far) couldn’t fix by using the resources on the internet about blender 2.5+.
It’s the folowing :
- How to make a object the active object?
I need to know this 'cause if I wish to join objects from script, and e.g. a lamp is the last user selected object, an error will be raised that lamp can’t be joined together with meshes.
This is the script so far :
#-----Librarys----- import bpy #-----If not in object mode ==> go to object mode-----1 if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='OBJECT') #-----If something other then the object is selected(like lamp etc), # deselect it-----0 for currentelyLoopedObject in bpy.context.selected_objects[:]: if currentelyLoopedObject.type != "MESH": currentelyLoopedObject.select=0 else: #make this object the active object to prevent #that e.g. the lamp remains the active one #-----Make temperory object (copied) to prevent permanent changes-----1 bpy.ops.object.duplicate_move() #-----Join/merge temperory objects if multiple are selected-----1 if(len(bpy.context.selected_objects) > 1): bpy.ops.object.join() #-----Convert Quads meshes to Triangles-----1 bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action = "SELECT") bpy.ops.mesh.quads_convert_to_tris() bpy.ops.object.mode_set(mode='OBJECT')
It works like this: User selects meshes, scripts makes a copy from it, joins meshes, convert to triangles, export, delete temp. mesh
I’d also be happy to hear advices from you pro’s here if so far I’d have written it in a shabby way
Thanks on advance
Edit: Sorry for posting in wrong section, really though I was inside Support