Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

March 20, 2012

importing .obj

The separator used here is '\\', but this varies from OS to OS. Python has a module called os to take some of the headache away. The above code allows you to do this stuff manually, research and experiment with the os module, it's great to understand how it works.

You could write a plugin using the directory selector built into Blender, so that you can navigate to a directory and obtain the string full_path_to_directory that way, but that's a different topic.

Blog reader pmpfx wondered how this syntax was glued together, so I think the above should clarify the path issues. The following snippet uses the os module to list the content of a directory. It will gather all files that are .obj and import them. No error checking is done, the path has to be valid. Conveniently the os module provides ways to check if a path is valid, read the docs. Here's a description of how to sanitize a blend