Is there an SDK to develop custom APIs for Skectchup / Ruby in C # in Visual Studio. This interests me a lot and I think there is a lot to do.
I am in SketchUp pro 2020 and Visual Studio pro 2019 (the last one)
Thank you for your answers
Iāve never had the need to manipulate SKP files outside of SketchUp. I think I do remember seeing a C# wrapper for the C SDK, but have never used it. C# is my favorite language, and with WPF it is easy to design a very nice UI.
In this thread I did post some code where I had a WPF app communicating with SketchUp.
The problem with that approach is that the WPF app is a separate app, so clicking the SketchUp window hides the WPF window behind SketchUp (unlike the SketchUP HTMLDialog window which stays on top). I could set my WPF window to be āalways on topā but that is a real nuisance because it stays on top of other apps as well. Iām in the middle of doing a major update to my Building Creator extension, and Iām going back to all HTMLDialogs for the UI. There are still things I plan to use C# for such as generating xlsx spreadsheets. Ruby in SketchUp is limited when it comes to things like that. For that case Iāll probably write the C# app as a command line app that runs in the background.
Another reason Iām going to all HTMLDialogs, is because I still have my fingers crossed that SketchUp will someday implement docking HTMLDialogs as a first class citizen in SU.
C # is also my favorite language because it is a real object oriented language unlike C ++.
I just want to give a little clarification, I donāt need the C # language to manage skp files. Iām just trying to create a small, user-friendly dialog interface for use with sketchup.
Maybe i can use html code but i donāt know how to do that.
Sorry for my bad English and donāt hesitate to correct me if necessary.
I understood this. Thee is no embedded official C# API for SketchUp.
Yes, SketchUp has the Chromium Embedded Framework for UI::HtmlDialog class.
This means you may need to know HTML, Javascript and CSS to make HTML interfaces.
There were several attempts to make pure Ruby libraries that would auto generate the UI::HtmlDialogs.
The latest is:
the āUI.select_directoryā method works really well but is there a similar method to reach files like āselect_fileā (windows explorer?).
Or is there a source in C or a dll that I could use?
If necessary, I can do it in C - itās easy - but then, how can I integrate it into my ruby code ?
The UI::openpanel always returns a valid filepath (unless the user cancels the dialog). The openpanel also allows multiple filetype filters for the MS Windows platform.)
The UI::savepanel allows the suggestion of a filename and file extension, but the user can override these (including giving an incorrect file extension.) The user may also attempt to use invalid characters that are not allowed in path strings and filenames. (Ie, code defensively.) Also, the user can navigate away from your suggested directory path.
As with the other method, the user can cancel the dialog.
The results from these methods (and that of UI::inputbox) should always be checked for a false eval, and if so ā¦ exit the command. (Ie, take it as an indication the user wishes to cancel the task.)
Example:
def open_model_command
filter = Sketchup.platform == :platform_win ? 'SketchUp Model|*.skp||' : '*.skp'
filepath = UI.openpanel("Select model to load", ENV['HOME'], filter)
return if !filepath # user cancelled !
# Continue with task ...
Sketchup.open_file(filepath)
end