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

Apply changes when click on the element

Scheduled Pinned Locked Moved Developers' Forum
1 Posts 1 Posters 275 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.
  • K Offline
    kimpastro
    last edited by 29 Jul 2015, 14:21

    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
    1 / 1
    • First post
      1/1
      Last post
    Buy SketchPlus
    Buy SUbD
    Buy WrapR
    Buy eBook
    Buy Modelur
    Buy Vertex Tools
    Buy SketchCuisine
    Buy FormFonts

    Advertisement