1
$\begingroup$

I wrote an exporter script and put the files into ~/.config/blender/x.xx/scripts/addons/export However, when I check the User Preferences I cannot find my script in the Import-Export section, so I could enable it. If I load the script manually, however, an export entry appears under the Export menu. My current goal is to simply have it show up in the User Preferences, the code is pretty much copy&pasted from other scripts.

__init__.py:

bl_info = {
  "name": "SCN format (.scn)",
  "author": "",
  "version": (0, 0, 1),
  "blender": (2, 77, 0),
  "location": "File > Import-Export > scn (.scn)",
  "description": "Export SCN",
  "warning": "",
  "wiki_url": "",
  "support": 'NONE',
  "category": "Import-Export"
}

if "bpy" in locals():
  import importlib
else:
  import bpy

from bpy.props import (
  BoolProperty,
  FloatProperty,
  StringProperty,
  EnumProperty,
  )

from bpy_extras.io_utils import (
  ImportHelper,
  ExportHelper,
  orientation_helper_factory,
  path_reference_mode,
  axis_conversion,
  )

IOOBJOrientationHelper = orientation_helper_factory("IOOBJOrientationHelper", axis_forward='-Z', axis_up='Y')

class ExportSCN(bpy.types.Operator, ExportHelper, IOOBJOrientationHelper):
  """Save a SCN File"""

  bl_idname = "export_scene.scn"
  bl_label = 'Export SCN'
  bl_options = {'PRESET'}

  filename_ext = ".scn"
  filter_glob = StringProperty(
    default="*.scn",
    options={'HIDDEN'},
  )

  output_format = EnumProperty(
    name="Output Format",
    items=(
      ("CBOR", "CBOR", "Export as CBOR"),
      ("JSON", "JSON", "Export as JSON"),
    ),
    default="CBOR"
  )

  path_mode = path_reference_mode

  check_extension = True

  def draw(self, context):
    layout = self.layout

    row = layout.row(align=True)
    row.prop(self, "output_format")

  def execute(self, context):    
    return "FINISHED"

def menu_func_export(self, context):
  self.layout.operator(ExportSCN.bl_idname, text="SCN (.scn)")

def register():
  bpy.utils.register_module(__name__)

  bpy.types.INFO_MT_file_export.append(menu_func_export)

def unregister():
  bpy.utils.unregister_module(__name__)

  bpy.types.INFO_MT_file_export.remove(menu_func_export)

if __name__ == "__main__":
  register()
$\endgroup$
  • $\begingroup$ Did you save the user settings after you activated the addon? gamefromscratch.com/image.axd?picture=image_thumb_2524.png $\endgroup$ – TLousky Jun 7 '17 at 11:24
  • $\begingroup$ i can't activate it, it does not show up, there's nothing in the console, if I load from the command line shell. $\endgroup$ – user1095108 Jun 7 '17 at 11:28
  • $\begingroup$ I see. Sounds like you're missing some of the required stuff for registering addons. Please have a look at the tutorial, and if you can post the script's code it could help debug the issue: docs.blender.org/api/blender_python_api_current/… $\endgroup$ – TLousky Jun 7 '17 at 11:31
  • $\begingroup$ My pleasure, here's the code, pretty much copy&pasted, nothing special. $\endgroup$ – user1095108 Jun 7 '17 at 11:55
1
$\begingroup$

If you come across a problem like this, the solution might be not to copy&paste from an existing exporter script, but to literally copy the directory of some such exporter into .config/blender/x.xx/scripts/addons and work on it from there. This seems to work, but the root cause was blender getting freaked out by my bl_info line. Specifically:

bl_info = {
...
"support": 'NONE',
...
}

freaked it out and omitting the line solved the issue.

$\endgroup$

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.