@edson said:
would you care to explain what is the difference between your version and the one that packs with sketchup?
I did in the first post of this thread. I wrapped the original code like thus:
module Examples
module SU
module Box
# the original create_box method
end # Box
end # SU
end # Examples
In addtion I made the create_box() method a module function (see Ruby Pick-Axe book: module_function)
I also made a small correction, by moving the last line up inside the preceeding if block.
I marked all lines that were added or moved.
Wrapping the code, in it's own namespace prevents it from being corrupted by scripts that load afterwards, that have methods (or other objects,) with the same name.
What was happening was, that after box.rb loaded, then later make_pano_pm.rb would load, and it ALSO had a method named " create_box". Since neither script (originally) was wrapped in a module they were actually defining methods within the SAME namespace (which is class Object.) Whenever Ruby reads a method definition of a method that is already defined, it deletes the old method, and replaces it with the new one.
So.. make_pano_pm.rb was redefining the create_box() method that both scripts were trying to use,... BUT the latter one was not written to work with both scripts, and users trying to use box.rb would never see the box dimensions input dialog appear.
If you did not have make_pano_pm.rb in your Tools folder (dir,) then box.rb would work normally, and you would not notice anything amiss.
I did NOT change or improve box.rb to be a better plugin, because it's not a plugin. It's really a simple code snippet, to be used as an example and a base, from which ruby-newbie's are to play with and improve themselves, thereby learning by doing.