More materials, layers, and loops


#1

To all,

Continuing on from How to efficiently color a polymesh, I updated the code I used as follows (along with a layer companion) –

  • runs from a method so it can be ran several times, count and type of iteration are parameters.
  • now has two operations, one to create the materials / layers and stuff the array, another for the face material / layer changes. The second operation can be undone via ‘Sketchup.undo’ in the console, and allows one to run the code using the different iteration types. The code does not perform the undo.

The model is at

Cubes Test 6k_14.skp

Some interesting data, The following shows timings for 3,000 layers, ran with 8 and 2014, layer window closed and open. SU2014 performs much better than SU8, but if the layer window is open, layer creation goes from about 4 seconds to 45 seconds in 2014.

As metioned in the other thread, with the material window open, only the ‘List View’ caused issues when creating 3k materials. The other view modes were ok.

Finally, iteration type had no noticeable effect on execution time.

When you load the modules, they puts to the console the run info.

Thanks,

Greg

mat_color.rb (2.2 KB)

lyr_color.rb (2.0 KB)

SU8 - Creating 3k layers with native layers window closed
----------------------------------------------------------
Lyrs.run(3000, 0)
199.355 Time - Layer Creation & Array
    0.063 Time - Loop Faces & Change Layers
                         Using .each_with_index
----------------------------------------------------------

SU8 - Creating 3k layers with native layers window open
----------------------------------------------------------
Lyrs.run(3000, 0)
211.824 Time - Layer Creation & Array
    0.031 Time - Loop Faces & Change Layers
                         Using .each_with_index
----------------------------------------------------------

SU2014 - Creating 3k layers with native layers window closed
----------------------------------------------------------
Lyrs.run(3000, 0)
    3.900 Time - Layer Creation & Array
    0.031 Time - Loop Faces & Change Layers
                         Using .each_with_index
----------------------------------------------------------

SU2014 - Creating 3k layers with native layers window open
----------------------------------------------------------
Lyrs.run(3000, 0)
  44.866 Time - Layer Creation & Array
    0.047 Time - Loop Faces & Change Layers
                         Using .each_with_index
----------------------------------------------------------


#2

FYI, “using” is a keyword in Ruby 2.0+.
see: http://ruby-doc.org/core-2.0.0/doc/syntax/refinements_rdoc.html
(It’s used as a local var in the “mat_color.rb” file.)