def export_file(self, context):
        """Export the file."""

        props = bpy.context.preferences.addons["rizomuv_bridge"].preferences

        act_obj = bpy.context.active_object
        sel_objs = mutil.get_meshes(True)
        out_objs = []

        bpy.ops.ed.undo_push()
        if not self.uv_map_checks(sel_objs):
            return {'CANCELLED'}

        for obj in sel_objs:
            new_obj = obj.copy()
            new_obj.name = obj.name + "_rizom"
            bpy.context.scene.collection.objects.link(new_obj)
            out_objs.append(new_obj)

        bpy.ops.object.select_all(action='DESELECT')

        # Clear any modifiers and reset active UV index ready for export
        for obj in out_objs:
            bpy.data.objects[obj.name].select_set(True)
            obj.modifiers.clear()
            obj.data.uv_layers.active_index = 0

        bpy.ops.export_scene.fbx(filepath=TEMP_PATH,
                                 use_selection=True,
                                 global_scale=1.0,
                                 object_types={'MESH'},
                                 use_mesh_edges=False,
                                 bake_anim=False,
                                 axis_forward='-Z',
                                 axis_up='Y')

        mutil.delete_meshes(out_objs)

        for obj in sel_objs:
            bpy.data.objects[obj.name].select_set(True)

        context.view_layer.objects.active = act_obj

        script = lua.write_script()
        prefs = bpy.context.preferences.addons["rizomuv_bridge"].preferences
        exe = prefs.rizomuv_path

        process = subprocess.Popen([exe, '-cfi' + script])

        if props.auto_uv:
            process.communicate()

        if not props.auto_uv:
            self.report({'INFO'}, "RizomUV Bridge: " + str(len(sel_objs)) +
                        " object(s) exported")

        return None
예제 #2
0
    def draw(self, context):
        """Draw the UI."""

        temp_file = tempfile.gettempdir() + os.sep + "rizom_temp.fbx"

        props = bpy.context.preferences.addons["rizomuv_bridge"].preferences

        layout = self.layout

        # Import/Export
        box = layout.box()
        row = box.row(align=True)
        row.label(text="UV Operations:", icon='UV_DATA')

        row = box.row(align=True)
        row.scale_y = 1.25
        if not os.path.exists(temp_file) or props.auto_uv is True:
            row.enabled = False
        row.operator("ruv.rizom_edit", text="Edit", icon='FILE_CACHE')

        row = box.row(align=True)
        row.scale_y = 1.25
        if props.auto_uv is True:
            export = "Export (Auto UV)"
        else:
            export = "Export"
        row.operator("ruv.rizom_export", text=export, icon='EXPORT')

        row = box.row(align=True)
        row.scale_y = 1.25
        if not mutil.get_meshes(False):
            row.enabled = False
        row.operator("ruv.rizom_import", text="Import", icon='IMPORT')

        #--------------------------------------#
        #--------------------------------------#

        # Export Settings
        box = layout.box()
        row = box.row(align=True)
        row.label(text="Export Settings:", icon='EXPORT')

        row = box.row(align=True)
        row.scale_y = 1.25
        row.prop(props, "script_run")

        row = box.row(align=True)
        row.scale_y = 1.25
        if props.script_run == 'NO_SCRIPT':
            row.enabled = False
            props.auto_uv = False
        row.prop(props, "auto_uv")

        #--------------------------------------#
        #--------------------------------------#

        # Import Settings
        box = layout.box()
        row = box.row(align=True)
        row.label(text="Import Settings:", icon='IMPORT')

        row = box.row(align=True)
        row.scale_y = 1.25
        row.prop(props, "seams")
        row.prop(props, "reveal_hidden")

        #--------------------------------------#
        #--------------------------------------#

        box = layout.box()
        row = box.row(align=True)
        row.label(text="Preferences:", icon='PREFERENCES')

        row = box.row(align=True)
        row.scale_y = 1.25
        row.operator("ruv.bridge_config_reset",
                     text="Reset Settings",
                     icon='LOOP_BACK')
예제 #3
0
    def poll(cls, context):
        """Check context is correct to run the operator."""

        return len(mutil.get_meshes(False)) > 0 and\
            os.path.isfile(TEMP_PATH)
    def poll(cls, context):
        """Check context is correct to run the operator."""

        return mutil.get_meshes(False) is not None