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

    Apply changes when click on the element

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 287 Views 1 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.
    • kimpastroK Offline
      kimpastro
      last edited by

      Hello guys, need some help again.

      Scenario:

      Have two entities selected, and when I click in my plugin need to calculate the sum of both selected LenX and apply this value on the next entity that i'll click. Like image below:

      http://imageshack.com/a/img538/3996/y8E0rI.jpg

      My code until now:

      
      model = Sketchup.active_model
      selections = model.selection
      
      lenx_total = 0.to_i
      leny_total = 0.to_i
      lenz_total = 0.to_i
      
      if selections.empty?
        UI.messagebox('Select at least one component.')
      else
          selections.each do |sel| 
            lenx_total = lenx_total + sel.definition.get_attribute('dynamic_attributes', '_lenx_nominal')
        end
      end
       
      # All this is for test only, where i'm stuck and trying to discover something
      model.find_entity_by_id(18618).definition.set_attribute 'dynamic_attributes', '_lenx_nominal', lenx_total
      new_def = model.find_entity_by_id(18618).definition
      model.place_component new_def
      
      

      Thanks for your time.

      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