Pushpull BUG?

group.entities.map {|e| e.pushpull(100) if e.is_a?Sketchup::Face }

group is including only one face
but this crashes everytime
must be a bug

I drew a rectangular face, grouped it, selected the group, and then ran

group = Sketchup.active_model.selection[0]
group.entities.map {|e| e.pushpull(100) if e.is_a?Sketchup::Face }

It worked as expected, without crashing. That makes me suspect there is something odd about your group variable that may be triggering a bug. Can’t tell without knowing the details of how you obtained it.

I’d suggest going about this a different way:

group.entities.grep(Sketchup::Face).each {|f| f.pushpull(100)}

I suspect there may be some issue with pushpull modifying the entities collection while map is iterating over it. That is, pushpull adds both a new bottom face and side faces, each of which may then pick up as eligible for the map.

2 Likes

must be it , it crashes after running and runing.
but why not u?

and i learned a new thing thanks u!

Just an FYI, … Enumerable#grep itself allows a block arguement, so the .each call is unneeded.

Ex:

group.entities.grep(Sketchup::Face) { |f| f.pushpull(100) }
1 Like

without “each”, it crashed again
guessing “each” ends enumerating and create a new array
tired of crashing, i use this instead :tired_face: , since i only need to manipulate a single face group

group.entities.grep(Sketchup::Face)[0].pushpull(100)