How to export a model in the form of .fbx with Ruby API?

Hi everybody, I’m Piraka.

Recently, I’m using sketchup to support a project. And I hope to find a method that can help me export the model in Sketchup by ruby automatically instead of processing it by hands. While, I looked up on the net but found little bout it. So I wish someone can give me some useful idea.

Thanks!

If you have the Pro version, see the “Model#export” method:

1 Like

There are a number of on-line converters, but it appears that they use the Open Asset Import Library. While the library features a lot of input formats, there are only four output formats:

COMMON INTERCHANGE FORMATS
Collada ( .dae )
Wavefront Object ( .obj )
Stereolithography ( .stl )
Stanford Polygon Library ( .ply )

In order to create a Ruby script to export SketchUp geometry in .fbx format, you will need to write your own exporter. This is not as difficult as it sounds, but in this case, the .fbx format is not especially well-documented. However, the ASCII format is somewhat explained here:

http://download.autodesk.com/us/fbx/2010/fbx_sdk_help/index.html?url=WS1a9193826455f5ff-150b16da11960d83164-6c6f.htm,topicNumber=d0e127

and the binary version is somewhat explained here:

You can create either format using the native Ruby file I/O.

Or, as @jim_foltz points out, you can buy Pro … poor me :slight_smile:

it’s relatively easy on your mac using your Pro version of SU…

you will need to manually export the first so that SU registers all of your .fbx options…

are all the files you wish to convert in a single folder?

do they all need to be the same Template i.e. identical style?

if so. Ruby can find the folder, then for each file, import each ‘definition’ into a prepared Template and move it to origin, export to .fbx, delete it, purge unused, import next, rinse and repeat…

john

Thanks to everyone contributing to this topic. Is there anyone able to post a script for converting .skp to .fbx?

If you have a SketchUp Pro edition, over the years, there have been quite a few postings of batch folder export of model files using the various Pro exporters supported by the SketchUp Ruby API’s Sketchup::Model#export method.

You’ll find the posts here or at the SketchUcation forums.

https://forums.sketchup.com/search?q=batch%20folder%20category%3A13
The first “hit” on the search leads to one of TIG’s examples …

1 Like

If you use SketchUp Pro you can automate this workflow with a Ruby script.

View the Ruby API here:

The Ruby API export options are explained here.

1 Like