Return SU_ERROR_NO_DATA when call SUApplicationGetActiveModel in Sketchup 2022
Sketchup Version : 22.0.354 Windows Version : win10 SDK Version : 2022.0.354
C/C++ code
#include <ruby.h>
#include <SketchUpAPI/sketchup.h>
#include <SketchUpAPI/application/ruby_api.h>
VALUE async_edge_data(int argc, VALUE* argv, VALUE self) {
SUModelRef model = SU_INVALID;
SUResult res = SUApplicationGetActiveModel(&model);
return rb_int2inum(res);
}
VALUE example= rb_define_module("Example");
rb_define_module_function(example, "async_edge_data", VALUEFUNC(async_edge_data), -1);
Ruby code
Example.async_edge_data
=>9
Are you linking to SketchUpAPI.lib or sketchup.lib? For Ruby C Extensions using the C API for read access to the model it should be sketchup.lib. Linking to SketchUpAPI.lib could potentially lead to issues like this.
Are you linking to
SketchUpAPI.liborsketchup.lib? For Ruby C Extensions using the C API for read access to the model it should besketchup.lib. Linking toSketchUpAPI.libcould potentially lead to issues like this.
yes. I link sketchup.lib.
This is my current solution. It's work. I can get data from model.
VALUE su = rb_const_get(rb_cObject, rb_intern("Sketchup"));
VALUE rb_model = rb_funcall(su, rb_intern("active_model"), 0);
VALUE su_entities = rb_funcall(rb_model, rb_intern("entities"), 0);
VALUE rb_entity = rb_funcall(su_entities, rb_intern("first"), 0);
if (NIL_P(rb_entity)) return 0;
SUEntityRef entity = SU_INVALID;
SU(SUEntityFromRuby(argv[0], &entity));
SU(SUModelGetEntities(model, &ents));
Logged as: SKEXT-4664
Hi LItterBoy-GB
Currently I am going through all the old issues and trying to reproduce. Could you please confirm if this is still an issue for you?
Thanks
#include <ruby.h>
#include <SketchUpAPI/sketchup.h>
#define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
VALUE active_model(VALUE self) {
SUModelRef model = SU_INVALID;
SUResult res = SUApplicationGetActiveModel(&model);
return rb_uint2inum(res);
}
extern "C" __declspec(dllexport) void Init_Example() {
VALUE example = rb_define_module("Example");
rb_define_module_function(example, "active_model", VALUEFUNC(active_model), -1);
}
require 'H:\VS2015_Project\Example\x64\Release\Example.so'
=> true
Example.active_model
=> 9
Thanks for the reply. I have updated the Jira ticket that this is still an issue. Hopefully it gets fixed soon.
Hi LItterBoy-GB
Just wanted to double check that this issue is happening with Sketchup version SU2025.0, right? The Source code link provided by you, is not working for me.
Thanks
Hi LItterBoy-GB
Just wanted to double check that this issue is happening with Sketchup version SU2025.0, right?
Thanks
I haven't tried other versions yet I've updated the link.
Thanks for the update and correct link. As you must be aware that we are not fixing issues prior to version 2023.0, I am going to see if this is still happening with 2025.0.
Thanks for the update and correct link. As you must be aware that we are not fixing issues prior to version 2023.0, I am going to see if this is still happening with 2025.0.
Yes. It is still happening with 2025.0.
Thanks, I am just trying to reproduce it with your source code, running Example.sln, giving me this error
Thanks, I am just trying to reproduce it with your source code, running Example.sln, giving me this error
I have added the third-party library file and used the VS macro variable processing path. Please pull.
Sorry for the delay, just tried and got this error now
Sorry for the delay, just tried and got this error now
After generating so, it should not be started directly in vs. Instead, load so in sketchup and execute the corresponding ruby code.
Yes, I can see the issue now. I will add these details on how to reproduce in the related ticket. I hope it will be addressed soon. Thanks again.
require 'C:\source\repos\Example\x64\Debug\Example.so' => true Example.active_model => 9 Sketchup.version => "25.0.660"