sketchucation logo sketchucation
    • Login
    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!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    Mysterious Bug [followme related]

    Scheduled Pinned Locked Moved Developers' Forum
    30 Posts 4 Posters 2.4k 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.
    • C
      Chris88
      last edited by

      Dan, i have to correct myself: It works, when i load the script from the Ruby Console = step forward! πŸ˜„ [Edit:] i just noticed, this is what thomthom meant. 😒 [/Edit]
      But it doesn't work yet, when i want to load the script from the plugin-folder by starting SU normally and the script is located in the plugin-folder.

      1 Reply Last reply
      Reply Quote 0
      • thomthomT
        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
          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
            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
              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
                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
                  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
                    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
                      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
                        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
                          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
                            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

                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                            With your input, this post could be even better πŸ’—

                            Register Login
                            • 1
                            • 2
                            • 2 / 2
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement