I’m trying to clean up an export from Alpine Truss software…
I’d like to erase all the “plates” on the trusses.
The truss assembly is wrapped in a component, but all the geometry is loose inside. So my approach was to identify the plate faces (and edges) according to the unique material that is used on them. In this case, the material name is
model = Sketchup.active_model ents = model.entities ents.each do |entity| model.start_operation('Delete Truss Plates', true) if entity.is_a?(Sketchup::Group) || entity.is_a?(Sketchup::ComponentInstance) objectDef = entity.definition facesToDelete =  objectDef.entities.each do |ents| if ents.is_a?(Sketchup::Face) && ents.material && ents.material.display_name=="<auto>4" allEnts = ents.all_connected #grab the edges too facesToDelete = facesToDelete + allEnts #add entities to array to delete later end end if facesToDelete.length > 0 facesToDelete.each do |thing| puts "erased" + thing.entityID #testing thing.erase! #error here?? end end end facesToDelete =  #empty the array?? model.commit_operation end
I’m getting an error: Code failed with an error: TypeError: reference to deleted Entity
I can’t figure out why, but it seems like somehow an entity inside the facesToDelete array is trying to be referenced/deleted after it has been deleted. I’ve tried emptying the array after each loop (even though I’m just testing it on a single group at the moment). Stuck at the moment. Any ideas?
Truss1121.skp (36.4 KB)