sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Reading what is sent to the console?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 308 Views 2 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.
    • jiminy-billy-bobJ Offline
      jiminy-billy-bob
      last edited by

      Hi,

      Is it possible to track what it is being sent to the console by other extensions via "puts" and "print"?
      I've read a bit about $stdout, but don't really understand how all this works in Sketchup.

      Thanks,
      jbb

      25% off Skatter for SketchUcation Premium Members

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        @jiminy-billy-bob said:

        Hi,

        Is it possible to track what it is being sent to the console by other extensions via "puts" and "print"?
        I've read a bit about $stdout, but don't really understand how all this works in Sketchup.

        Thanks,
        jbb

        Yes. it is possible, though it involves "monkey patching" the definitions of the output functions you want to intercept. Monkey patching is generally deprecated because it can destabilize Ruby and other plugins in hard-to-predict ways. I note that since you want to intercept output from other plugins, this is very different from building your own private modifications.

        In a nutshell (deliberately not code so as not to encourage the inexperienced to try it), you define an alias for the existing method then define a new method with the same name as the original that routes the arguments to your trap and then invokes the original so that the data gets to the console. I would not mess around with SketchUp's Console or $stdout, as they are already tweaked to make everything work.

        Out of curiosity, why do you want to snoop other plugins' output?

        Steve

        1 Reply Last reply Reply Quote 0
        • jiminy-billy-bobJ Offline
          jiminy-billy-bob
          last edited by

          Actually, since I posted I found another way to do what I want.
          But thanks for your answer, that's interesting.

          So I guess that's how the custom ruby consoles do it?

          25% off Skatter for SketchUcation Premium Members

          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