0
$\begingroup$

I install 3mf add-on, and I use Python scripting as the following but it does not work.

How can I write the script?

import bpy
bpy.ops.import_mesh.threemf(filepath=c:\\work\\sample.3mf)
$\endgroup$
2
  • $\begingroup$ Try filepath="c:\\work\\sample.3mf" $\endgroup$ Commented Oct 1, 2022 at 14:53
  • $\begingroup$ Thanks for your response! I did the upper comment and it shows the following error. AttributeError: Calling operator "bpy.ops.import_mesh.threemf" error, could not be found $\endgroup$
    – kn11n
    Commented Oct 2, 2022 at 12:43

2 Answers 2

0
$\begingroup$

The add-on somehow uses an operator name that starts with a number. That's the problem. You should report this to the author of the add-on as a bug. You can fix this by changing the text:

bl_idname = "export_mesh.3mf"

to

bl_idname = "export_mesh.three_mf"

in %AppData%\Blender Foundation\Blender\3.3\scripts\addons\io_mesh_3mf\export_3mf.py

and also doing the same thing to %AppData%\Blender Foundation\Blender\3.3\scripts\addons\io_mesh_3mf\import_3mf.py only this time change

bl_idname = "import_mesh.3mf"

to

bl_idname = "import_mesh.three_mf"

You can then use 3mf import operator in your scripts bpy.ops.import_mesh.three_mf(filepath="c:\\some_file.3mf")

$\endgroup$
1
  • $\begingroup$ Thank you for your help. I confirmed that works! $\endgroup$
    – kn11n
    Commented Oct 2, 2022 at 16:17
0
$\begingroup$

The above code is correct but not showing 3mf add-on installation on server environment where you don't have graphics card, and you can't install add-on using blender software. Below is the code to install and enable 3mf format using blender script:

import bpy
bpy.ops.preferences.addon_install(filepath='yourpath\\io_mesh_3mf\\__init__.py') # Need this part only one time to install add-on.
bpy.ops.preferences.addon_enable(module='io_mesh_3mf')
bpy.ops.import_mesh.threemf(filepath=yourpath) 

Thanks

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .