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

    Empty groups get deleted?!

    Scheduled Pinned Locked Moved Developers' Forum
    19 Posts 7 Posters 533 Views 7 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.
    • A Offline
      Aerilius
      last edited by

      Do you have a reference to the group?

      I assume SketchUp cleans up empty groups as they would otherwise clutter with zero-size elements that the user won't ever be able to select or re-use manually.
      Similar to that, Ruby cleans up unused references when it is sure that the reference won't ever be used again (garbage collection). If you need a reference later again (to draw entities into the group), the reference must live in the same scope as the drawing method.
      You could for example use a module variable instead of a local variable.

      1 Reply Last reply Reply Quote 0
      • N Offline
        niccah
        last edited by

        @aerilius said:

        Do you have a reference to the group?

        I assume SketchUp cleans up empty groups as they would otherwise clutter with zero-size elements that the user won't ever be able to select or re-use manually.
        Similar to that, Ruby cleans up unused references when it is sure that the reference won't ever be used again (garbage collection). If you need a reference later again (to draw entities into the group), the reference must live in the same scope as the drawing method.

        Thanks a lot for your fast reply!

        I agree with you - MANUALLY, I'm not able to use this group again. But with Ruby, I can find this group again by its name...

        Hm, can I insert something invisible?! In the worst case, I have to insert a line, hide it, and when the user starts so insert something in this group, I delete this invisible line at first...

        What do you think?

        1 Reply Last reply Reply Quote 0
        • N Offline
          niccah
          last edited by

          okay, I insert now a small edge and hide the full group... when the user insert his first objects, I delete this line and make the group again visible...

          Thanks Aerilius for the hint with the garbage collector!

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            Use a constructionpoint instead. May be lesser code.

            1 Reply Last reply Reply Quote 0
            • A Offline
              Aerilius
              last edited by

              Do you have a code sample that shows this?
              I highly doubt we have to insert a DrawingElement (if such a hack is necessary, then that behavior is a bug in SketchUp). I wonder why the group is garbage-collected, maybe we have to check again what kind of variable is used.

              1 Reply Last reply Reply Quote 0
              • jolranJ Offline
                jolran
                last edited by

                Maybe the code is between a start and commit operation? Doesent Sketchup garbage collect then?
                I don't think this is unusual, seen several hacks around conserning this. But they where rather old and I can't remember where I saw it. Maybe there's a better fix as Aerilius says...

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

                  SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances. Think it usually happens on commit - but there might be other triggers as well. Always seen this as part of the automatic cleanup.

                  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

                    @thomthom said:

                    SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances.

                    definitions ??

                    I thought it was empty instances that were GC'd ?

                    I'm not here much anymore.

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

                      It's a know way of removing an unused definition from the Component Browser without recourse to definitions.purge_unused, which of course might also remove components that the users has not yet got inserted, but would like to keep for later...
                      definition.entities.clear!
                      within a start/commit block will remove the definition.
                      Similarly group.entities.clear!, although in that case group.erase! will work BUT can can fall foul of some new BIMish ill-advised entities-observers... πŸ˜’

                      TIG

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

                        @dan rathbun said:

                        @thomthom said:

                        SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances.

                        definitions ??

                        I thought it was empty instances that were GC'd ?

                        Instances are just references to definitions. And it's not garbage collection - if it had been then they would not have disappeared when you have reference to them. It's SketchUp cleaning up.

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

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

                          @dan rathbun said:

                          @thomthom said:

                          SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances.

                          definitions ??

                          I thought it was empty instances that were GC'd ?

                          You're not talking about Ruby instances, right?

                          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

                            No. Back on the topic of the OP,... he was asking about group instances that get GC'd before he can use them, because they are empty.

                            I'm not here much anymore.

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

                              Andreas as the first one to mention the GC. The OP only said the group was deleted - which is what happens to definitions when they are empty.

                              @niccah said:

                              okay, I insert now a small edge and hide the full group... when the user insert his first objects, I delete this line and make the group again visible...

                              Why not create the group only right before you need to add something to it?

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

                              1 Reply Last reply Reply Quote 0
                              • N Offline
                                niccah
                                last edited by

                                At first! Thank you very much again for all your comments! I'm always learning a lot, "listening" to your discussions!

                                @thomthom said:

                                Why not create the group only right before you need to add something to it?

                                Following idea:

                                • the user can create a "project" => so, in my code, I create at first an empty group
                                • all the projects will be listed in a table
                                • now, the user can add to a single project some "parts"

                                So, my current problem:

                                • user create a project, and then he / her starts to draw the "part" => during drawing, the empty project group will be removed by GC...

                                My hidden line in the groups works perfect! I know, it not realy smart, but...

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

                                  That's where I ask: why do you need to create the group in advance before you actually make use of it? Seems to me it complicates things a little when you try to fight SketchUp for the group - slapping its wrist using hidden temp geometry.

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

                                  1 Reply Last reply Reply Quote 0
                                  • N Offline
                                    niccah
                                    last edited by

                                    @thomthom said:

                                    That's where I ask: why do you need to create the group in advance before you actually make use of it? Seems to me it complicates things a little when you try to fight SketchUp for the group - slapping its wrist using hidden temp geometry.

                                    πŸ˜„ Okay, let me "answer" with a new question - what can I do else? πŸ˜„ The user would like to create a project => so, somewhere I have to save this information about the projects (name, options, etc, ..). And the user could create a project and close Sketchup => so, the information about the new project has to be saved somewhere "for ever".

                                    I realy agree, my way is realy complicated...

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

                                      OK major problem with your logic.

                                      In Ruby you can cause the current editing context (the "project" group,) to be exited, via:
                                      model#close_active()

                                      BUT there is no API method to enter INTO an editing context. (You cannot cause the "project" group to become active for edit.)

                                      I'm not here much anymore.

                                      1 Reply Last reply Reply Quote 0
                                      • Chris FullmerC Offline
                                        Chris Fullmer
                                        last edited by

                                        @niccah said:

                                        The user would like to create a project => so, somewhere I have to save this information about the projects (name, options, etc, ..). And the user could create a project and close Sketchup => so, the information about the new project has to be saved somewhere "for ever".

                                        Use an attribute dictionary to attach information to the model. It will stay with it after the model is closed and opened.

                                        Single Dictionatires
                                        http://www.sketchup.com/intl/en/developer/docs/ourdoc/attributedictionary

                                        Collections of multiple dictionaries
                                        http://www.sketchup.com/intl/en/developer/docs/ourdoc/attributedictionaries

                                        This is a much more stable way to maintain data in the model from session to session.

                                        Chris

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

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

                                        Advertisement