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

    Selection order

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    3 Posts 3 Posters 212 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.
    • S Offline
      ssunderland
      last edited by

      Hi, I've been trying to apply an Attribute Dictionary to some entities in the outliner window but haven't been having my luck. It seems like Sketchup is picking a random entity as the place to start, rather than the first one I clicked on or selected like you would assume.

      IE. My first entity gets assigned the dictionary 12 instead of 0, my second gets assigned the dictionary 13 instead of 1, etc.

      I've double checked the code with others just to make sure it was correct, but I'm wondering if anyone else has experienced this randomized order of your selection.

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        I see the same. Evidently Sketchup does not promise to order the elements of the Selection based on the order in which you picked them on the GUI or Outliner. This may be a result of the data structure SketchUp uses to store the selection set (some structures optimized for search don't preserve order). You may need to give the entities names first so that you can test which one is which (this is a good idea anyway).

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

          You cannot rely on the order of elements in a Selection.
          If you freeze it using es=selection.to_a then the order is frozen - but not much use.
          You can extract objects from a selection using grep, e.g. ...
          gs=selection.grep(Sketchup::Group)
          Gives you an array of all groups in the selection.
          You can make an array of their names [sorted] and then find their matching id - into an hash - which might then be in an order you want...
          But you haven't really explained why the selected-items' order is so important for you...
          😕

          TIG

          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