Rendering into the SketchUp View via Ruby extension based on C/C++ native implementation

I requested and received the Sketchup SDK to develop c/c++ based extensions. Problem is that I want to call native SDK based code which is linked to my ruby extension. I want my native code to access scene objects, modify them or even render new type of data in the Opened sketchup scene. It seems that none is possible. First of all, native SDK seems to work on it own created Model (entities, etc) structure, not the opened Sketchup’s model structure even if I call it from ruby extension. So, SDK can only modify a separate SU Model just to write/export it to a file. I know this fact is already mentioned in the SDK page.
Problem is, I already examined a plugin named “Undet for SketchUp” which can render and modify point cloud data in Sketchup scene. The link to the plugin video is here: - YouTube . This is quite an advanced plugin. So there are two possible option to do such a thing. Whether there is a low level native SDK that I could not find. Or it is somewhat done through OpenGL render hook or something similar which is a indirect and tricky method (considering it is possible for Skethup scene render context).
Is there any one who knows anything about these subject?
Thank you in advance.

At the moment the C API does not work inside of SketchUp. It’s being worked on.

For now the only API that have access to the opened SketchUp model from within SketchUp is the Ruby API.

(Moved to SketchUp SDK category.)

The old C++ SDK used to be able to do it, but is deprecated. (Perhaps this extension you mention is still using the C++ SDK ?)

It was said for the 2014 or 2015 release, … that the old C++ DLLs will be removed in two release cycles.

Thank you for the fast replies. While doing my research I have come to a similar conclusion. What I do not get is that this Undet point cloud extension ( - YouTube ) still seems to be available for SU 2016 which I am not sure by the way. I recently request a trial for the plugin and did not received it yet. I believe such rendering can not be done with basic entities (such as face, etc) that is already available to Sketchup. Its rendering would be too slow since point cloud data is very big in size. I believe a low level access is necessary to OpenGL scene view’s handle to be able to utilize OpenGL vertex buffers directly. That was why I came to believe that this plugin my be achieved via utilizing OpenGL rendering hooks. For some 3D applications, it is possible indeed since it depends on the rendering infrastructure of the application. Of course my belief is totally theoretical and in reality old SDK may provide such an API.
Do you know whether old depreciated SDK allow to develop a native application to render a very different object such as point clouds?
Thank you.

By the way is it really possible the old SDK still works for latest SU 2016. If it is, why not let it be used by extension developers since it is more powerful. Is it because of security and reliability concerns?

The documentation is supplied within the SDK package:
SDK/deprecated/SkpReader/Documentation

Probably as the new C API is not fully complete. The “hook” is in the documentation somewhere. BUT, … expect it to not work in future SketchUp versions.

Thank you very much for the help. I will check it

I don’t think even the C++ SDK exposed any way to hook into the GL drawing context - if that’s what you are looking for.

1 Like

I was not expecting the SDK expose a hook indeed, since it is a SDK, they would instead provide an API to provide a low level access to the OpenGL context directly. But from what you imply before, such low level API was never seem to existed in any version of SU SDK.
Hook I am talking about is similar to event hooks where you can use to listen other process windows event messages, which is done via the SetWindowsHookEx WinAPI function
Sometimes, such hooks may also be possible for type of application which have a OpenGL rendering context. I am talking about a direct hook to OpenGL rendering events itself described similar in Google search results for “rendering hook to opengl” keywords. Sorry that I can not put more links in the discussion, as systems won’t let newcomers as me more than 2.
It is just a possibility depending on the application. I have to invest considerable effort to test the idea on SketchUp, and it would most probably in vain.
What I got from you guys was quite considerable insight, since there are lots of unclearness about old and new SDK, which sample stands for which, etc.
So, many gratitudes.

How about View.draw_points to draw points in Sketchup?
http://www.sketchup.com/intl/en/developer/docs/ourdoc/view#draw_points

I can imagine UNDET calculates which points have which colors and then, for each different color, performs a View.draw_points operation.

All of the View#draw methods must be used from within a Ruby Tool instance.
http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool


Neither the old obsolete C++ SDK, nor the newer C SDK have a Tool class / interface. They were / are designed to work upon files, first and foremost.

Because of this, neither of them had any interface to SketchUp’s View object.

(BTW, I’ve edited the topic title and replaced the word “Scenes” with “View”, because this topic is discussing the View object not Scene objects (which are more like property behavior pages that can be applied to the current view.)

But Ruby itself is written in C, and Ruby (and therefore SketchUp) extensions can also be written in C.

You can get a reference to SketchUp’s current view object from a C extension, but without observers, and an interface, other programmer’s tools and SketchUp’s own native tools will just fight against you. Or worse, you’ll interfere with SketchUp or other companies’ extensions and that will prevent their products from working. (And that can be a legal situation.)

view.draw_points only draw a pixel at a time - no way to control size. Drawing lots of points with different colours will be terrible slow due to the number of calls you have to make.

I’m not sure what undet do - there are those who find a way to poke into the inners of the rendering pipe.

The real problem would be speed indeed, point clould is very large data,so you need a fast graphics card access to draw it

Hi thomthom,

When it is estimated to be released, I mean the C API. Version 2017? :grimacing:

The C API is released already - but it doesn’t have complete feature parity and doesn’t work within SketchUp. I don’t have a specific release date for when these features will be complete.

New SDK major versions always get released with (or shortly after) the major SketchUp application releases. This happens in the autumn, usually in November, and has coincided the past few years with the Trimble Dimensions User Conference.

Any progress on this? I am also looking for some kind of methods to render point clouds (or triangulate meshes, but not the ones as entities) in sketchup.

After some work, I think the only possible way is to obtain the GL context through windows API and then do some magic stuffs with the GL context.

Hope somebody worked this out and will be kind enough to share his solution.

Sorry no progress at all, since I am doing some other plugin for sketchup. I did not dig in any further. But I agree with your approach. GL context should be retrieved and render events should be hooked by low level winapi methods to be able to render fast point cloud. DanRathbun and thomthom already stated that current sketchup API is not appropriate for the job. I find it possible that “Undet point cloud extension” uses such an approach.