4
$\begingroup$

I have installed import_off addon from this github repo. This addon provide import functionality of the ".off" file in blender using the GUI. But there is no way I can import ".off" file using python.

Please tell if there is any way I can import .off files using python, since I intend to work on many 3D models and using GUI is not possible on all of them.

$\endgroup$

2 Answers 2

7
$\begingroup$

You are under a misapprehension that you can not use the import OFF addon you posted.

Get the name of the operator by mousing over the import menu bpy.ops.import_mesh.off(...)

Typing the operator in the python console and using autocomplete CrtlSpace exposes the parameters (Same as those in the UI).

bpy.ops.import_mesh.off(filepath="", filter_glob="*.off", axis_forward='Y', axis_up='Z')
>>> bpy.ops.import_mesh.off(

Simply pass the filepath of an OFF file to the operator in your own code.

Eg: to import with default settings.

filepath = "some/path/to/file.off"
bpy.ops.import_mesh.off(filepath=filepath)

This can be done for pretty much all import / export addons.

$\endgroup$
2
  • $\begingroup$ What does "axis_forward='Y'" mean? $\endgroup$ Commented Dec 1, 2016 at 19:31
  • $\begingroup$ To define a 3d space used by an application, need which axis is up, for blender z, and which axis points towards you (y) in front ortho. A lot of other applications use y up. Without converting a blender model will be exported with the wrong alignment. $\endgroup$ Commented Dec 2, 2016 at 2:30
1
$\begingroup$

Answer from @batFINGER worked for me, but I had to pass the parameters as named parameters.

Do it like this:

bpy.ops.import_mesh.off(filepath = filepath)

Not like this:

bpy.ops.import_mesh.off(filepath)
$\endgroup$
1
  • 2
    $\begingroup$ Thanks, fixed the oversight in my answer. In future suggest adding a comment or making an edit. $\endgroup$ Commented Jul 12, 2021 at 8:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.