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

    Highlight each instance in a selection set

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 543 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