SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Sketchup.active_model.materials.size() != Sketchup.active_model.materials.to_a.size() #12

Open prachtan opened 6 years ago

prachtan commented 6 years ago

1). Sketchup 2018 / 2017 Make 2). Windows 10 x64

Inconsistency in RubyAPI if there is image-type material between:

Sketchup.active_model.materials.size() != Sketchup.active_model.materials.to_a.size()

Steps to reproduce:

Expect behavior: Sketchup.active_model.materials.to_a() should also returns an array containing image-type materials.

thomthom commented 6 years ago

Logged as SU-38308

DanRathbun commented 3 years ago

In my opinion, this issue should be closed as "Works as Intended" and/or "Won't Fix".

And the documentation should be edited so that this situation does not come as a surprise to coders. See Issue Add Ruby API information or warnings for internal vs manager materials #572 for the explanation of why there is an intended difference in the size of the materials collection and the size of derived enumerables (which use the class' overridden #each method that is purposefully designed to operate upon a subset.)

So what I am basically saying here is that this issue would not have been reported had the documentation explained to the true situation with internal versus public materials.

Coders could use a refinement similar to the example posted in Issue 180 (or use it for ideas for local extensions methods) until API classes actually get better treatment (ie, additional methods and iterators) to help this situation: Ruby class refinement for SketchUp 2019.2 or higher