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

    SelectionObserver and get attributes....

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 219 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.
    • P Offline
      Pauline01
      last edited by

      Hello,

      I see the classe http://code.google.com/intl/fr-FR/apis/sketchup/docs/ourdoc/selectionobserver.html, i use this to run a ruby script when i click on a component in skecthup.

      for example:

      My component "Component#1" has in "Component Attribute" an identity, adress, and others descriptions... i want when i click on this component, run my ruby script (I already did that), but i don't know to retrieve "Component Attribute". I wish put for example the attribute "identity" of "Componente#1" in a variable in ruby.

      
      require 'sketchup.rb'
      
      class MySelectionObserver < Sketchup;;SelectionObserver
      
             def onSelectionBulkChange(selection)	   
      		wd=UI;;WebDialog.new( "Somfy Controller", true, "",950, 700, 100, 100, false )
      		wd.show
      		
      ####################
      		#I WANT TO PUT IDENTITY ATTRIBUE OF MY COMPONENT#1 IN THIS VARIABLE
                      identity= '000003'
      		wd.set_url("http://localhost/final_programme/index.php?identity="+identity+"")
      ####################
      
             end
      end
      
           # Attach the observer.
           Sketchup.active_model.selection.add_observer(MySelectionObserver.new)
      # end of sample.rb
      
      

      thx to help me

      Pauline

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        How to set attributes?

        entity.get_attribute http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entity.html#get_attribute
        entity.set_attribute http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entity.html#set_attribute

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          Hi Pauline, the attributes for a Dynamic Component are in the the "dynamic_attributes" attribute_dictionary.

          
          # Check  "dynamic_attributes" dictionary for a Dynamic Component
          identity = selected[0].get_attribute("dynamic_attributes", "identity")
          # the Definition may have the attribute, so...
          if identity.nil?
            identity = selected.definition.get_attribute("dynamic_attributes", "identity")
          end
          if identity.nil?
            # there is not attribute named "identity"
          else
            # Yes, we found "identity"
          end
          
          

          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