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

    How to locate specific group# in model? [Solution Provided]

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    8 Posts 6 Posters 306 Views 6 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.
    • N Offline
      nickdk
      last edited by

      It might be very simple but I don't know how to find a specific group in my model, I have problems cutting group #94 as it freezes but I don't know which group it is, is it possible to locate the #94 in some clever way? πŸ˜„

      1 Reply Last reply Reply Quote 0
      • Dave RD Offline
        Dave R
        last edited by

        It's a shame you weren't using components. You wouldn't have this problem.

        Perhaps one of the Ruby gurus would have a way to determine the group by its number via a bit of code in the Console but it doesn't appear there's any way to identify it from the Outliner or Entity Info.

        Etaoin Shrdlu

        %

        (THERE'S NO PLACE LIKE)

        G28 X0.0 Y0.0 Z0.0

        M30

        %

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

          You can of course manually give your 'unnamed' Groups individual names using 'Entity Info', but the Groups' definitions' names always stay as 'Group#1', 'Group#2' etc.
          If Groups don't have names this "one-liner" will change their names to match their definition-name - then you can use the Outliner to select 'by name'.

          m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.instances[0].definition.name if g.name.empty?}};m.commit_operation
          

          Copy/Paste all of the code + <enter> into the Ruby Console and then use the Outliner to see/highlight the Group[s] by name.
          It is one-step undo-able in case you mess up...
          IF you want EVERY Group to be renamed [perhaps dangerous?] then remove the text ' if g.name.empty?' from the one-liner, and then all Groups get named after their definition-name - 'Group#1', 'Group#2' etc overwriting any earlier names you might have added manually using 'Entity Info'...
          πŸ€“

          TIG

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            You can select the Group in the Outliner window. On Windows, you can limit the visible entities by entering text in the Outliner's filter box.

            Hi

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

              The problem is that unnamed Group all display as 'Group' in the Outliner, so if you get an error referring to a specific Group definition name you have no way of finding it... My snippet changes unnamed Groups names to match their definition so you can then find them in the Outliner because then name==defn.name...

              TIG

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                When I used this code-

                m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.instances[0].definition.name if g.name.empty?}};m.commit_operation
                

                I got this error-
                Error: #<NoMethodError: undefined method `definition' for #Sketchup::Group:0x834ce04>

                removing the .definition removed the error but did not result in the naming of the groups.

                removing the .instances[0] seemed to work as expected. The final code string was

                m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.name if g.name.empty?}};m.commit_operation
                

                As an alternative, selecting the offending group will make it easier to find.

                m=Sketchup.active_model;s=m.selection;m.start_operation("sel grp");s.clear;m.definitions.each{|d|  next unless d.group?;if d.name == "Group#94";d.entities.each{|e| s.add e};end;};m.commit_operation
                

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

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

                  Thank you very much TIG, I'll test it soon πŸ˜„

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

                    d.instances[0].definition.name
                    This line makes little sense. The definition uses an instance of itself to get its definition...

                    It's equal to d.name. And d.name will avoid the error because Group doesn't have .definition.

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

                    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