I compress my extension to zip and renamed it as something.rbz, then I use extension install it, all is worked.
However, I uploaded the something.rbz file to this url :https://extensions.sketchup.com/extension/sign?login=true
, and got a newthing.rbz, it could be installed and seen in the extension manager, but the extension couldn’t work.
I guess, the possible reason may be using require (another.rb)
in main.rb, the another.rb was encrypted and renamed to another.rbe
, so something wrong happened, is that right?
Could someone help me?
r
Did you use Ruby’s require
or SketchUp’s Sketchup.require
?
Thank you, I changed all my Ruby’s require(somefile.rb)
to Sketchup::require(somefile)
. But there are still some problems.
when I install the encrypted file that download from web, the su’s console says Error: #<NameError: uninitialized constant
.
I tried to unzip the encrypted file that download from web, compress it to rbz and install it again, everything is OK now. But the disadvantage is that the extension manager says its an invalid signature.
Fixed it!
Not only using the Sketchup::require
, but also need to specify the modeul(self name space) when you using some class
When opting in for encryption your .rb files in the RBZ will be converted into .rbe files. These must be loaded via
Sketchup.require. When using
Sketchup.require`, omit the file extension, SketchUp will find the file for you.
Instead of
require 'my_extension/main.rb'
do this:
Sketchup.require 'my_extension/main'
You must also omit the file extension for the loader file provided to SketchupExtension
.
Not sure what you meant by this. Can you show an example?
class MySelectionObserver
is in core.rb
1:
module Pt
module PlanDesign
Sketchup::require(File.dirname(__FILE__) +'/core')
Sketchup.active_model.selection.add_observer(Pt::PlanDesign::MySelectionObserver.new(dialog))
2:
module Pt
module PlanDesign
Sketchup::require(File.dirname(__FILE__) +'/core')
Sketchup.active_model.selection.add_observer(MySelectionObserver.new(dialog))
1 is work, 2 is not work.
The strange thing is OK if I use Ruby/Extension loader
to load my extension, but when I use web convert it to a single rbz file, and install it in extension manager, there would be a mistake, the Sketchup
can not find class MySelectionObserver
.
What version of SketchUp are you seeing this in?
There used to be issues with __FILE__
in very old versions of SU when using encrypted files, but recent should be fine.
(Btw, __dir__
is the same is File.dirname(__FILE__)
.)
I wonder if perhaps there is another MySelectionObserver
class defined at the top level of Ruby’s objectspace ?
The unqualified local MySelectionObserver
constant identifier should be available from within the Pt::PlanDesign
module.
It is useful for me, thank you!
Maybe, but I wouldn’t expect the file being encrypted to have any effect on this. Should be the same regardless. Unless there’s a bug in Sketchup.require
…
I agree, and since we cannot see how “core.rb” is written out guesses are vague.