sketchucation logo sketchucation
    • Login
    1. Home
    2. onidarbe
    3. Posts
    βŒ› Sale Ending | 30% Off Profile Builder 4 ends 30th September
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 16
    • Posts 52
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: How to check showRubyPanel is ready to accept puts

      Because I need to swap very often between Notepad++ and SU while writing code I don't want to do a lot of stuff like saving, loading, typing, ... So I don't like opening the Ruby Console and loading plugins manually.

      I also like the Ruby Console to be ready to accept puts while my plugins are loading, for debugging reasons. I already managed Notepad++ to auto-saves everything upon unfocusing, and 1 short-cut to reload them in SU. But sometimes SU needs to restarted to really have all the old stuff out of it like methods and variables.

      So I like SU to automatically restart, open the Ruby Console and be ready to accepts puts from my plugins while they are loading πŸ˜‰

      I would also like to find out if the Ruby Console is open, so I don't need that menu-item to enable/disable the Ruby Console at start. Seems I need to use Win32API.

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How to check showRubyPanel is ready to accept puts

      yeah, but UI.messagebox is again disturbing a quick save-and-test my plugins!

      I'm still fooling around with the Win32API, to know when the Ruby Console window is open. In the meantime I'm just waiting 2 seconds before my plugins are loaded with this:

      To make it ready for RDZ I added:
      ...\plugins\mr_plugins.rb

      require 'sketchup.rb' # Don't know why, but everyone is adding these line?
      require 'extensions.rb' # Don't know why, but everyone is adding these line?
      
      mr_plugins = SketchupExtension.new "mr_plugins", "mr_plugins/mr_!main.rb"
      mr_plugins.copyright= "Copyright 2014"
      mr_plugins.creator= "onidarbe () gmail"
      mr_plugins.version = "2013 jan 06"
      mr_plugins.description = "Adds all ../plugins/mr_plugins/*.rb"
      Sketchup.register_extension mr_plugins, true
      

      This plugin will then load all my plugins in a sub-folder after 2 seconds, to be sure that the Ruby Console is open and ready to receive puts:
      ...\Plugins*mr_plugins*\mr_!main.rb

      module MR
      
        if !file_loaded?(File.basename(__FILE__))
          UI.start_timer(2, true){ require_all(Sketchup.find_support_file("Plugins") + "/mr_plugins/") }
          file_loaded(File.basename(__FILE__))
        end #if
      
      end #module
      

      Finally this code will add a menu-item which could be checked to enable/disable opening the Ruby Console:
      ...\Plugins*mr_plugins*\mr_openRubyConsoleOnStart.rb

      module MR
      
        @pluginPath = Sketchup.find_support_file("Plugins")
        
        def self.openRubyConsoleOnStart   # onidarbe 2013-01-07
          # Delete or create a plugin file that opens the Ruby Console on start of Sketchup.
          # Because the filename starts with a "!" it will alphabetically start first.
          # The Ruby Console takes some time to load in-between loading other plugins!"
          if FileTest.exist?(@pluginPath + "/!openRubyConsoleOnStart.rb")
            File.delete(@pluginPath + "/!openRubyConsoleOnStart.rb")
            UI.menu("Windows").set_validation_proc(@menuItem){MF_UNCHECKED}
          else
            file = File.new(@pluginPath + "/!openRubyConsoleOnStart.rb", "w")
            file.puts("# Placed here with #{File.basename(__FILE__)} to open the Ruby Console at start.") 
            file.puts("# Filename starts with a '!' to start first as plugins starts alphabetically.") 
            file.puts("# The Ruby Console takes some time to load in-between loading other plugins!") 
            file.puts("Sketchup.send_action 'showRubyPanel;'") #to open Ruby Console
            file.close
            UI.menu("Windows").set_validation_proc(@menuItem){MF_CHECKED}
          end
        end
      
        if !file_loaded?(File.basename(__FILE__))
          @menuItem = UI.menu("Windows").add_item("Open Ruby Console on start   [MR]") {MR;;openRubyConsoleOnStart}
          if FileTest.exist?(@pluginPath + "/!openRubyConsoleOnStart.rb")
              p @menuItem
            UI.menu("Windows").set_validation_proc(@menuItem){MF_CHECKED}
          end if
          file_loaded(File.basename(__FILE__))
        end
      
      end #module
      

      Now if I could know that the Ruby Console is open, then I don't need to add an other menu-item! I could just restore the last situation, opening the Console when it was open on closing SU. πŸ˜’

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How to check showRubyPanel is ready to accept puts

      Thank you all, I'll look it to it all...

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How to check showRubyPanel is ready to accept puts

      Well, I'm already sure it load it first πŸ˜‰

      The problem here, is that I can't seem to open the Ruby Console before continuing to load any other plugin. Using any timer will only delay opening the Ruby Console as well. When you have a lot of plugins to load, eventually the puts from loading the last plugins will be displayed in the Ruby Console. It's like the Ruby Console is only opening, taking time in between loading other plugins.

      So I'm now trying to move all plugins to "plugins/delayed/", all but one that opens the Ruby Console and waits for 2 seconds to load the others with using:
      `

      UI.start_timer(3, true) { 
        require_all(Sketchup.find_support_file("Plugins") + "/delayed")
      }
      

      `
      The thing I need now is not a timer, but a check it the Ruby Console is fully loaded and ready. So, how can one know if the Ruby Console is open?

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How to check showRubyPanel is ready to accept puts

      Nope, I've tried that 😞

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • How to check showRubyPanel is ready to accept puts

      How can I check if the Ruby Console is up and ready to receive puts?

      So what I like to do is opening the RubyPanel and accept puts before any other plugin is loading?

      I know this plugin needs to start before the others with a filename that sits alphabetically on top, like: "!openRubyConsole.rb" But it takes a while before the window is ready to accept puts, and even waiting doesn't seem to work!

      [ruby]Sketchup.send_action('showRubyPanel;')
      #sleep 2  ### not working!
      time=Time.now
      until Time.now > time + 2 ### also not working!
      end
      puts("hi")[/ruby]
      
      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Class installs twice when reloaded!

      aoh, I need to have that file Win32API.so in the plugin map!
      thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: X-ray transparency settings?

      I guess not 😞
      Didn't find anything useful here:
      http://www.sketchup.com/intl/en/developer/su-api/rendering__options_8h.html

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Want new tool: Select through transparent face

      Maybe we can change the X-ray transparency to 0%(no transparency)? That would do it, but how?

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Class installs twice when reloaded!

      yheah I know, tried that one already.
      Need to use win32API, but I can't seem to figure out how to use that!
      require "Win32API" gives me: "parenthesize argument(s) for future version" and "no such file to load"

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • X-ray transparency settings?

      Does anyone know if I can change the X-ray transparency amount?

      thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Class installs twice when reloaded!

      ooh OK, that explains a lot. Thanks Dan!

      Maybe you could also edit that post of you and add that they should never use the full path, because in windows it could be truncated! πŸ˜‰

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Want new tool: Select through transparent face

      Could anyone help me to make this ruby "ghost" script?
      How can I redirect the user-interface to the things behind an object as if it doesn't exist?

      thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Class installs twice when reloaded!

      Thanks Dan,

      With your help I found the problem with reloading plugins:

      When my Sketchup starts, file_loaded(__FILE__) adds "c:/progra~2/sketchup/sketch~1/plugins/any_script.rb" to $loaded_files, but when reloading the plugin it adds "c:/program files (x86)/sketchup/sketchup 2013/plugins/any_script.rb". So when SU starts it's using the shorter DOS-path though the filename isn't truncated to 8 characters, at least in my Windows 7 x64.
      That's why if !file_loaded?(__FILE__) doesn't work!

      So I only need to find a way to put in the full path length on startup. Any idea?
      Using only the filename or module:basename doesn't seem right to me, because shouldn't we all add the same to $loaded_files? Buy the way Module.nesting[0].name gives "undefined method"! Probably because of an older Ruby version.

      I was playing with the as_pluginloader.rb from Alexander Schreyer. I wanted to add a "reload all plugins". That's when I figured out that many plugins don't even use file_loaded. So that's a bummer 😞

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How can I run code on view-change

      thanks!

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • Want new tool: Select through transparent face

      Hi,

      I want to make a plugin that lets you select and work right through 100% transparent faces, without the need to hide it or use planes. Would be very nice to indoor designers having the the transparent faces as non existing πŸ˜‰ It gives a much faster look turning the room around, without the need to activate and deactivate the according plane again and again.

      I was thinking on capturing the button-down and make that work on recalculating the objects behind it. Or maybe I should create a switch to make all locked object as "ghosts", you can see them but you can't select or change them. Maybe that's even better otherwize there are still edges in the way!

      Any help, idea's or links to information that I need is very appreciated.
      Take in mind that I have little knowledge of Ruby jet!

      Thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Class installs twice when reloaded!

      Thanks again, your always answering! β˜€

      It seems file_loaded(__FILE__) and unless file_loaded?(__FILE__) just doesn't work! It lets it reload a second time. And they are all using this techniek?!

      Isn't there any way to find which modules, classes, methods and observers have been added by all plugins?! Maybe I just need to search through the code of every *.rb file in the plugins-maps! But then I still need to know if I can undo everything. I already now that I can't remove any menu added items, although I could gray them out... But can I remove everything: methods, modules, classes, observers and variables. And I probably forget a lot of other things, considering I'm just starting to learn Ruby.

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: Remove last line in Ruby Console?

      ok, thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • Class installs twice when reloaded!

      When I start SU, it will output 1 "x" releasing the middle-mouse-button, but when I reload the plugin, it will output 2 times "x"? Though a second reload doesn't produce 3 times "x"!

      [ruby]class MyToolsObserver < Sketchup;;ToolsObserver
          def onActiveToolChanged(tools, tool_name, tool_id)
            if @prevOrbit
              puts "x"
              @prevOrbit=false
            else
              @prevOrbit = true if tool_name == "CameraOrbitTool"
            end
          end
      end
      unless file_loaded?(__FILE__)
        Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
      	file_loaded(__FILE__)
      end[/ruby]
      

      Is there even a way to unload any class, module of method? Maybe there is a total reset, removing all plugins, before reloading them all again, without the need to restart SU and reloading the model...

      thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • RE: How can I run code on view-change

      I found out how to trigger a method when the viewing angle has changed, but I can't seem to find how to know in which viewing direction the window is.

      `

      class MyViewObserver < Sketchup;;ViewObserver
        def onViewChanged(view)
          puts view.camera.eye.to_s
        end
      end
      
      Sketchup.active_model.active_view.add_observer(MyViewObserver.new)
      

      `

      I would like to know the current viewing angle X, Y, Z and compare this to a face if that face is visible on that side or not.

      Any idea how to do that?

      thanks

      posted in Developers' Forum
      onidarbeO
      onidarbe
    • 1 / 1