New developer guidance - GUI extension

Hello,
I’m new to developing Sketchup and come from a c# background. I am looking for general guidance or advice about developing my first SketchUp plugin / extension with a GUI interface.

My questions are:

  1. Are there any XMAL methodologies for creating a SketchUp GUI - for example do people use the XAML tools provided by UWP methodologies or are other methodologies better -

  2. Before I begin my work are there methodologies useful for developing cross platform (Mac / Windows) SketchUp plugins that I should know about or consider leveraging?

  3. I’m assuming that it’s still best to use Visual Studio but if there are other IDE that people recommend please feel free to mention them.

Appreciate all thoughts and recommendations - thanks in advance.

Sincerely,

One important question: your forum profile says you are using SketchUp Free. Are you aware that Free cannot run extensions? If you actually have Pro, please update your profile.

Slbaumgartner,
Thank you for the suggestion - updated.

Generally, SketchUp extensions are coded either in Ruby atop the built-in SketchUp Ruby extension API and runtime interpreter, or in C/C++ with hooks into the Ruby API for cases when Ruby is too slow at bulk data operations. There is a C SDK, but it is mainly for creating standalone apps to manipulate SketchUp files, or importers and exporters for file types that are not supported by SketchUp natively. It does not provide separate GUI capabilities. See https://developer.sketchup.com for more information.

If an extension has a GUI, it is normally built using objects from the UI module of the Ruby API. It provides several basic dialogs and a more flexible HtmlDialog class. There is an event-driven protocol called “Tool” that handles most user event interaction with an extension and also allows drawing to the model view window without affecting the SketchUp model itself.

I suspect that using something like XAML to create a GUI within SketchUp would cause clashes over handling of the user event stream and management of the display. But perhaps someone who has actually tried it will jump in and either confirm or correct this statement.

In general, extensions only run into Windows vs Mac portability issues if they draw directly on system libraries from a specific platform, such as Win32 or rely on C code compiled for a specific platform. If you stick to Ruby and generic C/C++ libraries, there should be no problem aside from likely needing to compile separately for each platform.

Any IDE that supports both Ruby and C should work. Choice among them is largely a matter of familiarity and comfort level.

1 Like

For cross platform “live” C extensions, you’ll need to know Ruby anyway.
(Ruby itself is coded in C, so it also has a C API.)

For Windows, you’ll likely use either Visual Studio or VS Code. (The SketchUp has explanations of setting up a project and how to hook up the SketchUp Debugger library.)
For Mac, it would be Xcode I believe. (I’m not a Apple consumer myself.)

LINKS ( ... click to expand...)
2 Likes

As mentioned, the Ruby API is the API for creating extension in SketchUp.

The C API is mainly for reading/writing SKP files in third party applications. (Though also used to create importers/exporters for SketchUp.

For UI with the Ruby API the usual way is using UI::HtmlDialog (Chromium dialogs). Some examples;

VSCode works really well for development:

RubyMine is also a good editor for Ruby work.

If you need to dive into more low level stuff Ruby itself has a C API: The Ruby C API

You can use the SketchUp C API from a Ruby C extension, but only for read only operations. (Unless you are writing a render engine that needs to read the whole model frequently I’d recommend just sticking with the Ruby API for extension work.)

You can then use anything that can interop with C from within a Ruby C extension:

When doing Ruby work you need the debugger to hook a Ruby debugger to SketchUp’s Ruby: GitHub - SketchUp/sketchup-ruby-debugger: Ruby API debugger for SketchUp 2014 and later.

There is also static analysis for Ruby via rubocop, where we made an extension to the tool to provide SketchUp specific insights: GitHub - SketchUp/rubocop-sketchup: Rubocop cops for SketchUp - test against our Extension Warehouse technical requirements and other pitfalls

2 Likes

Hello community. I’m new to developing and starting to learn Ruby as well. I’d like to ask if there is a tool or something that record our movements, commands and clicks inside SketchUp and write the code like in Excel Macros and VBA. Thanks!

No, sorry. No macro feature. You might look into the Live Components beta.


P.S. - And please begin a new question topic when it is off-topic.
(This one is specific with regard to what GUI frameworks are available.)