sketchucation logo sketchucation
    • Login
    1. Home
    2. azuby
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    โš ๏ธ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    A
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 23
    • Posts 305
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Ruby namespace?

      I'm interested in your Python solution. The forum PM function works fine, I think ๐Ÿ’š

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Ruby namespace?

      Please, please - no pros and cons between Ruby and Python. It would become a neverending thread. Ruby isn't file oriented and you can define your namespace (or mix-in) in more than one file.

      Example to explain mix-ins:

      class Light
        # ...
      end
      
      l = Light.new
      l.switch rescue puts "Light#switch is not implemented"
      # => "Light#switch is not implemented"
      
      module Switchable
        def switch
          puts "Switching ..."
        end
      end
      
      class Light
        include Switchable
      end
      
      l.switch rescue puts "Light#switch is not implemented"
      # => "Switching"
      
      # ... and the other way round;
      class Light
        undef ;switch
      end
      
      l.switch rescue puts "Light#switch is not implemented"
      # => "Light#switch is not implemented"
      

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Ruby namespace?

      You can use modules.

      module YourNameSpace
        class YourClass
          # ...
        end
      end
      
      YourNameSpace;;YourClass.new
      

      Modules are used in two different ways: 1. to build namespaces, 2. to build mix-ins.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Question - A way to allow user to change ruby menu location?

      Difficult. You can't change it while Sketchup is running -> restart. But you can try to override the Sketchup methods for adding (sub) menus and menu items keeping the old methods with alias names. Your methods "hook" into the old methods, before they perform their action - short IRB session explaining what I'm talking about:

      irb(main);001;0> class A
      irb(main);002;1>   def a
      irb(main);003;2>     puts "a"
      irb(main);004;2>   end
      irb(main);005;1> end
      => nil
      irb(main);006;0> class A
      irb(main);007;1>   alias ;old_a ;a
      irb(main);008;1>   def a
      irb(main);009;2>     puts "b"
      irb(main);010;2>     old_a
      irb(main);011;2>   end
      irb(main);012;1> end
      => nil
      irb(main);013;0> A.new.a
      b
      a
      => nil
      

      Your method could read the correct menu structure i.e. from a text file. But you have to make sure, that your script is eval'ed by Sketchup before another script adds menus or menu items.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: [Solved] My script keeps bugsplatting :(

      If you can't see the error messages, send them to a file.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: SU script / Ruby book for beginners

      @remus said:

      I had a quick look at the website, and the rd edition deals with ruby 1.9, perhaps SU uses 1.8?
      Exactly. Sketchup uses a real old Ruby (1.8.0). Most of the Ruby programmers use 1.8.6 (or 1.8.7) at the moment. Betwenn 1.8.6 and 1.8.7 they made some changes influenced by the development of 1.9.0 (and 1.9.1). But alos betwenn 1.8.7 and 1.9.0 (1.9.1) there are a lot changes.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Odd Ruby Error

      That should be the reason.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Request - Email Model function in the SU File menu

      My first thought was using mailto: - but it doesn't support attachments.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Odd Ruby Error

      A return statement from a do..end / { } block is used in one of your installed Ruby scripts.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: SU script / Ruby book for beginners

      I think you should read the Pickaxe (but not the Third Edition!) and than digging into Sketchup Ruby API documentation.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Scrambler.exe

      ๐Ÿ˜ฎ You do D'n'D? I thought, you're a real cool programmer ๐Ÿ˜„ using vi and so on.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Scrambler.exe
      Scrambler.exe yourfile.rb
      

      Well - should be a really short documentation ๐Ÿคฃ

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Holding variables

      Best is, not only using classes but also using modules for structuring your code. Modules can be used to represent different names spaces so you can't conflict with code from other Plugins:

      module MyFunnyModule
        class MyFunnyPlugin
          def initialize
            @myfunnyvariable = 0 # an instance variable
            setup_ui
          end
          def increment
            @myfunnyvariable = @myfunnyvariable + 1
          end
          def setup_ui
            # here i. e. your toolbar code
            # ...
            # call the increment method from an UI;;Command;
            cmd = UI;;Command.new("Foo") { increment }
            # ...
          end
        end # MyFunnyClass
        
        m = MyFunnyPlugin.new # get an instance of your class
        
      end # MyFunnyModule
      

      Do not use names beginning with big letter for your methods. And do not use CamelCase. It's just code style, but Ruby guys programm this way:

      MoveLeft - OK for class and module names
      moveLeft - not OK
      move_left - OK for method and variable names

      You should read a bit about Ruby.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Help on ICONS

      Use the Toolbar class from the Sketchup Ruby API.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Holding variables

      Use an instance variable. At the moment, your code should be in a class. Initialize your instance variable (i. e. @clicks - the @ is neeeded) in the initialize method of your class and use the variable in the code which is executed by clicking on your button.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: Weihnachtsfrieden

      Und? War's friedlich? Oder hat vielleicht irgendwo irgendeine Katze irgendeinen Braten geklaut? ๐Ÿ˜„

      azuby

      posted in Deutsch
      A
      azuby
    • RE: Scripts not working after Scrambler

      @unknownuser said:

      Ha, Ha,

      Happy New Year

      Oscar
      ๐Ÿ˜„

      oscarlok.slepp 6.days
      

      ๐Ÿ’š

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: [Plugin] JointSU (in drafting)

      In most of the cases developers declare their methods being private, there is a good reason for that. But you can try for your own whether this method does what you want by using send:

      Sketchup.active_model.send ;open
      

      With Sketchup 6 the result is:

      Sketchup.active_model.send ;open
      Error; #<ArgumentError; (eval);1619;in `initialize'; wrong number of arguments (0 for 1)>
      (eval);1619
      

      OK, the methods needs an argument. I tried with a path:

      Sketchup.active_model.send ;open, "C;/bla.skp"
      #<File;C;/bla.skp>
      

      azuby

      posted in Plugins
      A
      azuby
    • RE: Mac Webdialog opens in background
      PLATFORM = (Object;;RUBY_PLATFORM =~ /mswin/i) ? ;windows ; ((Object;;RUBY_PLATFORM =~ /darwin/i) ? ;mac ; ;other)
      

      edit: It's a one-liner.

      azuby

      posted in Developers' Forum
      A
      azuby
    • RE: View Observers?

      onViewChange - http://groups.google.com/group/SketchUp-Plugins-Dev/web/Ruby-ViewObserver.html?hl=en

      azuby

      posted in Developers' Forum
      A
      azuby
    • 1 / 1