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

    Selection add

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 444 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.
    • P Offline
      Pauline01
      last edited by

      Hello,

      I select the objects where the attribute ZoneAdr = ZoneName.

      I want after to have a selection of all item to can see them (in my code ### I want to have my objects added to the selection to see them
      ##??? selection.add e? ).

      I see "selection.add entity" but i don't know if it's the good function.

      Else i want change the color of my object what is the function?

      thx.

      
      def selectbindzone
      
      val = Sketchup.active_model.selection[0].get_attribute("MyDico", "ZoneName")
      default = [val]
      UI.messagebox (default.to_s )
      
      
      model=Sketchup.active_model
      entities=model.selection.to_a
      entities=model.entities.to_a
      
      ### an array
      #blinds=[] 
      entities.each{|e|
                 
            val2 = e.get_attribute("MyDico", "ZoneAdr")
            default2 = [val2]
      
        if default2.to_s==default.to_s
          
      
          ### I want to have my objects added to the selection to see them
          ##??? selection.add e?
      
          UI.messagebox ("object find")
          ### it's a string - could be integer ==
          #blinds << e
      
        end
      }
      end
      
      
      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Incidentally you have entities set to be the selection and entities ! = a typo ?
        Also with the model its often appropriate to use active_entities, i.e. those available in that edit session: entities for the model or group/definition is 'all' entities - even those outside of the current edit set [e.g. when you are editing a group model.entities would refer to everything outside as well, whereas active_entities sis those available to be changed]

        Before you add things to the selection do you want to clear it ?
        selection=model.selection ###... selection.clear
        You have the entity set to ' e' in the each loop / test, so simply add the line
        selection.add(e)
        to select it if it meets the test.

        If you want to change the object's color so you see it then selection is the better option... but to change its color simply use something like
        e.material="red"
        The object will take on a color 'red', making a material called 'red' if it doesn't exist.
        Note that Groups or Component-instances with existing 'internal' materials won't change completely, only those faces with 'default' color [nil] etc...

        Hope this helps... 🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • P Offline
          Pauline01
          last edited by

          nice help.

          Thx

          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