• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Closing an open component API

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 4 Posters 152 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.
  • T Offline
    tim
    last edited by 5 Jun 2012, 16:17

    I am unable to find the api to close a component that is open for editing; I've searched for terms that seem plausible like 'close_edit' and exit and clear and selection and so on and on. A list of methods is all very useful when you have a decent idea of what your target might be called but not so much fun otherwise. Simply searching the forums dumped so much on me that I almost fell asleep reading through it. I was anticipating something along the lines of "Sketchup.close_open_edit()'.

    My ComponentScenes plugin can be used when a component is opened up and sub-components are selected. At the end of the function I'd like to close the edit because it seems confusing to have the edit context make the 'new' components created non-visible (depending upon the users settings for 'view>component edit' of course). One might argue that users should be aware of their own setup but I think it worth trying to be helpful. If it turns out to actually be helpful, of course.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 5 Jun 2012, 17:12

      https://developers.google.com/sketchup/docs/ourdoc/model#close_active

      Assuming that model=Sketchup.active_model has been set earlier...

      If the user could be in the model OR a group/component context, then use ' close_active' with a test, something like:
      model.close_active unless model.entities==model.active_entities

      To close ALL open edit contexts back to the base level of the model.entities use something like:
      model.close_active until model.entities==model.active_entities

      Of course you could try and find the view>component-edit boolean value and remember it, then set it to be 'on' and when your tool is done reset it to the remembered boolean value ?

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        tim
        last edited by 5 Jun 2012, 18:09

        Thanks; that's even pretty damn obvious once you know it. Good point about multiple levels of open as well; hadn't considered that.
        Maybe it would be best to leave things as they are...

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 5 Jun 2012, 18:35

          @tim said:

          A list of methods is all very useful when you have a decent idea of what your target might be called but not so much fun otherwise. ... I was anticipating something along the lines of "Sketchup.close_open_edit()'.

          But there are only two methods that begin with " close..." in the API Method Index .

          .. and you know it's likely not the one for the Webdialog class.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 5 Jun 2012, 22:28

            Beware!
            Normally when you close a group/component using the SketchUp UI it is added to the Undo stack.
            However, model.close_active does not add the event to the undo stack so if the user invokes undo after using that method geometry shifts around as they are undone because the undo operation doesn't know the context and axis changes.

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              tim
              last edited by 7 Jun 2012, 00:53

              @dan rathbun said:

              But there are only two methods that begin with " close..." in the

              Yeah but you know what it's like - you are searching for something for which you have no idea of the name, try all sorts of combinations - exit, stop, abandon, cancel, whatever - and when you give up and ask for help it's always the most embarrassingly obvious choice that you never even considered. This is why getting forgetful in older age is so infuriating.
              "Um, strawberry-ish. Red thing. Flower?"
              "Rose?"
              "Yes - spectacles! Thank you!"

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 7 Jun 2012, 08:19

                @tim said:

                Yeah but you know what it's like -

                Yes I've been there.

                Was just teasing. 😛

                And it takes awhile to get used to how they organized the API.

                I'm not here much anymore.

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

                Advertisement