I am looking for a way to convert several skp, kmz or dae files at once into 3ds or fbx format. In sketchup pro you can do export as...3ds or fbx but that would take too long to open each file and export it. Is there a command line in sketchup, or a script that could be used to perhaps automate this process? Thanks
Is there a command line in Google Sketchup to export in 3ds or fbx format?
Asked Answered
you need to invoke sketchup from the command-line specifying a script to run immediately
sketchup.exe -RubyStartup d:\scripts\runexport.rb
in your ruby script (runexport.rb
) you can
load your model. See http://code.google.com/apis/sketchup/docs/ourdoc/model.html#import
export your model. See http://code.google.com/apis/sketchup/docs/ourdoc/model.html#export
and finally, shutdown sketchup. See http://forums.sketchucation.com/viewtopic.php?f=180&t=29162
For recursively walking the directory, try this ruby code (from wikipedia)
Pattern matching using regular expressions
#define a recursive function that will traverse the directory tree
def printAndDescend(pattern)
#we keep track of the directories, to be used in the second, recursive part of this function
directories=[]
Dir['*'].sort.each do |name|
if File.file?(name) and name[pattern]
puts(File.expand_path(name))
elsif File.directory?(name)
directories << name
end
end
directories.each do |name|
#don't descend into . or .. on linux
Dir.chdir(name){printAndDescend(pattern)} if !Dir.pwd[File.expand_path(name)]
end
end
#print all ruby files
printAndDescend(/.+\.rb$/)
that worked great, but how would i do a batch import from a folder and export them using their own filename. sorry but i'm new to Ruby. Thanks –
Caravan
that translates into "how to pass command line parameters to a startup ruby script" ... and I believe the answer is "no way". So, you'll have to figure out a way to represent in your script a list of files previously built by the bat that invokes sketchup. –
Rice
no I was thinking more like run the comamnd line once, but in the .rb file there is some code that gets a list of files from a directory, imports them and exports them. I was looking at something with Dir["*"].each {} but haven't gotten it to work yet. You think that would work? –
Caravan
I couldn't edit my own comment... SO timed me out. Editing my answer. –
Rice
Is it possible to get a sample script including all the steps? I'm trying to convert .skp to .fbx –
Embarrass
© 2022 - 2024 — McMap. All rights reserved.