# Can't show copy formula

**URL:** <https://forums.sketchup.com/t/cant-show-copy-formula/53155>\
**Category:** Dynamic Components\
**Tags:** sketchup\
**Created:** [October 12, 2017, 4:50pm UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155 "2017-10-12T16:50:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CharellkingQu](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@CharellkingQu](https://forums.sketchup.com/u/CharellkingQu)\
**Post date:** [October 12, 2017, 4:50pm UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155/1 "2017-10-12T16:50:29Z")

</div>

```ruby
    component_def = Sketchup.active_model.selection[0].definition
    custom_attr = {
        "_formatversion" => 1.0,
        "_has_movetool_behaviors" => 0.0,
        "_hasbehaviors" => 1.0,
        "_inst___iscollapsed_access" => nil,
        "_inst___iscollapsed_formlabel" => nil,
        "_inst___iscollapsed_formula" => nil,
        "_inst___iscollapsed_formulaunits" => nil,
        "_inst___iscollapsed_label" => nil,
        "_inst___iscollapsed_options" => nil,
        "_inst___iscollapsed_units" => nil,
        "_inst__copies_access" => nil,
        "_inst__copies_formlabel" => nil,
        "_inst__copies_formula" => "1+2",
        "_inst__copies_formulaunits" => nil,
        "_inst__copies_label" => "Copies",
        "_inst__copies_options" => nil,
        "_inst__copies_units" => nil,
        "_inst__iscollapsed" => "false",
        "_inst_copies" => 0.5333333333333258,
        "_lastmodified" => "2017-10-12 23:54",
        "_lengthunits" => "CENTIMETERS",
        "_name" => "Component#2",
    }

    custom_attr.each { |k, v|
        component_def.set_attribute("dynamic_attributes", k, v)
    }

```

when i set copy attribute, but i can’t see the “Copies” attribute

 ![abc](https://global.discourse-cdn.com/sketchup/original/3X/4/6/464b4e8ba812a8a7a2f0398fba373837826ceaaf.png)

---

<div class="post-metadata">

**Author:** ![MikeWayzovski](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mikewayzovski/32/98346_2.png) [@MikeWayzovski](https://forums.sketchup.com/u/MikeWayzovski)\
**Post date:** [October 12, 2017, 9:13pm UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155/2 "2017-10-12T21:13:49Z")

</div>

You are missing some/adding the wrong…:

 ![Attributes_Copies](https://global.discourse-cdn.com/sketchup/original/3X/f/f/ffd433025dea68b2c1d43050789844119dc47ccb.gif)  
check with attribute inspector what attributes are being used when adding an attribute in DC.

---

<div class="post-metadata">

**Author:** ![CharellkingQu](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@CharellkingQu](https://forums.sketchup.com/u/CharellkingQu)\
**Post date:** [October 14, 2017, 9:10am UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155/3 "2017-10-14T09:10:30Z")

</div>

i set the copy attribute as the “inspector attributes” tools but the "Copies " still not appear.

```ruby
UI.menu("Plugins").add_item("step3") do
    component_def = Sketchup.active_model.selection[0].definition
    component_attr = component_def.attribute_dictionaries["dynamic_attributes"]

    custom_attr = {
        "_formatversion" => 1,
        "_has_movetool_behaviors" => 0,
        "_lastmodified" => "2017-10-14 15:46",
        "_lengthunits" => "CENTIMETERS",
        "_hasbehaviors" => 1,
        "_inst___iscollapsed_access" => "null",
        "_inst___iscollapsed_formlabel" => "null",
        "_inst___iscollapsed_formula" => "null",
        "_inst___iscollapsed_formulaunits" => "null",
        "_inst___iscollapsed_label" => "null",
        "_inst___iscollapsed_options" => "null",
        "_inst___iscollapsed_units" => "null",
        "_inst__copies_access" => "null",
        "_inst__copies_formlabel" => "null",
        "_inst__copies_formula" => "1+2",
        "_inst__copies_formulaunits" => "null",
        "_inst__copies_label" => "Copies",
        "_inst__copies_options" => "null",
        "_inst__copies_units" => "null",
        "_inst__iscollapsed" => "false",
        "_inst_copies" => 0.5333333333333324,
        "_lastmodified" => "2017-10-14 15:59",
        "_lengthunits" => "CENTIMETERS",
        "_name" => "Component#2",
    }

    custom_attr.each { |k, v|
        component_def.set_attribute("dynamic_attributes", k, v)
    }
end

```

---

<div class="post-metadata">

**Author:** ![MikeWayzovski](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mikewayzovski/32/98346_2.png) [@MikeWayzovski](https://forums.sketchup.com/u/MikeWayzovski)\
**Post date:** [October 14, 2017, 1:39pm UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155/4 "2017-10-14T13:39:16Z")

</div>

Try to first make component. Only add copies attributes with formula in Dynamic Components Attributes dialog, you would get these attributes in the dynamic\_library :

> **Attributes**
>
> ```
> "_copies_error" => "1+2",
> "_copies_formula" => "1+2",
> "_copies_label" => "Copies",
> "_formatversion" => 1,
> "_has_movetool_behaviors" => 0,
> "_hasbehaviors" => 1,
> "_inst__copies_access" => "null",
> "_inst__copies_formlabel" => "null",
> "_inst__copies_formula" => "1+2",
> "_inst__copies_formulaunits" => "null",
> "_inst__copies_label" => "Copies",
> "_inst__copies_options" => "null",
> "_inst__copies_units" => "null",
> "_inst__copy_access" => "null",
> "_inst__copy_formlabel" => "null",
> "_inst__copy_formula" => "null",
> "_inst__copy_formulaunits" => "null",
> "_inst__copy_label" => "null",
> "_inst__copy_options" => "null",
> "_inst__copy_units" => "null",
> "_inst_copies" => 3,
> "_inst_copy" => 3,
> "_lastmodified" => "2017-10-14 15:00",
> "_lengthunits" => "CENTIMETERS",
> "_name" => "MyNamedComponent",
> 
> ```

Try it with a newly made component. To work properly, you would have to redraw the DC, first get the proper observer, then do a redraw on selection.

```
sel=Sketchup.active_model.selection[0]
dcs = $dc_observers.get_latest_class 
dcs.redraw_with_undo(sel)

```

 ![DynamicComponent](https://global.discourse-cdn.com/sketchup/original/3X/7/e/7e24ea3e316855635e6096c2054f970f8822f7f1.gif)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [January 14, 2018, 5:39am UTC](https://forums.sketchup.com/t/cant-show-copy-formula/53155/5 "2018-01-14T05:39:55Z")

</div>

Closed on January 14, 2018, 5:39am UTC

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
