SketchUp Command Line: RubyStartup
-
In that video @22:48 - that "Developer Console" ... internal Google tool, or one of the consoles made by people here?
-
@tig said:
BUT a script in Plugins in the form
` def xxx()do some stuff
end
xxx()`
does exactly that ?We use a solution like this when we export a model from ARRIS CAD and import it into SketchUp. We create a temporary .rb file to load the saved geometry - (saved as a ruby file to draw the geometry desired) - and then delete the temporary file.
However, running a ruby script from the command line would be a much better solution.
-
@jim said:
Apparently there is a command-line option to Sketchup that accepts the path to a ruby script and runs the script at start-up.
Would be nice, I can see uses.
Tried it on Windows. Does not work. Either it's a Mac only thing, or he had a "special/internal" compiled version.
-
@al hart said:
@tig said:
BUT a script in Plugins in the form
` def xxx()do some stuff
end
xxx()`
does exactly that ?We use a solution like this when we export a model from ARRIS CAD and import it into SketchUp. We create a temporary .rb file to load the saved geometry - (saved as a ruby file to draw the geometry desired) - and then delete the temporary file.
However, running a ruby script from the command line would be a much better solution.With appropriate premade file you can just type at the command line in the Ruby Console
load'xxx.txt'
The .txt file [which is inside the ../Plugins/ folder] is actually a Ruby script, but without the usual .rb file extension it won't auto-load - but it will load to order.
Inside of the script you have the closing 'xxx()' [after the 'def..end'] so it will auto-run itself once loaded.
Rarely do you need a temporary .rb - a temporary .cmd/.command file [PC/MAC] is another matter...
You could of course load a ruby-command at startup in the usual .rb way but have it take arguments, e.g.
def xxx(a=nil,b=[],c=0) ###do stuff using a, b, c etc end
Then you run it from inside another script with a line like
xxx(selection[0], selection[0].faces, 2)
say to process a selected entity [edge], its faces and an option '2'.
If you don't pass an argument value it also does an action in the formif not a...
etc
OR it will run from the Ruby Console in the same form - perhaps after you've set 'a' asxxx a, a.faces, 2
-
@dan rathbun said:
@jim said:
Apparently there is a command-line option to Sketchup that accepts the path to a ruby script and runs the script at start-up.
Would be nice, I can see uses.
Tried it on Windows. Does not work. Either it's a Mac only thing, or he had a "special/internal" compiled version.
It worked for me on SU7.1 and Win XP.
-
-
Dan, this worked fine on versions 6 Free and 7 Free.
-
@jim said:
Dan, this worked fine on versions 6 Free and 7 Free.
Well... then it appears to need an absolute path. I tried it by going to the SU folder I think.
When Sketchup loads it sets the cwd to HOME (%UserProfile%) so that defeats any change in the directory I made prior to the command.
. -
@thomthom said:
In that video @22:48 - that "Developer Console" ... internal Google tool, or one of the consoles made by people here?
I looked at that Thom, it's simply a BASH shell window (or whatever system shell he's using.)
Ya know, Windows used to have a clone of that shell window, Win95 or Win98. I loved it! Then Win2000 (which is NT,) has nothing but a frame with a scrollbar, and that crummy system menu. It is a royal pain just to cut and paste !! Why didn't MS port the cmd window to NT ??
-
This is very interesting, thanks for sharing, are there other command line arguments to SketchUp? SketchUp.exe --help, /?, etc just launches the program...
Dan
-
After that video, I went looking and found a few:
-template "/path/to/template.skp"
# startup template
-notemplate
# use no template
-page "Scene 1"
# set the staring scene
-timing
# some sort of test?There's more, if you search the .exe for these strings.
Advertisement