Drag And Drop my own file extensions in sketchUp


I have created a SketchUp plug-in containing a button that is able to read a text file with some geometry data and build a sketchUp model from that. The mechanism is very simple, just clicking the button triggers a UI.openpanel where the user can navigate the PC and select the appropriate file. This file has a particular extension of my own (filename.myext)

I have two questions here,

  1. Is It possible to make sketchUp recognize a drag and drop of filename.myext and trigger the button with the file?

  2. Is It possible to use windows command line to open SketchUp and make it click the button with a given filename.myext

I think this two things will make my plug-in more user friendly, hope there is a way to make it possible.

best regards, Carlos

I have seen something similar - using the Class: Sketchup::Importer - in e.g. this two extension:

(These are not encrypted so you can look into it, how she did it.)

There could be some command line to load fexternal file with SU, but for sure you can not achieve the “make it click the button”…
Someone else may give you better answer.

1 Like

This is called an Importer and the SketchUp API has a common interface for this via the Sketchup::Importer class (as @dezmo mentioned.)

Please use this interface as users know to go to File > Import which opens up the native openpanel and the user can choose your filetype and then open an options dialog.

Also if you implement an options dialog, it will automatically pop up after a drag and drop action.

Triggering this from a toolbar button is out of the norm for the SketchUp application.

1 Like

Yes it is possible to run sketchup.exe from the command shell or a batch file and add a option switch to run a particular ruby script. That script could instantiate an instance of your importer, but would also need to call the do_options callback (if using it,) and then call the #load_file callback.

To get the filepath, it would need to get this from an Environment variable that the batch command set before SketchUp loaded. SketchUp’s Ruby creates a hash-like object named ENV that holds a copy of the environment when SketchUp loaded.

The Ruby script that starts your importer needs to be in a subfolder of the “Plugins” folder so that it does not run automatically when SketchUp starts.


1 Like

Hi dezmo and DanRathbun

thank you very much for your answers, I think I figured out my first question. @DanRathbun as you indicated there is no need for the button and UI.openpanel since File > import does what I need. Just one thing, I notice drag and drop my fileextension works on SketchUp 2019 but not in 2018. Is this a feature for SketchUp 2019 and later?

regarding my second question it looks a little more tricky but I will be trying in the coming days, I will post here if I have problems

regards, Carlos

You are right, but more precisely since 2019.2 _ :wink:

SketchUp Desktop 2019.2 | SketchUp Help

Importing files. The days of picking out your import file format from a long list are over. You can now drag and drop ALL supported file types directly into your modeling window. By default, you’ll now see all supported file types available for import…