rubypluginssketchup

How to change attribute LenX/Y/Z of your component in sketchup using ruby?


i am trying to make a dynamic component in Sketchup, i need to set value to lenZ, lenX, lenY.. but when i set it, it doesn't change. The attribute inspector shows the change, but the component doesn't change. i tried using redraw, refresh view..but it's still doesn't works.. (i need to do by this way, i need to set the component from a ruby plugin, and after it, i must ajust it by their attributes). (excuse my english..)

This is the code that i am using:

sk = Sketchup
model = sk.active_model
view = model.active_view
sel = model.selection
obj = sel.first
dcs = $dc_observers.get_latest_class

obj.set_attribute('dynamic_attributes','lenz',20)
dcs.redraw(obj)

This is a image of the component, but their size is the same.


Solution

  • First $dc_observers.get_latest_class should be at the end.

    Second , you set dcs as the result of $dc_observers.get_latest_class

    trhird , you should affect the value to the definition

    please find below the code that should work

    model = Sketchup.active_model
    sel = model.selection
    obj = sel.first
    obj.definition.set_attribute "dynamic_attributes", "_lenz_formula", "360"
    $dc_observers.get_latest_class.redraw_with_undo(obj)
    

    EDIT

    for DC they are several other hidding attributes starting by "_"

    _lenz_formula define the formula and other