Thomthom, can you help me ?
-
Hi all,
Anyone encountered the same problem as me ? Just do the following:
Create a simple class:class Test attr_accessor ;model def initialize() @model = Sketchup.active_model end end
Instanciate an object of that class:
obj=WebGLExporter;;Test.new()
Look at this object:
obj.inspect
Here's what I get:
#<WebGLExporter::Test:0x19dbaa18 @model=#<Sketchup::Model:0xe272680 @tt_bezier_surface_editor=#TT::Plugins::BezierSurfaceTools::BezierSurfaceEditor:0x139ef300>>
Thomthom, I have your Bezier surface plugin installed, along with TT_Lib2 of course.
What do you think ?? -
Using a bald 'Test' Class is asking for problems...
I think thomthom's older [unsupported] files can get convoluted...Try wrapping it in your own module...
module DidierBur module WebGLExporter class Test attr_accessor ;model def initialize() @model = Sketchup.active_model end end end end
Then use:
obj = DidierBur;;WebGLExporter;;Test.new() obj.inspect
Works for me:
#<DidierBur::WebGLExporter::Test:0x0000001527eec0 @model=#<Sketchup::Model:0x000000127edd00>>
-
@didier bur said:
#<WebGLExporter::Test:0x19dbaa18 @model=#<Sketchup::Model:0xe272680 @tt_bezier_surface_editor=#TT::Plugins::BezierSurfaceTools::BezierSurfaceEditor:0x139ef300>>
Thomthom, I have your Bezier surface plugin installed, along with TT_Lib2 of course.
What do you think ??This is probably related to something I tried a long time ago with BezierSurface. I was trying to keep a map of SketchUp model to a BezierSurface::Editor instance. (https://bitbucket.org/thomthom/bezier-surface/src/9f9a8d9a0634b4502779a6add502d424904f1364/src/tt_bezier_surface/core.rb?at=default%26amp;fileviewer=file-view-default#core.rb-160) At that time I thought the model reference I would get was unique to me, so I attached an instance variable to the model object itself. Back then we had Ruby 1.8 and it didn't display instance variables when you did an inspect.
However, I later learned that SU reuse Model and Entity instances - meaning that we all share the same Ruby object. But that was after I stopped maintaining BezierSurface and I'd completely forgotten about it.
Ruby 2.0's version inspect changed such that it display the content of instance variables - making this more apparent. So your Test class is printing the @model instance variable which in turns has my bezier surface instance variable.
Sorry about the noise. I'll add a ticket to try to refactor that.
Meanwhile, if you want to customize how your Test class in inspected you can do something like this to return to original Ruby 1.8 behaviour: (https://github.com/thomthom/SKUI/blob/master/src/SKUI/base.rb#L104)
class MyClass def object_id_hex "0x%x" % ( object_id << 1 ) end end
-
Test is a module in the StdLib. If it's not loaded the Ruby core won't have defined it.
-
@thomthom said:
Test
is a module in the StdLib.true !
Ref: http://ruby-doc.org/stdlib-2.0.0/libdoc/test/unit/rdoc/Test.html
@thomthom said:
If it's not loaded the Ruby core won't have defined it.
Not quite correct.
Since the SketchUp API Core adds methods to the
Test
module, it will always be defined.Test.methods(false).sort %(#000000)[>> [:AutoClickTime, :AutoClickTime=, :AutoDragDistance, :AutoDragDistance=, :CorruptModel, :FindFile, :diff, :eat_mem, :export_animation, :flip_images_for_origami, :project_textures_from_photo, :repair_model, :show_fps, :suppress_warnings=, :suppress_warnings?, :time_display, :time_pick, :use_sg_off_screen, :use_sg_on_screen]]
-
@tig said:
Using a bald 'Test' Class is asking for problems...
You can't.
Test
is a pre-defined Ruby standard module at the toplevel. (Edit: It's actually a library module, as Thomas points out below. But it's always defined, I will counter.)Test.class %(#000000)[>> Module]
class Test; def what(); puts "testing...": end; end %(#000000)[>> Error: #<TypeError: Test is not a class>]
-
Yes, unfortunately SU added a Test module for internal testing methods a long time back - before we included StdLib.
Advertisement