7
$\begingroup$

I am interested in exporting and importing 3d models using blender via the command line, as mentioned in this question.

So now I want to know how I can import and export the models in blender with python using this method?

$\endgroup$
4
$\begingroup$

Apart from the info that this question already gives you, you need to figure out the operators to call from the Python script.

Enable Python Tooltips (User Preferences -> Interface -> Display), then go to the import action in the File menu. Rather than clicking on it, hover your mouse over the menu item and inspect the tooltip. That'll tell you which operator to use. Do the same for the export, and you should have the information you need to build up your Python script.

You can get more help from the Python console (in the Scripting layout), by just typing the name of the operator. For example, >>> bpy.ops.import_scene.obj will give you:

# Load a Wavefront OBJ File
bpy.ops.import_scene.obj(filepath="", filter_glob="*.obj;*.mtl", use_ngons=True,
use_edges=True, use_smooth_groups=True, use_split_objects=True, use_split_groups=True,
use_groups_as_vgroups=False, use_image_search=True, split_mode='ON',
global_clamp_size=0, axis_forward='-Z', axis_up='Y')

This tells you which options there are, and what the defaults are.

$\endgroup$
  • $\begingroup$ Hi @Sybren, thanks for your answer, and what you mean by Python console (in the Scripting layout) ? am newbie to python as well as blender $\endgroup$ – Jothi Kannan Oct 9 '14 at 12:34
  • $\begingroup$ At the top of the Blender window, you see a drop-down list with "Default" in it. That's the screen selector. You can select predefined "screens" (which I referred to as "layouts", sorry for that), or create your own. If you select the "Scripting" screen there, you'll find an interactive Python console at the bottom of the screen. There is more info in the Blender manual about screens. $\endgroup$ – dr. Sybren Oct 9 '14 at 12:41
  • $\begingroup$ Yes i got it, thanks for the tip, and this may help me lot $\endgroup$ – Jothi Kannan Oct 9 '14 at 12:55
  • $\begingroup$ Done :) @Sybren $\endgroup$ – Jothi Kannan Oct 9 '14 at 13:55

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.