1

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.

Lionvids
  • 9
  • 3

1 Answers1

2

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_error
  • _lenz_formula
  • _lenz_label

_lenz_formula define the formula and other

Denis Bolomier
  • 350
  • 2
  • 19
  • Hi, thanks for your answer. I tried what you said..but it still not work.. i can't change the attribute lenz of the component. it is still the same.. https://imgur.com/a/jlJKFpp – Lionvids Aug 24 '20 at 14:26