@pcmoor said:
0ne point I have found, the copy function within the DC does not make an instance, but another DC embedded within the group. this uses up memory, compare the file sizes of 100 normal copies compared to a DC copying its self. (note you also need to purge the file after going back from 100 to 1)
This may explain your observations
Confirm on the file size point;
* 0 definitions, 0 instances - 6.93 KB (7,101 bytes)
* 1 definitions, 0 instances - 12.2 KB (12,521 bytes)
* 1 definitions, 100 "copy+paste" copies, 25 KB (25,620 bytes)
* 1 definitions, 200 "copy+paste" copies, 39.7 KB (40,750 bytes)
* 1 definition, 0 "dc-copies" (copies=0, no instance), 15.9 KB (16,373 bytes)
* 1 definition, 1 "dc-copies" (copies=0), 17.0 KB (17,476 bytes)
* 1 definitions, 100 "dc-copies" (copies=99) copies, 86.9 KB (89,005 bytes)
* 1 definitions, 200 "dc-copies" (copies=199) copies, 160 KB (164,302 bytes)
Those numbers don't seem to add up for your theory though (using a naive approach)
>>> file_overhead = 7101
>>> definition = 12521 - file_overhead
>>> definition # Cost of definition excluding DC attributes
5420
>>> one_clone = 16373 - file_overhead
>>> one_clone # Cost of definition including DC attributes
9272
>>> cp_100_cost = (25620 - (file_overhead + definition)) / 100.0
>>> cp_100_cost
130.99
>>> cp_200_cost = (40750 - (file_overhead + definition)) / 200.0
>>> cp_200_cost
141.145 # Acceptable variance
>>> dc_100_cost = (89005 - (file_overhead + one_clone)) / 100.0
>>> dc_100_cost
726.32
>>> dc_200_cost = (164302 - (file_overhead + one_clone)) / 200.0
>>> dc_200_cost
739.645 # Acceptable variance
If there was a copy of the definition for each of the "dc-copies" instances, you would expect the dc_*00_cost
to be closer to the value for one_clone
Also
` # 100 "copy-paste" instances
Sketchup.active_model.selection.length
100
Sketchup.active_model.selection.first.definition.instances.length
100
Sketchup.active_model.selection.map() {|i| i.definition}.uniq.length
1
100 "dc-copies" instances
Sketchup.active_model.selection.length
100
Sketchup.active_model.selection.first.definition.instances.length
100
Sketchup.active_model.selection.map() {|i| i.definition}.uniq.length
1`
I imagine some of the filesize distance would come from storing the attributes on each instance (although we have 63385 bytes to account for)
Sketchup.active_model.selection.first.attribute_dictionary('dynamic_attributes').each() {|k, v| puts " #{k} = #{v.inspect}" } _copies_label = "Copies" _has_movetool_behaviors = 1.0 _hasbehaviors = 1.0 _lengthunits = "CENTIMETERS" _name = "Component#1" _y_error = "<span class=subformula-success>10.0</span>*200" _y_formula = "COPY * 200" _y_label = "Y" copies = "99" copy = 10 leny = 39.3700787401575 y = 787.40157480315
I tested this by adding some position and scale attributes to the component, and the file size jumped up to 168 KB (172,766 bytes)
(from 86.9 KB (89,005 bytes)
) for 100 and 314 KB (321,979 bytes)
(from 160 KB (164,302 bytes)
)for 200. (or 837.61 bytes/instance for 100 and 788.385 bytes/instance for 200). ~800 bytes for attributes only seems a bit heavy for only attributes but doesn;t come near the size of the definition (which, including attributes is 19.8 KB (20,351 bytes) [including file overhead]
or 13250 bytes [exlcuding file overhead]
In these tests, there was no excessive components to purge, but that was by design (single depth component. no per-instance formula).
@pcmoor, This leads me to believe that this isn't the cause, but it still interesting information none-the-less. I do appreciate the input, though - and has given me food for thought on the cost of using copies.
Edit: just as a double confirm, if I take the "dc-copies" component, set it copies to 0 and then "copy-paste" for a total of 100, the file size comes out roughly the same as if I had used "dc-copies" (copies=99), at 165 KB (169,312 bytes)
(within 3 KB)