ok well the program I am in the middle of programming I need it to
generate a folder in the c: when it loads up.
does anyone know how I can do this? and possibly make it with an if
variable so if there is already a folder in the c: called action3d dont
generate one but if there isnt then make one
ok well the program I am in the middle of programming I need it to
generate a folder in the c: when it loads up.
does anyone know how I can do this? and possibly make it with an if
variable so if there is already a folder in the c: called action3d dont
generate one but if there isnt then make one
ok well the program I am in the middle of programming I need it to
generate a folder in the c: when it loads up.
does anyone know how I can do this? and possibly make it with an if
variable so if there is already a folder in the c: called action3d dont
generate one but if there isnt then make one
ok well the program I am in the middle of programming I need it to
generate a folder in the c: when it loads up.
does anyone know how I can do this? and possibly make it with an if
variable so if there is already a folder in the c: called action3d dont
generate one but if there isnt then make one
Yet another answer (command line):
ruby -run -e mkdir newdirname
or in rb code:
`ruby -run -e mkdir newdirname`
yeh im using a .rb file to do my codeing. so if I was to put code in
there wanting to make a folder on there c: called temp what would I put.
=) sorry noob to ruby here ^^
all that is doing is adding a new toolbar and opening somthing called a
components panel. now is it possible to add code in here that will
create a folder on there C: called temp and if it is already there dont
overwrite it.
Didnt work for me :s just gave errors. I am codeing ruby in google
sketchup if that helps.
What kind of error did you get and what is the code you used ?
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>false
p Dir.mkdir('~/Documents/fake/nonexistant/directories/new_dir')
#=>0
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>true
p Dir.mkdir('~/Documents/fake/nonexistant/directories/new_dir')
#=>:[-1,-1]:[0,0]: File exists -
~/Documents/fake/nonexistant/directories/new_dir (Errno::EEXIST)
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>true
all that is doing is adding a new toolbar and opening somthing called a
components panel. now is it possible to add code in here that will
create a folder on there C: called temp and if it is already there dont
overwrite it.
Sure.
I'll suppose you are on a UNIX system type (I do not know that sort of
thing on windows, perhaps, it is as simple as changing /temp by
c:/temp or c:\temp)
Just add:
dir = "/temp"
if File.exist?(dir)
puts "#{dir} already exists !"
else
Dir.mkdir(dir)
end
What kind of error did you get and what is the code you used ?
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>false
p Dir.mkdir('~/Documents/fake/nonexistant/directories/new_dir')
#=>0
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>true
p Dir.mkdir('~/Documents/fake/nonexistant/directories/new_dir')
#=>:[-1,-1]:[0,0]: File exists -
~/Documents/fake/nonexistant/directories/new_dir (Errno::EEXIST)
p File.exists?('~/Documents/fake/nonexistant/directories/new_dir')
#=>true
So, everything is working fine: you just can't call Dir.mkdir on an
existant file. That's why you have to use File.exist? to ensure your
directory is not yet in place:
if File.exist?(dir)
puts "#{dir} already exists !"
else
Dir.mkdir(dir)
end
all that is doing is adding a new toolbar and opening somthing called a
components panel. now is it possible to add code in here that will
create a folder on there C: called temp and if it is already there dont
overwrite it.
Sure.
I'll suppose you are on a UNIX system type (I do not know that sort of
thing on windows, perhaps, it is as simple as changing /temp by
c:/temp or c:\temp)
Just add:
dir = "/temp"
if File.exist?(dir)
puts "#{dir} already exists !"
else
Dir.mkdir(dir)
end
any ideas? I am a noob when it comes down to programming etc and have
oinly ever used ruby on plugins. so im not sure what a unix stystem type
is but if it helps im on windows
all that is doing is adding a new toolbar and opening somthing called a
components panel. now is it possible to add code in here that will
create a folder on there C: called temp and if it is already there dont
overwrite it.
Sure.
I'll suppose you are on a UNIX system type (I do not know that sort of
thing on windows, perhaps, it is as simple as changing /temp by
c:/temp or c:\temp)
Just add:
dir = "/temp"
if File.exist?(dir)
puts "#{dir} already exists !"
else
Dir.mkdir(dir)
end
any ideas? I am a noob when it comes down to programming etc and have
oinly ever used ruby on plugins. so im not sure what a unix stystem type
is
Unix is another type of operating system. There are numerous versions
of unix that are slightly different, so a "unix system type" is an
awkward way to refer to any of the unix operating systems.
but if it helps im on windows
Have you seen The Matrix?
Run this program:
puts dir
Compare the output to the output you are getting.
I am a noob when it comes down to programming
Ok, noob. Here is the way it works. You post your code, or better yet:
you construct a small example that duplicates your error and post that.
Then you post the exact error message, AND you put a comment in your
code indicating what line the error is on.
The thing is I need it to make this folder automaticly using script in
the .rb file. what we are doing is giving out cds to our clients where
they can view our 3d models but to video the models they need a folder
called temp in there c: instead of telling them to add it we want it to
make it automaticly. when the sketchup.exe is run
also do you think you could help me out with somthing else on a
program where it has file>help etc at the top is there a way to disable
this so that it does not show?
I'm afraid this is more a sketch'up issue rather than a Ruby one.
I've been looking at the documentation
(http://code.google.com/intl/en/apis/sketchup/docs/ourdoc/ui.html\) but
couldn't find a "hide" method for example for the menu class (so you
could write for exemple UI.menu("File").hide). Ask the dedicated
sketchup mailing lists, the perhaps already have a simple answer to
your request.
Cheers,
···
2009/8/14 Simon Staton <simon@gardengames.co.uk>:
also do you think you could help me out with somthing else on a
program where it has file>help etc at the top is there a way to disable
this so that it does not show?
Just for the sake of thos who didn't know this little trick:
There is a method in FileUtils caklled mkdir_p, which removes the
hassle of checking if the directories and superdirectories exist, and
automatically creates them if not.