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

Add an object to the selection based on a attrib.

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 321 Views
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.
  • P Offline
    Pout
    last edited by 4 Sept 2008, 12:06

    Hello all,

    In the attribute dictionary of all my objects in the model i have added a unique identifier for each object (since i have noticed that the ID's created by SU itself are not solid over several sessions)

    Now if i want to add an entity-group-whatever with a specific unique id to the selection (so it shows selectedin SU) do I need to loop through all the available objects in SU?

    Or is it possble to directly get that object and add it to the selection? (like:
    object= select where ent.get_attribute "attrdict", "attrname" = xxx
    selection_add object

    Thx again

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 5 Sept 2008, 00:47

      @pout said:

      Hello all,

      In the attribute dictionary of all my objects in the model i have added a unique identifier for each object (since i have noticed that the ID's created by SU itself are not solid over several sessions)

      Correct.

      @unknownuser said:

      Now if i want to add an entity-group-whatever with a specific unique id to the selection (so it shows selectedin SU) do I need to loop through all the available objects in SU?

      Yes. If there are a small number of entities, you could just loop over them. But it would be better to loop over them once, and hash the entities by your ID so you can just look them up.

      @unknownuser said:

      Or is it possble to directly get that object and add it to the selection? (like:
      object= select where ent.get_attribute "attrdict", "attrname" = xxx
      selection_add object

      This line is the same as looping over everything in the model:

      
      
      Sketchup.active_model.selection.add( Sketchup.active_model.entities.select{|e| e.get_attribute("Dict", "key") == "value"} )
      
      

      @unknownuser said:

      Thx again

      Hi

      1 Reply Last reply Reply Quote 0
      • P Offline
        Pout
        last edited by 8 Sept 2008, 12:49

        Excellent,
        Thank you very much!

        Also, could you point me out a good book for ruby for SU?
        i have this one book here now 'Learning Ruby' from O'reilly but it doesn't seem to contain the info i need.

        Regards,

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by 8 Sept 2008, 14:07

          This is no book for Ruby in SketchUp, per se. There are Ruby books and there are SketchUp books. The book I use as a reference for Ruby is called the Pickaxe book. An older copy is available online here: http://phrogz.net/ProgrammingRuby/frameset.html

          Todd

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

          Advertisement