When I tried to retrieve the materials of faces in group in my friend’s model, I found out that in some groups, all of their materials of faces were nil and the other groups would not have this problem. But every group indeed had materials. I am very confused and can not figure it out.
Here is my code.
mod = Sketchup.active_model
ent = mod.entities
sel = mod.selection
ent.grep( Sketchup::Group ).each{|e|
if e.definition.entities.grep( Sketchup::Face ).length==0 then
UI.messagebox "1"
else
for i in 0...e.definition.entities.grep( Sketchup::Face ).length
if e.definition.entities.grep( Sketchup::Face )[0].back_material.nil? then
UI.messagebox "nil"
else
UI.messagebox e.definition.entities.grep( Sketchup::Face )[0].>material.name
end
end
end
}
BTW there is a group that I can’t see or select(by"select all") in the screen. It only exist in ruby console. All the groups I can see have faces and I have already purged unused definitons.