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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Highlight each instance in a selection set

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 580 Views 2 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.
    • C Offline
      confitex architure
      last edited by

      Hello!
      I'm building a selection set and would like to view every component instance, one by one, in the selection.

          ss = Sketchup.active_model.selection
      
           ss.each do |e|
           if( e.kind_of? Sketchup;;ComponentInstance )
      ...
      
      

      What can I insert in the "do" loop operation in order to visualy highlight every instance?

      Thanks for your help!

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

         
        ss = Sketchup.active_model.selection.collect
        ss.each do |e|
          if( e.kind_of? Sketchup;;ComponentInstance )
            Sketchup.active_model.selection.clear
            Sketchup.active_model.selection.add e
            UI.messagebox("Next")
          end
        end
        
        

        Hi

        1 Reply Last reply Reply Quote 0
        • C Offline
          confitex architure
          last edited by

          Thanks Jim!
          Once again, you hit the mark.
          First, I missed the ".collect" and get a bug on sketchup.

          Have you got any idea what scan order is prefered in the 'do' loop?
          Any way to sort the collection?

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

            @unknownuser said:

            Thanks Jim!
            Once again, you hit the mark.
            First, I missed the ".collect" and get a bug on sketchup.

            Have you got any idea what scan order is prefered in the 'do' loop?
            Any way to sort the collection?

            Collect is a Ruby method that just makes a copy of the selections in an Array.

            There isn't any order to the entities returned (that I am aware of.) You'll need to sort them manually, possibly by building another array of only the instances. Then, you'll need to decide what to sort on: definition name, color, position, size?

            Hi

            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