I am new in ruby and c.when I try to code by the example show in the c sdk I have a problem when I want to load my dll.The dll is just compiled by vs studio2015.And I put the dll in the ruby’s search path. I just use ruby code editor and fiddle lib to load the dll. But the Ruby says unknown symbol ‘myfunction name’. who can help me. thanks a lot.
… and please do not post images of code. Cut and paste the code into a delimited code block.
(2) You cannot use the C API to change a live model at this time. You can only read stuff from the model, say for creating an exporter, or building another model file that is not the active model.
The C API was written for 3rd party applications to create importers and exporters for their applications.
// Must release the model or there will be memory leaks
SUModelRelease(&model);
// Always terminate the API when done using it
SUTerminate();
return 0;
(4) You do not need Fiddle to load a Ruby C extension if you’ve properly defined a Ruby entry point function … ie "Init_SameNameAsDLLfile"
You just use the global require() defined in the Kernel module (which is mixed into Object making it global.) … from the doc for this method (with emphasis by me) …
If the filename has the extension “.rb”, it is loaded as a source file; if the extension is “.so”, “.o”, or “.dll”, or the default shared library extension on the current platform, Ruby loads the shared library as a Ruby extension.
(5) The entry point function should define Ruby object to access C functionality. Ie, it should create your module objects (your toplevel namespace module, and it’s extension specific submodule,) and within those define Ruby methods that when called in Ruby, fire off C or C++ functions.
(6) Then please first learn how the SketchUp API works using Ruby scripting. Creating C Ruby extensions is very advanced.
thanks a lot 。but I still want to know how to use fiddle to call c dll. I modify the code .try to using ruby to call ''test ‘’ which is not entry point function.but still can’t get it. could you please tell me the reason. the editor still tell me that ‘unknown symbl’.
the h file
require "fiddle"# Default code, use or delete...
libm=Fiddle.dlopen('C:/Users/Administrator/Documents/Visual Studio 2015/Projects/miniDll/x64/Debug/miniDll.dll')
test1=Fiddle::Function.new(libm['test'], [Fiddle::TYPE_FLOAT]*2,Fiddle::TYPE_FLOAT)
the reason I didn’t add SUModelRelease and SUTerminate is that I just call the active model to add some thing. when the function end. the model still exist.
well I copy the marco from
the internet to the h file. and load dll successfully. thanks. but it’s true that the geometry didn’t appear in the scence…meaning. I can’t create geometry in the active_model through c sdk. why you inventors make the limitation. why you don’t let the other developers interactive with sketchup through c.