I encode my rbz file and import it into sketchup giving me an error, I'm new

NAT_Comand_CADtoSUcorquerbz.rbz (995.1 KB)
NAT_Comand_CADtoSU.rbz (982.5 KB)
this file Encryption is "NAT_Comand_CADtoSUcorqerbz.rbz
this file origin is "NAT_Comand_CADtoSU.rbz
-I encode my rbz file and import it into sketchup giving me an error
"Extension Errors Report
SketchUp: 25.0.571
OS: Windows 11
Ruby: 3.2.2

Extension: NAT Command CAD→SU (1.0.0)
Error: LoadError (cannot load such file – C:/Users/TAI/AppData/Roaming/SketchUp/SketchUp 2025/SketchUp/Plugins/NAT_Comand_CADtoSU/NAT_Comand_CADtoSU_loader.rb)
C:/Users/TAI/AppData/Roaming/SketchUp/SketchUp 2025/SketchUp/Plugins/NAT_Comand_CADtoSU.rb:27:in load' C:/Users/TAI/AppData/Roaming/SketchUp/SketchUp 2025/SketchUp/Plugins/NAT_Comand_CADtoSU.rb:27:in <top (required)>'"

In the extension registrar file (NAT_Comand_CADtoSU.rb,) … REMOVE these lines:


# Xác định đường dẫn đến folder chứa loader
plugin_root = File.dirname(__FILE__)
loader_path = File.join(plugin_root, 'NAT_Comand_CADtoSU', 'NAT_Comand_CADtoSU_loader.rb')

# Load mã chính
load loader_path

Sketchup::register_extension will load your extension’s loader file, IF the user has it switched ON in the Extensions Manager. Since you passed true as the 2nd argument, it will be loaded the first time when extension is installed.

I deleted it like you said, sketchup doesn’t give an error but when I click on the icon nothing happens

I did not check if your extension actually works. Open the ruby console, and see if any errors appear.

Before encryption, it still works normally. After encryption, there is an error like I said at the beginning of the article

Are you encripting the register file?

Yes I see the issue.

IN the loader file …

  # Load các file chức năng
  Dir.glob(File.join(PLUGIN_ROOT, '*.rb')).each do |file|
    next if File.basename(file) == File.basename(__FILE__)
    load file # <<-----<<<< WRONG!
  end

Change load file to: Sketchup.require(file) so that it is (Corrected globing):

  # Load các file chức năng
  Dir.glob(File.join(PLUGIN_ROOT, '*.{rb,rbe}')).each do |file|
    next if File.basename(file) == File.basename(__FILE__)
    Sketchup.require(file)
  end

No it was not encrypted.

My file “NAT_Comand_CADtoSU_loader.rb” is used to create menus, toolbars and run files located in the folder with “NAT_Comand_CADtoSU_loader.rb”. When encryption is complete, the file “NAT_Comand_CADtoSU_loader.rb” changes to “NAT_Comand_CADtoSU_loader.rbe” so does it count as I have encrypted the registration file?

Actually, you also need to glob rbe files since they are encrypted:

  # Load các file chức năng
  Dir.glob(File.join(PLUGIN_ROOT, '*.{rb,rbe}')).each do |file|
    next if File.basename(file) == File.basename(__FILE__)
    Sketchup.require(file)
  end

Do you understand now?

I deleted "# Specify the path to the folder containing the loader
plugin_root = File.dirname(FILE)
loader_path = File.join(plugin_root, ‘NAT_Comand_CADtoSU’, ‘NAT_Comand_CADtoSU_loader.rb’)

Load main code

load loader_path’ in "NAT_Comand_CADtoSU.rb and replace “# Load function files
Dir.glob(File.join(PLUGIN_ROOT, ‘*.{rb,rbe}’)).each do |file|
next if File.basename(file) == File.basename(FILE)
Sketchup.require(file)
end” in “NAT_Comand_CADtoSU_loader.rb” and re-encrypt it then when I enter into sketchup there is still no error and clicking on the icon nothing happens, I’m a newbie so I really don’t know how to encrypt the file properly.

The encryption portal does the encrypting for you.
You need to properly use Sketchup.require for encrypted rbe files.

Leave the Ruby Console open and restart SketchUp. See if any errors messages appear in the console.


And please post code correctly in the forum:

so I have to add the line “Sketchup.require” for the .rb files in the folder “NAT_Comand_CADtoSU” and then re-encrypt, right?

In the "NAT_Comand_CADtoSU_loader" file. Read the API documentation for Sketchup.require.

I followed your steps again and it worked, thank you very much

1 Like