sketchucation logo sketchucation
    • Login
    1. Home
    2. Anton_S
    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 7
    • Topics 52
    • Posts 1,261
    • Groups 2

    Posts

    Recent Best Controversial
    • Identify/locate the Subclass

      During coding I came up to the point where I needed to figure whether the selected object is a sublcass of a class. I mean like Sketchup.active_model.select_tool only accepts subclasses, right? And it only works if the tool includes some of its methods, such as onMouseMove.

      I can predict how it works. Maybe it uses @selected_tool.include?(certain_method), If method not inclduded, then the tool jst ignores the callback to current message. But with this assumption the ...select_tool method will also accept anything, but not nil, as it describes in the API description.

      Is there a way to actually know whether the selected tool is actually a subclass of a class?

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Code] Win32 - Get SketchUp Window Handle (WIP)

      @dan rathbun said:

      You neglect to show the require() staement that loads Dan Berger's win32-api extensions. (This example does not use the Win32API.so file, that comes "out-of-the-box" with Ruby.)

      Thanks for pointing that out. Yep, the code above requires win32-api

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Code] Win32 - Get SketchUp Window Handle (WIP)

      Here is my way to find sketchup window.
      I used it in SU Window Settings plugin.

      Parts of ClassName change After restarting SU
      ~sample: "Afx:00400000:b:00010011:00000006:0574025D"
      From my testing:

      • On windows XP, the last set of values, separated by ":" change.
        Afx:00400000:b:00010011:00000006:0574025D
      • On windows 7, all even parts, separated by ":" change. The odd parts are always the same, including on both 32 and 64 -bit processors.
        Afx:00400000:b:00010011:00000006:0574025D

      So, the only parts of class that are reliable to locate main SU window are, Afx, b and 00000006. Plus to get the current sketchup window, you could add the Process.pid. The code below does all of that work πŸ˜„

      @main_window = Hash.new
      @find_main_window = Win32;;API;;Callback.new('IP', 'I'){|hwnd, lParam|
        p = 0.chr*4
        threadID = GetWindowThreadProcessId.call(hwnd, p)
        pid = p.unpack('l')[0]
        next true if (pid != Process.pid)
        cname = 0.chr*50
        GetClassName.call(hwnd, cname, cname.size)
        cname = cname.strip
        if (cname[0,3] == "Afx") and (cname[13,1] == "b") and (cname[24,8] == "00000006")
          @threadID = threadID
          @main_window["hwnd"] = hwnd
          next false
        end
        true
      }
      EnumWindows.call(@find_main_window, nil)
      

      Note, this example was only tested on Windows XP and On Win7.

      What vous think?

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Code] YARC – yet another ruby console

      yep, sure

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Code] YARC – yet another ruby console

      @dan rathbun said:

      
      > unless file_loaded?(File.basename(__FILE__))
      > ...
      > file_loaded(File.basename(__FILE__))
      > 
      

      I recommend putting the whole __FILE__ instead of a File.basename(__FILE__). That way you would eliminate same filenames that are in different folders.

      EX:
      Plugins/Anton_Lib/core.rb

      that statement would be true
      ` unless file_loaded?(File.basename(FILE))

      ...
      file_loaded(File.basename(FILE))end`
      Plugins/TT_Lib/core.rb

      that statement would be false, preventing vital parts to be called
      ` unless file_loaded?(File.basename(FILE))

      ...
      file_loaded(File.basename(FILE))end`

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Code] YARC – yet another ruby console

      πŸ˜„ πŸ˜› Wow, wow, wow, yahooooooooooooooooo1!!!!!! β˜€ πŸ˜„

      Jst awesome, that ruby console could save a lot of time 😍

      posted in Developers' Forum
      A
      Anton_S
    • RE: [Plugin] FullScreen v5.1.3 (25 April 2024)

      @rich o brien said:

      Thanks Anton. I love this plugin πŸ‘

      That was fast πŸ˜„

      posted in Plugins
      A
      Anton_S
    • RE: [Plugin] FullScreen v5.1.3 (25 April 2024)

      Updated Monday June 18, 2012
      See First Post πŸ˜„

      posted in Plugins
      A
      Anton_S
    • RE: Notepad++ SU8 Ruby API Autocomplete

      @thomthom said:

      @anton_s said:

      @rich o brien said:

      Sublime 2?

      Sublime 2 is awesome!!!

      Ditto! It's not freeware - but I have no problem paying for this one.

      Sure, piece of cake πŸ˜„

      'Hay, dad...'

      posted in Developers' Forum
      A
      Anton_S
    • RE: Notepad++ SU8 Ruby API Autocomplete

      @rich o brien said:

      Sublime 2?

      Sublime 2 is awesome!!!

      posted in Developers' Forum
      A
      Anton_S
    • RE: Notepad++ SU8 Ruby API Autocomplete

      Is there a way for np++ automatically to add/remove your own module, class, and method names into/from the auto-complition list?

      What I mean:
      Lets say I write some class in NP++, naming it 'Anton'.
      On the next line I start with letter A and the auto-completion-list should show-up displaying all index with A including my name.
      Then I erase my class and on next line start with word A again. Now, the index list should no longer have 'Anton' in the index.

      Sorry, that's kind of awkward put together, though I hope ya could understand what I mean. πŸ‘Š

      posted in Developers' Forum
      A
      Anton_S
    • RE: Ruby code to extract watermark

      You can actually display watermarks.

      model = Sketchup.active_model opts = model.rendering_options opts['DisplayWatermarks'] = true/false

      Yep, there is no function to get/set watermark image, though there is actually a way around it.

      "Watermarks are part of a Style. You would have to have a preset Style with the watermark, and change the Style with the API." - quote by Dan.
      Create a style or two, add watermarks to each, and set them via Ruby API:
      styles = Sketchup.active_model.styles styles.selected_style = styles['Style Name'/style index#]

      Reference: Watermark via Ruby API

      posted in Developers' Forum
      A
      Anton_S
    • RE: What does SU mean to you?

      Really nice words.

      SketchUp + Sketchy-physics got my interest since I was 12.
      My programming skills went up exponentially and it got my interests in space NASA

      posted in SketchUp Discussions
      A
      Anton_S
    • Linux Windows API?

      I've read and don't get it. Does linux use and support windows API? I'm just cureous if it win32::api library can also be used on linux OS.

      posted in Developers' Forum
      A
      Anton_S
    • RE: Ruby Module Variables

      @dan rathbun said:

      All of your modules and/or classes need to be within your "author" namespace.
      If you need one copy of some code, make it a module.
      If you need multiple copies of some code, make it a class, and use multiple instances of the code.

      Ok, good advice, thaks πŸ˜„ . Now I'm on my way to 'Keep on typing' the code.

      posted in Developers' Forum
      A
      Anton_S
    • RE: Ruby Module Variables

      @jim said:

      As far as I know, a instance variable, a class variable, and a constant will all have the same visibility (scope) when defined at the top-level of a module. They will all be visible everywhere within the module namespace, including classes and other modules defined within the module. A unique feature of Ruby is that these same objects (classes, modules, variables) are visible across files if the files use the same names.

      Which is "right" may come down to convention and personal preference.

      Alright, so are the two namespaces below right and which of them do you prefer better:?

      module CandiesM
        @@count ||= 0
        def self.buy(); @@count += 1; end
      end
      
      class CandiesC
        @@count ||= 0
        def self.buy(); @@count += 1; end
      end
      
      posted in Developers' Forum
      A
      Anton_S
    • RE: Ruby Module Variables

      Thanks, for a great replie(s) Dan and Jim

      Well, isn't this:

      @dan rathbun said:

      
      > Anton = Module.new() {
      >   @color = 'blue'
      >   def self.get_color()
      >     @color
      >   end
      > }
      > 
      

      the same as this:?

      module Anton
        @color = 'blue'
        def self.get_color()
          @color
        end
      end
      

      I don't see any difference in these


      @dan rathbun said:

      Because modules can be the library type (best used with module/class variables and module/class methods,) OR the "Mixin" type, which are used to mixin instance variables and instance methods into custom classes. (You can also create a hybrid that is both types, like the Math module is.)
      So.. read up on Mixin Modules.

      Found a really good explanation here, thanks πŸ˜„

      posted in Developers' Forum
      A
      Anton_S
    • Ruby Module Variables

      Based on the reference: Module Variables, I figured that it's valid to create instance variables inside the Module. I tested it on SU via Ruby and it all worked, without any conserns. Though, some of Ruby things began bugging me, and thus I need a good confirmination.

      1st: Creating instance variables in module namespace is valid, though is it right and why?

      2nd: Since, you can't create an instance of a module (SomeModule.new = No function such as new) then, why are there things such as module instance methods (def someMethod) and module class methods (def self.someMethod)?

      3rd: Getting even deeper, I figured that it is valid to create constants inside the class. They act the same way as class variables, though as usual ruby would warn once the constant is assigned a different value. So, is it also right to initiate constants inside the class namespace?

      4th: What is a difference bettween instance variables and class variables in the module?

      posted in Developers' Forum
      A
      Anton_S
    • RE: SU 9 Wishlist

      @thomthom said:

      @anton_s said:

      Anyways who is working on creating SU9?

      An infinite number of monkeys in front of keyboard typrewriters.

      ...which, are at Zoo. πŸ˜’

      posted in SketchUp Feature Requests
      A
      Anton_S
    • RE: SU 9 Wishlist

      Anyways who is working on creating SU9?

      posted in SketchUp Feature Requests
      A
      Anton_S
    • 1 / 1