Is it possible to insert with DataBase linked to the sketch-up file and Ruby on Rail?

Hello
I’m a novice developer of Sketchup Plug-in.
I wonder if the sketchup file format (.skp) is available through Ruby on Rails.
For example, I wonder if data (ex: length, width, etc.) from files created in SketchUp can insert those data into DataBase linked through Web programming such as RubyOnRails.

Hi,

The Ruby API is only available in the SketchUp application. The C SDK however should be possible to use in a Ruby C extension to extract such data.

@Salvation

This would be extracting data directly from SKP files, on the web server, within your Rails app.

See:

However, the C SDK is available only for MacOS and MS Windows platforms.
(There are no other platform builds, such as Linux, available.)

For an embedded extension running within the SketchUp application, it might be possible to host your Rails app from your website within a Sketchup::HtmlDialog window.

But, the SketchUp Ruby API process communicates to webpages via JavaScript eval function, and back to SketchUp through a sketchup JavaScript object. (See the documentation for the Sketchup::HtmlDialog class.)

So Ruby on Rails would need to have a means to access to the JavaScript process of the Chromium browser. (You would likely end up writing a couple of communication functions in JavaScript that “talk” back and forth to Rails.)

Perhaps @MSP_Greg has some ideas ?

@Salvation

Assuming a user running the SketchUp (SU) desktop app, almost all model data is accessible thru the Ruby API.

You could use either the net/http classes or the SU API Sketchup::Http::Request class to push data to a Rails app.

SU’s Ruby API allows one to create toolbars, toolbar buttons, and menu items for basic UI needs.

For more interactive UI needs, one can create embedded browser (html/js) windows, with methods that can move data between SU Ruby and the windows’ js engine. These windows can also issue http requests using js.

So, yeah, it certainly could be done.

2 Likes

Thank you for your answer, have a nice day!