sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Thomthom, can you help me ?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 1.0k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Didier BurD Offline
      Didier Bur
      last edited by

      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 ??

      DB

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

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

        TIG

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @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
          
          

          Thomas Thomassen โ€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Test is a module in the StdLib. If it's not loaded the Ruby core won't have defined it.

            Thomas Thomassen โ€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @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]]

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @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>]

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Yes, unfortunately SU added a Test module for internal testing methods a long time back - before we included StdLib. ๐Ÿ˜ž

                  Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement