Importer to our own 3D-Software


#1

Dear Community and SketchUp-Team,

we want to import skp-files in a 3D-Software I developed myself.

I was not able to find guidelines on importing SKP files to other software in the SDK or API sections.

Does anyone here have experience with developing such an importer?

Alternatively, can the SketchUp-Team please set up a contact to someone who can help me on that?

Best,

Sascha


#2

Hi Sascha,
you can either

  • develop an exporter extension for SketchUp using the Ruby API or the C SDK to export to the file format of your software,
  • or use the C SDK to write an importer for your software that can read .skp files.

For the Ruby API, there is no specific exporter class. You basically create a file for writing to (File.open('my_file.xyz', 'w'){ |f| f.puts('text') }) and traverse the active model. Be aware that SketchUp models have a nested component hierarchy, so to export the entities contained in a component you can call the same code that you used for exporting the entities of the top-level model. Even better is to traverse the definitions list (to avoid exporting a component multiple times) and the instances they refer to.

For creating an exporter using the C SDK, you go to “Data Structures” and then “SketchUpModelExporterInterface”.

For reading .skp files directly within your software using the C SDK, you also find a stand-alone example on the index page.