Argh ... thx anyway Dan !
Posts
-
Getting the "circle steps" ???
Now I need to get the "steps" a circle is build of (standard is 24) but it can be changed dirung a session and then resets to 24 again when SU is restarted.
How can I "get" this "step" as a number and use it in my code ?
-
RE: Drawings for milling ????
@dave r said:
You could use a shape representing the volume of space through which the cutter would pass. Intersect it with the shape then delete the cutter and the waste.
Yeah, but try do it and show me by attaching file
-
Drawings for milling ????
When using a mill for metal you aften need do something like the attach file.
How can I make such drawings ?
I did the drawing by using the LINE-tool to draw the "connected faces" - but there must be a better method !
-
RE: Will NOT scramble ??
@dan rathbun said:
OH wait !!
I'll fix the example. Sheesh that was a dumb one.
(I had actually tested it with the "load on start" parameter, set tofalse
. So this error did not happen for me in testing.)DONE
Now I see the contours of a TEMPLATE for future plugins made in THE RIGHT WAY in a HURRY - that's good practice I think !
Still I have some claims and I'll try figure it out myself before I seek you help
-
RE: Will NOT scramble ??
@dan rathbun said:
@ksor said:
@dan rathbun said:
@ksor said:
Now I can't use the danish special signs æøåÆØÅ instide a string without fooling the interpretor !
Are you saying that UTF-8 characters do not work inside scrambled rubies ???
Did you save your unscrambled rb file as "UTF-8 without BOM" (aka "ANSI as UTF-8"), before scrambling ???
What I say is that I used some ordinary danish characters æøåÆØÅ and the the interpretor crashed with a lot of errors !
If I saved with or without BOM ... how should I know !
It is on the Notepad++ Status Bar:
[attachment=1:1waa5u4s]<!-- ia1 -->NPP_Status_Bar.png<!-- ia1 -->[/attachment:1waa5u4s]@ksor said:
Tell me WHAT I should save it as -
"UTF-8 without BOM" on the menu. (aka "ANSI as UTF-8" on the Statusbar):
[attachment=0:1waa5u4s]<!-- ia0 -->Encode_Menu_NPP.png<!-- ia0 -->[/attachment:1waa5u4s]@ksor said:
... and I hope this BOM or not could be set up automatic - where do I do that ?
see the topic on Notepad++:
[Info] Notepad++ : Tip, Tricks & PluginsIt IS this encoding !
-
RE: Will NOT scramble ??
Dan - again you are there right before the ship goes down - a really nice lesson you've done !
BUT ...
I tried to use it and create the folder structure and replaced my name for AUTHOR and my plugin name for WIDGET and when I run SU I get this completely non-sence error message, and I think I've carefully watched upper and lowercase - done the scrambling:
Error Loading File C:/Program Files/Google/Google SketchUp 8/Plugins/KSOR/Remskive/remskive_loader.rb
(eval):39:inrequire': uninitialized constant KSOR::Remskive::ABSDIRError Loading File KSOR_remskive_ext.rb (eval):39:in
require': uninitialized constant KSOR::Remskive::ABSDIRis it "remskive_loader.rb" that's wrong ? the file has 1 line !!!!!!!!!!!!!!!
OR
is it "KSOR_remskive_ext.rb" that's wrong ? line 39 is a COMMENT !!!!!!!!!!!!
OR
-
RE: Will NOT scramble ??
@dan rathbun said:
@ksor said:
Now I can't use the danish special signs æøåÆØÅ instide a string without fooling the interpretor !
Are you saying that UTF-8 characters do not work inside scrambled rubies ???
Did you save your unscrambled rb file as "UTF-8 without BOM" (aka "ANSI as UTF-8"), before scrambling ???
What I say is that I used some ordinary danish characters æøåÆØÅ and the the interpretor crashed with a lot of errors !
If I saved with or without BOM ... how should I know !
Tell me WHAT I should save it as - and I hope this BOM or not could be set up automatic - where do I do that ?
I think I'll HAVE to spend more time looking at your lesson on this matter to get this BEEP up and running !
-
RE: Will NOT scramble ??
This code samples sucks more and more of just killing time !
Now I can't use the danish special signs æøåÆØÅ instide a string without fooling the interpretor !
I get very, very tired when things like tha tcomes up ... Zzz ZZ ZZZZZ yawning .... prusssssss
-
RE: Will NOT scramble ??
@tig said:
You have a script xxx.rb file that is placed in the Plugins folder.
this file will then auto-load/run, and thereby it creates an Extension.
It also sets /tool_folder/yyy.rb to be loaded IF the Extension is active, but not otherwise.
The /tool_folder/yyy.rb file is a 'loader' script.
It does not auto-load/run because it's in the subfolder - but it is activated from the xxx.rb file that itself loads from Plugins, IF the specified Extension is active...
When loaded the yyy.rb file will create, menus, submenus, context-menus and toolbars... AND it loads the file[s] /tool_folder/aaa.RBS etc - which are your files containing the main code for your tool[s].
RBS files are compiled but IF you are not compiling them they will simply end in .RB and will be human-readable...
The Plugins subfolder, referred to above as 'tool_folder', is your own subfolder in Plugins; and inside which you package your main tools' files.
It can be a single user named subfolder with more subfolders for each tool - e.g. then you'd use Plugins/KSOR_tools_folder/tool_aaa/yyy.rb - or it can be a tool-specific folder like Plugins/KSOR_tool_aaa/yyy.rb - you choose...
This subfolder [or its subfolders] can also contain any images needed for toolbar-buttons and the many files used to make webdialogs etc...A good one - I'll try to get the structure set up - but a little fire was started in the end and a little smoke came up ... ha, ha !
-
RE: Will NOT scramble ??
@thomthom said:
Plugins/foobar.rb
<span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /></span><span class="syntaxdefault">require </span><span class="syntaxstring">'extensions.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br /> module PluginName<br /> <br /> </span><span class="syntaxcomment"># Constants<br /></span><span class="syntaxdefault"> PATH </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> __FILE__ </span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> </span><span class="syntaxstring">'PluginSupportFolder'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">).</span><span class="syntaxdefault">freeze<br /> <br /> </span><span class="syntaxcomment"># Extension<br /></span><span class="syntaxdefault"> loader </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'loader.rb'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ex </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> SketchupExtension</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Hello Scrambled World'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> loader </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">description </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Lorem Ipsum"<br /></span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'1.0.0'<br /></span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copyright </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith © 2012'<br /></span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">creator </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith (john@example.com)'<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">register_extension</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author </span><span class="syntaxdefault"></span>
Plugins/PluginSupportFolder/loader.rb
<span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br /> module PluginName<br /> <br /> </span><span class="syntaxcomment"># Menus and Toolbars<br /></span><span class="syntaxdefault"> unless file_loaded</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> m </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Plugins'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> m</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">...</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> <br /> </span><span class="syntaxcomment"># Load the rest of the files - which might be scrambled.<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file1'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file2'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file3'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author<br /><br /></span><span class="syntaxdefault">file_loaded</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span>
Sorry, but I still don't understand - are the two code samples two alternatives or ONE way to do WHAT ?
In the second code you have "PluginName" - what is that compared to the items under the Plugin menu ?
and what is it compared to the "the rest of the files" ... file1, file2 and file 3 ?How are the folder structure - should ALL my .rb and .rbs files be store in the PluginSupportFolder ?
Are "loader.rb" a peace of code that load ALL my plugins under the menu "Plugins" or .. ?
Please give me some overview of the structure.
I get this error message when running SketchUp:
Error Loading File C:/Program Files/Google/Google SketchUp 8/Plugins/PluginSupportFolder/loader.rb
tried to create Proc object without a blockError Loading File Foobar.rb
tried to create Proc object without a block -
RE: Will NOT scramble ??
@dan rathbun said:
This may also work with a shortcut icon for scrambler.exe ??
It WORKS fine with the shortcut too - really great Dan !
-
RE: Will NOT scramble ??
@dan rathbun said:
On MS Windows...
You can scramble files from the GUI without opening a cmd shell.
Just drag and drop an rb file (from Explorer window 1,) ONTO scrambler.exe (in another Explorer window.)
.. and the rbs file will be put in the original folder with it's rb file.
This may also work with a shortcut icon for scrambler.exe ??
- This works great on XP, Windows 6+ users need to have write permissions the destination folder.
Oh ... Dan, that was a good one - thx !
I'll implement it right away !
-
RE: Will NOT scramble ??
Thx - thomthom, I'll study the code carefully !
-
RE: Will NOT scramble ??
thomthom
I think so - but how to implement it if it should NOT be done like I did BEFORE and AFTER TIG made me move my menu settings from/to the primary .rb-file - do you have some sample code ?
-
RE: Will NOT scramble ??
@thomthom said:
On a sidenote - it can be confusing for the user if the menus are always there - regardless if the extension is loaded. And it'd defeat the purpose of using the extension. Menus should be loaded by the script that SketchupExtension loads.
????
Maybe I misunderstands you - english isn't my first language - but isn't exactly the opposit of what TIG told me to do ? -
RE: Will NOT scramble ??
@thomthom said:
@ksor said:
I just did the same as with the .rb file - just clicked in the menu: when run by .rb the "A" comes up, when run as .rbs nothing happens - no error, nothing at all.
There is something else going on. I tried that Polley snippet you posted - scrambled it. Loaded the .rbs and wrote in the console:
x=Polley.new
The messagebox popped up.Did you try exactly that small snippet yourself - or did you extract it from your main code? Sounds like your issues lies with the construct of your plugin.
Since you don't get any messagebox, nor any errors when it should pop up it sound like something is overriding the initialize method.
(Remember you cannot reload a .rbs - you must restart SketchUp to see any changes.)I did EXACTLY that snippet af code - and I start SketchUp from scratch each time I do some tests.
I start it as an extension as recommended and this primary code is here:
require 'sketchup.rb' require 'extensions.rb' filename=File.basename(__FILE__) if(not file_loaded?(filename)) UI.menu("Plugins").add_item("Remskive") { Sketchup.active_model.select_tool Polley.new } end file_loaded(filename) # Create the extension. ext = SketchupExtension.new 'Remskive', 'Remskive/Remskive_LOADER' # Attach some nice info. ext.creator = 'Keld Sørensen, Danmark' ext.version = '1.0.0' ext.copyright = '2012..., Keld Sørensen' ext.description = 'Visit my website; http://kelds.weebly.com/udvidelser.html' # Register and load the extension on startup. Sketchup.register_extension ext, true
-
RE: Will NOT scramble ??
@thomthom said:
@ksor said:
The "A" never comes up - maybe the scrambler IS a prototype - then just say it then.
So when you do tried
Polley.new
nothing happened - no error at all?Your example didn't include anything about how you tested it - maybe there is something there.
I just did the same as with the .rb file - just clicked in the menu: when run by .rb the "A" comes up, when run as .rbs nothing happens - no error, nothing at all.
I never used so much time on so little code with so little outcome - it feels like just killing time !
-
RE: Will NOT scramble ??
@tig said:
You only need to call
require 'sketchup.rb'
once in a session [it might have been called earlier by another script anyway],
do should that in your 'loading' .rb file that makes the 'extension'.
Then you can omit it from the .rbs because it's already loaded...
OR alternatively try to use
Sketchup::require 'xxx'
inside a compiled script, which should work...?????
Ha, ha just a new smokescreen ....
Whether or not I have the "require 'sketchup.rb'" is not the point - and it has NO difference on the problem !
The point is if the scrambler IS a prototype or NOT ... and you have not a single word about it !
I remember to have read somewhere in this forum, that it maybe would be a good idea to write a better scrambler .... I would add: maybe a better interpretor too - not to mention an editor with some intellisence .... that would be really nice.
There is much too much 'really low level' debugging going on in what should be a high level language.
.... but take Ruby as it is or leave it !
-
RE: Will NOT scramble ??
@tig said:
:roll: OK... perhaps I should have said something like using 'FILE' won't work inside a .rbs compiled script consistently...
When a Ruby runs it has FILE got from the script's own path, which is unique to each script....Ha, ha, I think I'm the one who should do the !
Can I ask (and get an answer of cause ) is the SCRAMBLER just a prototype ?
And please don't turn the focus to me trying to scramble menu setting - that's not the point - it's just a smokescreen over the real problem I think.
Even this simple code doesn't work when scrambled and loaded as an extension:
require 'sketchup.rb' class Polley # store bogstaver evt. med _ er en CONST MINDIAP = 50.mm MINDIAA = 10.mm MINKRVD = 25.mm MINKRVB = 15.mm def initialize() UI.messagebox("A") end #initialize def draw_pulley() end # draw_polley def input_dialog() end # input_dialog def makePulley(diaP, diaA, krvD, krvB) end # makePulley end #class
The "A" never comes up - maybe the scrambler IS a prototype - then just say it then.