0
$\begingroup$

Good evening everybody. I use Blender to create Objects for a videogame, i used to use the Version 2.79 because there is the "export as DirectX" Add-On available. Now i want to switch to 2.80, because of that i tried to "update" the Add-On for this Version. I was able to implement the Add-On without any error occuring.

The big problem is, it doesn't show up under "File>Export>..." and i can't find why. (It is activated in the Add-On Menu)

Im not used to program in Python/Blender so i have no real clue in finding errors, i just compared differences between other Add-Ons

I just want to ask if someone could look about the Script and tell me where the error is or even fix the error :)

Thanks and greetings from Germany :)

PS: It is just the init.py becuase the export_x.py would enlarge this Thread way to much in my opinion.

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation, either version 3
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#  All rights reserved.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

bl_info = {
    "name": ".x Exporter",
    "author": "Nico Froese",
    "version": (1, 0, 0),
    "blender": (2, 80, 0),
    "location": "File > Import-Export",
    "description": "Export .x",
    "wiki_url": "",
    "support": 'COMMUNITY',
    "category": "Import-Export"}

if "bpy" in locals():
    import importlib
    if "export_x" in locals():
        importlib.reload(export_x)


import bpy
from bpy.props import (
        BoolProperty,
        FloatProperty,
        StringProperty,
        EnumProperty,
        )
from bpy_extras.io_utils import (
        ImportHelper,
        ExportHelper,
        orientation_helper,
        path_reference_mode,
        axis_conversion,
        )


class ExportDirectX(bpy.types.Operator, ExportHelper):
    """Export selection to DirectX"""

    bl_idname = "export_scene.x"
    bl_label = 'Export DirectX'
    bl_options = {'PRESET'}

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

    # Export options

    SelectedOnly: BoolProperty(
        name="Export Selected Objects Only",
        description="Export only selected objects",
        default=True)

    CoordinateSystem:  EnumProperty(
        name="Coordinate System",
        description="Use the selected coordinate system for export",
        items=(('LEFT_HANDED', "Left-Handed", "Use a Y up, Z forward system or a Z up, -Y forward system"),
               ('RIGHT_HANDED', "Right-Handed", "Use a Y up, -Z forward system or a Z up, Y forward system")),
        default='LEFT_HANDED')

    UpAxis: EnumProperty(
        name="Up Axis",
        description="The selected axis points upward",
        items=(('Y', "Y", "The Y axis points up"),
               ('Z', "Z", "The Z axis points up")),
        default='Y')

    ExportMeshes: BoolProperty(
        name="Export Meshes",
        description="Export mesh objects",
        default=True)

    ExportNormals: BoolProperty(
        name="    Export Normals",
        description="Export mesh normals",
        default=True)

    FlipNormals: BoolProperty(
        name="        Flip Normals",
        description="Flip mesh normals before export",
        default=False)

    ExportUVCoordinates: BoolProperty(
        name="    Export UV Coordinates",
        description="Export mesh UV coordinates, if any",
        default=True)

    ExportMaterials: BoolProperty(
        name="    Export Materials",
        description="Export material properties and reference image textures",
        default=True)

    ExportActiveImageMaterials: BoolProperty(
        name="        Reference Active Images as Textures",
        description="Reference the active image of each face as a texture, "\
            "as opposed to the image assigned to the material",
        default=False)

    ExportVertexColors: BoolProperty(
        name="    Export Vertex Colors",
        description="Export mesh vertex colors, if any",
        default=False)

    ExportSkinWeights: BoolProperty(
        name="    Export Skin Weights",
        description="Bind mesh vertices to armature bones",
        default=False)

    ApplyModifiers: BoolProperty(
        name="    Apply Modifiers",
        description="Apply the effects of object modifiers before export",
        default=False)

    ExportArmatureBones: BoolProperty(
        name="Export Armature Bones",
        description="Export armatures bones",
        default=False)

    ExportRestBone: BoolProperty(
        name="    Export Rest Position",
        description="Export bones in their rest position (recommended for "\
            "animation)",
        default=False)

    ExportAnimation: BoolProperty(
        name="Export Animations",
        description="Export object and bone animations.  Data is exported for "\
            "every frame",
        default=False)

    IncludeFrameRate: BoolProperty(
        name="    Include Frame Rate",
        description="Include the AnimTicksPerSecond template which is "\
            "used by some engines to control animation speed",
        default=False)

    ExportActionsAsSets: BoolProperty(
        name="    Export Actions as AnimationSets",
        description="Export each action of each object as a separate "\
            "AnimationSet. Otherwise all current actions are lumped "\
            "together into a single set",
        default=False)

    AttachToFirstArmature: BoolProperty(
        name="        Attach Unused Actions to First Armature",
        description="Export each unused action as if used by the first "\
            "armature object",
        default=False)

    Verbose: BoolProperty(
        name="Verbose",
        description="Run the exporter in debug mode. Check the console for "\
            "output",
        default=False)

    def execute(self, context):
        self.filepath = bpy.path.ensure_ext(self.filepath, ".x")

        from . import export_x

        Exporter = export_x.DirectXExporter(self, context)
        Exporter.Export()
        return {'FINISHED'}

    def invoke(self, context, event):
        if not self.filepath:
            self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".x")
        context.window_manager.fileselect_add(self)
        return {'RUNNING_MODAL'}


def menu_func_export(self, context):
        self.layout.operator(ExportDirectX.bl_idname, text="DirectX (.x)")


classes = (
    ExportDirectX,
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)


if __name__ == "__main__":
    register()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.