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

    Mysterious Bug [followme related]

    Scheduled Pinned Locked Moved Developers' Forum
    30 Posts 4 Posters 603 Views 4 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

      @chris88 said:

      Do you think the gaps could be the reason for the bug?

      Don't think so. Just a sidenote. It is possible to create that shape in one operation.

      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

        Alright replace the load loop with this ...

          # run when file loads
          #
          prevdir = Dir.getwd
          Dir.chdir Sketchup.find_support_file("Tools")
          tools = Dir["*.rb"]
          Dir.chdir(prevdir)
          if ( tools & $LOADED_FEATURES == tools ) &&
          Sketchup.active_model &&
          Sketchup.active_model.active_entities
            UI.start_timer(2.0, false){ LineA.create_line }
          else
            timer_LineA = UI.start_timer(2.0, true){
              if ( tools & $LOADED_FEATURES == tools ) &&
              Sketchup.active_model &&
              Sketchup.active_model.active_entities
                UI.stop_timer(timer_LineA)
                LineA.create_line
              end #if
            }
          end
          tools = nil
        
        

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          And here's a version that makes sure the Tool Stack is ready ...

            # run when file loads
            #
            prevdir = Dir.getwd
            Dir.chdir Sketchup.find_support_file("Tools")
            tools = Dir["*.rb"]
            Dir.chdir(prevdir)
            if ( tools & $LOADED_FEATURES == tools ) &&
            Sketchup.active_model &&
            Sketchup.active_model.active_entities &&
            Sketchup.active_model.tools.active_tool_id != 0
              UI.start_timer(2.0, false){ LineA.create_line }
            else
              timer_LineA = UI.start_timer(2.0, true){
                if ( tools & $LOADED_FEATURES == tools ) &&
                Sketchup.active_model &&
                Sketchup.active_model.active_entities &&
                Sketchup.active_model.tools.active_tool_id != 0
                  UI.stop_timer(timer_LineA)
                  LineA.create_line
                end #if
              }
            end
            tools = nil
          
          

          I'm not here much anymore.

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

            Let's step back to the very beginning...
            Do you need this script to run automatically EVERY time EVERY SKP opens?
            A. Yes.
            Why for goodness sake ???
            A. No.
            Then what's the problem?
            If it runs from a menu/toolbar then everything will be loaded by the time you think about using it anyway. Just do NOT include the code that runs it as it loads and everything is cushty!
            πŸ˜•

            TIG

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              Because he's generating ruby scripts (that build geometry,) from a C# program, which reads XML data.
              A batch mode use of Sketchup.

              He's not that good with Ruby, or else he could use Ruby's XML libraries directly.

              And I do have an API request in for an AppObserver "onReadyState" callback method.

              I'm not here much anymore.

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

                Well, I tried the snippet - installed in my Plugins folder - now executing the command. It splatted. But wrapping the command in a timer that delay the operation with two seconds - no splat.

                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

                  The processing of the Tools dir must complete, so that the menus and toolbars can all be built and displayed.

                  I'm not here much anymore.

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

                    Isn't he doing it arse-before-face as we say in the UK ?

                    Open Sketchup.
                    Start_operation.
                    Run the external 'tool'...
                    Load the objects in turn, each one as an individual component.
                    When all objects are done Export those objects in turn as separate SKPs.
                    Abort_operation.
                    Close Sketchup [no save].

                    That way nothing relies on something else 'opening in time' ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @tig said:

                      Isn't he doing it arse-before-face as we say in the UK ?

                      We'll, he knows C#, and not much of Ruby.

                      Instead of using Sketchup in a hacked batchmode... he or someone needs to wrap the C++ Interfaces for SKPWriter.DLL for C#. (Likely someone has already done it.) Any way it would be better to directly create skps.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Chris88
                        last edited by

                        THANKS to all for your efforts!
                        Now it works!!! it's slower than before, but it runs and that's the main thing!
                        @Dan: Thank you, you're the best! ^^

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          No problem...

                          Just a note that the disposal of the tools filename array needs to be inside the conditional true blocks. (Otherwise we might get an error with the & method if tools gets set to nil, prematurely.)

                            # run when file loads
                            #
                            prevdir = Dir.getwd
                            Dir.chdir Sketchup.find_support_file("Tools")
                            tools = Dir["*.rb"]
                            Dir.chdir(prevdir)
                            prevdir = nil
                            if ( tools & $LOADED_FEATURES == tools ) &&
                            Sketchup.active_model &&
                            Sketchup.active_model.active_entities &&
                            Sketchup.active_model.tools.active_tool_id != 0
                              UI.start_timer(2.0, false){ LineA.create_line }
                              tools = nil
                            else
                              timer_LineA = UI.start_timer(2.0, true){
                                if ( tools & $LOADED_FEATURES == tools ) &&
                                Sketchup.active_model &&
                                Sketchup.active_model.active_entities &&
                                Sketchup.active_model.tools.active_tool_id != 0
                                  UI.stop_timer(timer_LineA)
                                  tools = nil
                                  LineA.create_line
                                end #if
                              }
                            end
                          
                          

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • 1
                          • 2
                          • 1 / 2
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement