How to call export options window in Ruby API

Is there a way to call export options window for obj from ruby?
image
I found

  .send_action(action) ⇒ Boolean 

but I couldn’t find any parameter corresponding to this window.

I’m not sure what you are trying to do. Do you want to start an export and let the user enter their preferences, or do you want to get the info the user enters? You can export using the API but I think you have to set the export options yourself.

3 Likes

Yes, I want to start an export and let the user enter their preferences.
I am able to make an export setting some preferences, but I need to let the user to choose themselves.
Do I need to create my custom window?

I’m afraid that the API doesn’t expose the user input dialogs for the exporters. (We only recently got the export option hash supported for all exporters.)

You can file a feature request in our API issue tracker: https://github.com/SketchUp/api-issue-tracker/issues

Thanks a lot, I got it.

you can check what they have set before or if they haven’t…

# mac path
file = File.read(File.expand_path('~/Library/Application Support/SketchUp 2019/SketchUp/SharedPreferences.json'))
result_hash = JSON.parse(file)
result_hash["Shared for All Computers"]["Obj Exporter"]
# => 
{"ExportDoubleSidedFaces"=>true, "ExportEdges"=>true,
 "ExportSelectionSetOnly"=>false, "ExportTextureMaps"=>true,
 "ExportTriangulatedFaces"=>true, "ExportUnits"=>0, "SwapYZ"=>true}

john

SketchUp’s Ruby API is mostly not focussed on GUI automation (like macros often are), but rather on automating the underlying functionality. That is why you would provide the options hash (which you can build from a custom input box or HtmlDialog). Calling the GUI exporter would be handy in this case.

But I still think it is important to keep API methods cleanly separated that are either purely programmatic or interact with the GUI (blocking operations, or requiring user input). There was for example the case with place_component that caused confusion.

3 Likes