# Ruby api set a new dynamic attributes attributes and value but this windows can not display that value

**URL:** <https://forums.sketchup.com/t/ruby-api-set-a-new-dynamic-attributes-attributes-and-value-but-this-windows-can-not-display-that-value/85567>\
**Category:** Ruby API\
**Tags:** sketchup-pro\
**Created:** [January 16, 2019, 5:42am UTC](https://forums.sketchup.com/t/ruby-api-set-a-new-dynamic-attributes-attributes-and-value-but-this-windows-can-not-display-that-value/85567 "2019-01-16T05:42:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wang](https://avatars.discourse-cdn.com/v4/letter/w/edb3f5/32.png) [@wang](https://forums.sketchup.com/u/wang)\
**Post date:** [January 16, 2019, 5:42am UTC](https://forums.sketchup.com/t/ruby-api-set-a-new-dynamic-attributes-attributes-and-value-but-this-windows-can-not-display-that-value/85567/1 "2019-01-16T05:42:38Z")

</div>

i create a component. like it

 ![QQ%E5%9B%BE%E7%89%8720190116133357](https://global.discourse-cdn.com/sketchup/original/3X/c/0/c0d496a3d35b5de42b266c1b2cca886218933013.png) .  
then i use ruby api like this:  
model = Sketchup.active\_model  
selection = model.selection  
en = selection[0]  
en.set\_attribute “dynamic\_attributes”, “Vico01”, “123\*12”  
And then i open this window: ![QQ%E5%9B%BE%E7%89%8720190116133813](https://global.discourse-cdn.com/sketchup/original/3X/e/d/edd3fc908ce35e925373ad310dc0ca55bc17a966.png)  
the value of Vico01 is display null and get this ERRORl:  
 ![QQ%E5%9B%BE%E7%89%8720190116134022](https://global.discourse-cdn.com/sketchup/original/3X/0/0/0054e232c56656e5c79c77991a9d25b6054392f4.png)  
why the dialog window can not display this value. how do for fix it.

---

<div class="post-metadata">

**Author:** ![eneroth3](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/eneroth3/32/1222_2.png) [@eneroth3](https://forums.sketchup.com/u/eneroth3)\
**Post date:** [January 16, 2019, 3:45pm UTC](https://forums.sketchup.com/t/ruby-api-set-a-new-dynamic-attributes-attributes-and-value-but-this-windows-can-not-display-that-value/85567/2 "2019-01-16T15:45:22Z")

</div>

First of all I’d recommend to use a graphical tool to set the attributes, e.g. Aerilius’ Attribute Inspector. This makes it easier to see what you are doing, e.g. make sure names aren’t misspelled, and that the attribute type matches similar attributes.

However I’d also discourage building anything around Dynamic Components. Dynamic Components have no public documented API, and are not meant to be interacted with from other scrips. Any third party scripts that successfully interacts with DCs does it just by change, not because DC is designed to work that way, and any change in DCs could break it.

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [January 16, 2019, 4:29pm UTC](https://forums.sketchup.com/t/ruby-api-set-a-new-dynamic-attributes-attributes-and-value-but-this-windows-can-not-display-that-value/85567/3 "2019-01-16T16:29:49Z")

</div>

Also the Dynamic Components Extension has its own “language” for expressions in attributes. That means it needs to parse and validate the value before it knows it is an expression that it can evaluate. This means two things:

1. You cannot easily **debug** the issue if you don’t really see the current (possibly invalid) attribute value. Maybe Dynamic Components displays only values only after validation.
2. You **risk** easily introducing errors by setting dynamic attributes through the backdoor because you bypass validation. (Therefore Dynamic Components should have (if it has not) a setter method API that applies validation).

Bear in mind that dynamic components are not a feature of the .skp file format, but an extension that _only_ runs in this implementation of SketchUp (not in the Web version, not in third-party apps that implement an .skp reader (through the SDK) like Unity or Enscape). And dynamic components have not seen active development for a long time.
