Place component with dynamic attribute change

when placing component with dynamic attribute .component placed successfully and dynamic attribute value updated in Attribute inspector with resizing not working.

def place_component()
path=File.expand_path(‘…/…/’, dir).concat(“/src/images/cabinet1.skp”)

dict = ‘dynamic_attributes’
mod = Sketchup.active_model
defs = mod.definitions
componentdefinition = defs.load(path)

componentdefinition.set_attribute(dict,'_lenx_nominal','50')
componentdefinition.set_attribute(dict,'_leny_nominal','50')
componentdefinition.set_attribute(dict,'_lenz_nominal','50')

mod.place_component(componentdefinition)

end

code working dynamic attribute value updated but not refreshed means redraw.

dynamic attribute value changed but component size not updated.

You have set it for the definition, not the instance (the one in the model view)

Check this thread:

See how to properly post code in the forum …

I have tried as u refer but not working. now component not placing on window.

def place_component()
   path=File.expand_path('../../', __dir__).concat("/src/images/cabinet1.skp")          
  
  dict = 'dynamic_attributes'
    mod = Sketchup.active_model
    defs = mod.definitions               
    componentdefinition = defs.load(path)      
   
    sel = Sketchup.active_model.selection
    dco = $dc_observers.get_latest_class
    sel.grep(Sketchup::ComponentInstance).each do |inst|     
      dco.set_attribute(dict,'_lenx_nominal','50')
      dco.set_attribute(dict,'_leny_nominal','50')
      dco.set_attribute(dict,'_lenz_nominal','50')
      dco.redraw_with_undo(inst)
    end

I want to recalculate attribute value which is currently loaded by

 componentdefinition = defs.load(path)   

But with the using below code

sel = Sketchup.active_model.selection
    dco = $dc_observers.get_latest_class
    sel.grep(Sketchup::ComponentInstance).each do |inst|     
      dco.set_attribute(dict,'_lenx_nominal','50')
      dco.set_attribute(dict,'_leny_nominal','50')
      dco.set_attribute(dict,'_lenz_nominal','50')
      dco.redraw_with_undo(inst)
    end

I’m able to recalculate selected component on sketchup window.

I want to recalculate attribute value which is currently loaded by

 componentdefinition = defs.load(path)