sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Using win32ole on startup

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 5 Posters 272 Views 5 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.
    • thomthomT Offline
      thomthom
      last edited by

      Won't that loop block the rest of SketchUp? Ruby doesn't let SketchUp "breathe" when it's working - that's why the UI white outs because not even the Windows messages are given any opportunity to be processed.

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

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

        But presumably it'll only pause briefly until model.entities in returned ?
        OR it could start a timer that'd run separately ?

            require 'sketchup.rb'
            require 'win32ole.so'
            module SR20VET
              def SR20VET.xls()
                UI.start_timer(1,false){
                model = Sketchup.active_model
                until model.entities
                  model_dict = model.attribute_dictionary("thisIsADict")
                  if model_dict
                    xl = WIN32OLE.new('Excel.Application')
                    ### rest of code ###
                  end
                end
                }#end timer
              end#def
            end#module
            SR20VET.xls()
        
        

        TIG

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

          @tig said:

          But presumably it'll only pause briefly until model.entities in returned?

          Pretty sure it won't, because the rest of SU can't continue until the loop is complete. You might have created an infinite loop. SketchUp's doesn't run in parallel with the ruby engine. It's sequential processing.

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

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

            I think this'll work:

                    require 'sketchup.rb'
                    require 'win32ole.so'
                    module SR20VET
                      def SR20VET.xls()
                        timer=UI.start_timer(0,false){
                          UI.stop_timer(timer)
                          model = Sketchup.active_model
                          until model.entities; end
                          model_dict = model.attribute_dictionary("thisIsADict")
                          if model_dict
                            xl = WIN32OLE.new('Excel.Application')
                            ### rest of code ###
                          end
                        }#end timer
                      end#def
                    end#module
                    SR20VET.xls()
            

            TIG

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

              For timer delay you should immediately stop the timer in it's block - because if a modal window appear within the block, like a messagebox or an error message (which you get when you start SU) will make the timer repeat until the modal window is closed.

              <span class="syntaxdefault"><br />timer&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">false</span><span class="syntaxkeyword">){<br />&nbsp;&nbsp;</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">stop_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">timer</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;...<br /></span><span class="syntaxkeyword">}<br />&nbsp;</span><span class="syntaxdefault"></span>
              

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

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

                Added to last post for avoidance of confusion...

                TIG

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Sorry to drag this off topic, but what does win32ole do? It looks like the code is interfacing with excel? Will win32ole read and write excel files? I'm looking around here:

                  301 Moved Permanently

                  favicon

                  (www.ruby-doc.org)

                  But I don't see an explanatiojn of what it does.

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

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

                    OLE is an interface for communicating with Objects. Excel has implemented this interface so you can communicate with Excel.

                    Win32OLE is a library that allows you to use OLE interfaces within Ruby.

                    Link Preview Image
                    Object Linking and Embedding - Wikipedia

                    favicon

                    (en.wikipedia.org)

                    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

                      [Plugin Library] Win32API and Win32OLE so files

                      Online reference rdocs for these 2 libraries:

                      • Win32API rdoc
                      • WIN32OLE rdoc

                      I'm not here much anymore.

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

                        @thomthom said:

                        For timer delay you should immediately stop the timer in it's block - because if a modal window appear within the block, like a messagebox or an error message (which you get when you start SU) will make the timer repeat until the modal window is closed.

                        <span class="syntaxdefault"><br />timer </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">false</span><span class="syntaxkeyword">){<br /></span><span class="syntaxdefault">  UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">stop_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">timer</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># ...<br /></span><span class="syntaxkeyword">}<br />&nbsp;</span><span class="syntaxdefault"></span>
                        

                        Hi Thom and TIG, that's exactly how ì solved it. Noticed the fact that a UI.messagebox in the block will make the timer repeat too.
                        Never used UI.start_timer before but I can think of some nice implementations of it.

                        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