• 登入
sketchucation logo sketchucation
  • 登入
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

How to pause a ruby script for 1 second

已排程 已置頂 已鎖定 已移動 Developers' Forum
25 貼文 5 Posters 5.0k 瀏覽 5 Watching
正在載入更多貼文
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • N 離線
    N Lindenthal
    最後由 編輯 2008年8月23日 上午7:10

    @alexmozg said:

    @unknownuser said:

    …And completely to get rid from selection.

    Where I can find "following.rbs"?
    I shall think...

    Yes, rid from selection …

    … but how? This way?

    select_comp_by_name("Fahrstuhl")
    def Morisdov.transf_get(dict_key, ss=nil)
      model=Sketchup.active_model               
      ents=model.active_entities
       if ss
         @ents = ss
       else
         @ents=[]
         model.selection.each {|e| @ents.push(e)}
       end                                 
      @ents.freeze
      model.selection.clear
    end
    

    (my poor english) Which "following.rbs" you need?

    1 條回覆 最後回覆 回覆 引用 0
    • A 離線
      AlexMozg
      最後由 編輯 2008年8月25日 上午4:44

      @unknownuser said:

      Yes, rid from selection …

      … but how? This way?

      
      def select_comp_by_name(comp_name)
         model = Sketchup.active_model
         if compdef = Sketchup.active_model.definitions[comp_name]
            sel = compdef.instances
         else
            sel=[]
            Sketchup.active_model.active_entities.each do |d|
               if d.typename == "ComponentInstance"
               sel << d if d.name==comp_name
            end
         end
            if sel.count == 0
               UI.beep
            else
               UI.messagebox(sel.count.to_s + " gesuchte Dinger gefunden.")
            end
         end
      sel
      end
      
      def Morisdov.transf_get(dict_key, ss=nil)
        model=Sketchup.active_model               
        ents=model.active_entities
         if ss
           @ents = ss
         else
           @ents=[]
           model.selection.each {|e| @ents.push(e)}
         end                                 
        @ents.freeze
        model.selection.clear
        ...
        ...<<original code>>...
        ...
      end
      
      
      
      
      

      Use:

      1. ss = select_comp_by_name("Fahrstuhl")
      2. Morisdov.transf_get(dict_key, ss)

      @unknownuser said:

      (my poor english) Which "following.rbs" you need?

      Here this:

      @unknownuser said:

      ...Position 2
      To get the script work, the following .rbs must be installed:

      ????

      1 條回覆 最後回覆 回覆 引用 0
      • C 離線
        Chris Fullmer
        最後由 編輯 2009年2月16日 上午5:36

        I know this is old, but I was needing an answer to something similar today, and this thread over-complexificated the issue for me. I just wanted to add a short .2 second delay before carrying on with my script. This is what I've come up with and it worked for me. No need to invoke the UI.timer

        time_mark = ( Time.now + 0.2 )
        while time_mark > Time.now
        end
        

        Hopefully thats helpful if anyone stumbles on this thread,

        Chris

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

        1 條回覆 最後回覆 回覆 引用 0
        • T 離線
          tbd
          最後由 編輯 2009年2月16日 上午7:18

          Chris: i hope your code is called only by the user and not in an Observer or right click menus, because it will stop Ruby thread and if you call this several times it will block a lot of things.

          SketchUp Ruby Consultant | Podium 1.x developer
          http://plugins.ro

          1 條回覆 最後回覆 回覆 引用 0
          • C 離線
            Chris Fullmer
            最後由 編輯 2009年2月16日 上午7:26

            Ahh, I see. I think its ok in this instance to stop up ruby entirely. I was having very little luck getting it to work any other way. I just kept sending SU into a deeep coma.

            Maybe I'll try to post my broken code using the timer and try to get that working instead then. Thanks Tavi,

            Chris

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

            1 條回覆 最後回覆 回覆 引用 0
            • 1
            • 2
            • 2 / 2
            • 第一個貼文
              最後的貼文
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement