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!
    Mac User? | Join the Rayscaper Beta for Mac Learn More

    Close webdialogs on File-New/Open

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 4 Posters 1.3k 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.
    • P
      Pout
      last edited by

      It's like this:
      The webdialog is opened though a button and shows info on the Sketchup model.
      Straightforward, no class used.
      So i think it's the AppObserver i need.
      I have to initiate that at the start of the ruby and just handle the events?

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

        @pout said:

        I have to initiate that at the start of the ruby and just handle the events?

        Yup!

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

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

          class MyDialogAppObserver < Sketchup;;AppObserver
            def onNewModel(model)  ### from menu or app
              begin
                $myDialogID_12345.close
              rescue
              end
            end
            def onOpenModel(model) ### from menu
              begin
                $myDialogID_12345.close
              rescue
              end
            end
            def onQuit()
              begin
                $myDialogID_12345.close
              rescue
              end
            end
          end
          ### Attach the observer at kick-off...
          Sketchup.add_observer(MyDialogAppObserver.new)
          
          

          You then need to set a global variable referring to your dialog [ dlg] so the observer can find and close it...
          $myDialogID_12345=dlg

          TIG

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

            Beware that on OSX you can have multiple model documents open.

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

            1 Reply Last reply
            Reply Quote 0
            • P
              Pout
              last edited by

              Tig, thx for the piece of code!
              ThomThom, in that case it think it will be necessary to keep the model path in a global variable and use that to check.

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

                And if the user swaps between models while working?
                Or the user saves the model under a new name?

                I have a tool where I need to keep track of the various models. I tried using the model object as reference, but it changes when you save teh model etc. I also tried the model.guid - but that also changes at times. At the moment I use a combo of model object and guid to track it.

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

                1 Reply Last reply
                Reply Quote 0
                • P
                  Pout
                  last edited by

                  sssshtttt ThomThom,

                  you're giving me a headache on a friday afternoon πŸ˜†

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

                    Why not make a simple tool that opens the dialog and then you can have a 'deactivate()' method to close the dialog whenever you move away from that SKP ? - you'd just need to wrap the original 'def' code into an initialize()/activate() instead, inside the new tool's class and call the 'tool' in a slightly different way from a raw 'def' ??
                    Adding convoluted observers and global variables seems to be a lot more complicated...

                    TIG

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

                      @tig said:

                      Why not make a simple tool that opens the dialog and then you can have a 'deactivate()' method to close the dialog whenever you move away from that SKP ? - you'd just need to wrap the original 'def' code into an initialize()/activate() instead, inside the new tool's class and call the 'tool' in a slightly different way from a raw 'def' ??
                      Adding convoluted observers and global variables seems to be a lot more complicated...

                      Then you can't use the other native tools.

                      (And I'd use module variables instead of global variables.)

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

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

                        @pout said:

                        sssshtttt ThomThom,

                        you're giving me a headache on a friday afternoon πŸ˜†

                        πŸ‘Ώ you're welcome. πŸ˜„
                        The whole multiple window scenario under OSX is a bit of a pain - I don't feel it has proper support in the API for managing them.

                        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

                          Agreed.

                          I logged several Feature Requests for MDI support (new methods) in the API, including a Models collection.

                          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 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement