Export dll not in exporters folder

If you mean to have it automatically appear in the filetypes of the export dialog, no I would think you would need to tell SketchUp it is loaded, guessing perhaps there might be a register_exporter() SDK function.

Yes in the Ruby script you’d need to add a export option to the “File” menu:

Here is a sample. You’d need to adjust the CTypes to match your library function.
See the constants in the Fiddle module:
http://ruby-doc.org/stdlib-2.0.0/libdoc/fiddle/rdoc/Fiddle.html

# Encoding: UTF-8

module Marsh
  module NiftyExport

    # Initialize a module variable indicating if menuitem added:
    @@menuitem = false if !defined?(@@menuitem)

    MENUTEXT = "Export to Nifty"

    LIBNAME = "nifty_export.dll"
    LIBPATH = "some/path/to/external/directory"
    LIBRARY = File.join( LIBPATH, LIBNAME )
    
    EXPORT_FUNCNAME = "export_func_name"

    def self::export()

      # Make sure Fiddle library is loaded:
      require 'fiddle' unless defined?(Fiddle)
      require 'fiddle/import' unless defined?(Fiddle::Importer)

      # Extend this module with Fiddle::Importer mixin module:
      # (extend checks the ancestors, so only does this once.)
      extend Fiddle::Importer

      # Load the export library:
      @lib = Fiddle::dlopen LIBRARY

      # Import the export function:
      @export = import_function(
        @lib[EXPORT_FUNCNAME],
        Fiddle::TYPE_VOID,        # ctype : see Fiddle module constants
        [Fiddle::TYPE_UINTPTR_T], # arg array of ctypes : see Fiddle module constants
        call_type = nil           # the ABI of the function
      )
      
      # Do the export:
      @export.call( Sketchup::active_model )
      
    rescue => e

      puts Module::nesting[0].name<<" Error: #<#{e.class.name}: #{e.message}>"
      puts e.backtrace if $VERBOSE && $DEBUG

    ensure

      @lib.close    # let GarbageCollection call dlclose() on the library
      @export = nil # release reference to function
      @lib = nil    # release reference to handle

    end ###


    if !@@menuitem  # Add the menu item only once:

      UI.menu("File").add_item(MENUTEXT) {
        self::export()
      }
      @@menuitem = true

    end

  end # inner export module
end # outer author namespace module

I could have used simple local variables within the export method for the lib handle and function reference, but I chose to use @var instance variables, so they would stand out as transitory references.

1 Like