api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Return SU_ERROR_NO_DATA when call SUApplicationGetActiveModel in Sketchup 2022

Open LItterBoy-GB opened this issue 9 months ago • 15 comments

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

Image

LItterBoy-GB avatar Mar 28 '25 06:03 LItterBoy-GB

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.

thomthom avatar Apr 23 '25 16:04 thomthom

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.

yes. I link sketchup.lib. Image

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));

LItterBoy-GB avatar Apr 27 '25 03:04 LItterBoy-GB

Logged as: SKEXT-4664

sketchup[bot] avatar May 05 '25 15:05 sketchup[bot]

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

kalpana-ghodeswar avatar May 14 '25 09:05 kalpana-ghodeswar

Source Code

#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

LItterBoy-GB avatar May 20 '25 06:05 LItterBoy-GB

Thanks for the reply. I have updated the Jira ticket that this is still an issue. Hopefully it gets fixed soon.

kalpana-ghodeswar avatar May 20 '25 09:05 kalpana-ghodeswar

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

Image

kalpana-ghodeswar avatar May 29 '25 14:05 kalpana-ghodeswar

Hi LItterBoy-GB

Just wanted to double check that this issue is happening with Sketchup version SU2025.0, right?

Thanks

Image

I haven't tried other versions yet I've updated the link.

Source Code  源代码

LItterBoy-GB avatar Jun 11 '25 03:06 LItterBoy-GB

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.

kalpana-ghodeswar avatar Jun 11 '25 07:06 kalpana-ghodeswar

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.

Image

LItterBoy-GB avatar Jun 11 '25 07:06 LItterBoy-GB

Thanks, I am just trying to reproduce it with your source code, running Example.sln, giving me this error

Image

kalpana-ghodeswar avatar Jun 11 '25 07:06 kalpana-ghodeswar

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.

LItterBoy-GB avatar Jun 11 '25 07:06 LItterBoy-GB

Sorry for the delay, just tried and got this error now

Image

kalpana-ghodeswar avatar Jun 11 '25 08:06 kalpana-ghodeswar

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.

Image

LItterBoy-GB avatar Jun 11 '25 08:06 LItterBoy-GB

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"

kalpana-ghodeswar avatar Jun 11 '25 09:06 kalpana-ghodeswar