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

    What what what? This makes no sense!

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 943 Views 3 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.
    • thomthomT Offline
      thomthom
      last edited by

      Save the following snippet into a test module in your plugins folder.

      Draw some shapes in SU and select everything. (have some groups/comps)

      
        def self.test
          model = Sketchup.active_model
          ents = model.selection.to_a
          arr = []
          until ents.empty?
            e = ents.shift
            next unless e.is_a?(Sketchup;;Edge)
            arr << e.all_connected.to_a.select{ |entity| entity.is_a?(Sketchup;;Edge) }
          end
          arr.length
        end
      
      

      When you run the snippet, which does nothing but create some arrays, the loose geometry appears to deselect. But they are in fact selected, which the Entity Info displays. You can even use the move tool for instance and see that everything is moved.

      It all boils down to this line:
      arr << e.all_connected.to_a.select{ |entity| entity.is_a?(Sketchup::Edge) }

      But why? It makes no sense.
      I see this on SU 7.1, Windows and OSX. It's maddening!

      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

        I slimmed it down further:

        
          def self.test
            model = Sketchup.active_model
            ents = model.selection.to_a
            e = ents.shift
            e.all_connected
          end
        
        

        If you have three separate squares in your model selected when you run this, then one will appear to be unselected afterwards.

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

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

          Glitch in the API somewhere - until it's fixed perhaps you can add model.selection.add(ents) near the end to ensure the original selection stays highlighted ? πŸ˜•

          TIG

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

            @tig said:

            Glitch in the API somewhere - until it's fixed perhaps you can add model.selection.add(ents) near the end to ensure the original selection stays highlighted ? πŸ˜•

            .add and .remove are just aliases for .toggle

            @thomthom said:

            I slimmed it down further:

            So did I, the culprit is the .all_connected methods for Face and Edge classes.

            module Select_Test
              def self.go
                model = Sketchup.active_model
                view = model.active_view
                sel = model.selection
                sfc = sel.first.all_connected
                view.refresh
                  # the first square unhilites
                UI.messagebox('Ready to Re-Hilite the square.')
                sel.toggle sfc  # removes from the selection
                sel.toggle sfc  # adds back into selection
                view.refresh
                  # the first square REhilites
              end
            end # module
            
            

            P.S.: I AVOID using "test" as a method name because of the importance of Kernel.test which all objects inherit.

            I'm not here much anymore.

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

              @thomthom, is this still a bug, or has it been fixed ?

              I'm not here much anymore.

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

                hm...
                I don't recall this thread at all any more. But I tried this in SU2016, and it seem to be doing something odd. In my test a group would be deselected after running this code and making a zoom to update the viewport.

                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