How deleted an object with ruby script in sketchup


#1

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
grp = ent.add_group

block = grp.entities.add_face [100,100,0],[150,100,0],[150,150,0],[100,150,0]
block.reverse!
block.pushpull 12

block1 = grp.copy
block1.material = 'red’
tr = Geom::Transformation.scaling 0.5,2,1
ent.transform_entities tr, block1

tr = Geom::Transformation.new [100,50,30]
ent.transform_entities tr, block1

i have an question about my program in ruby script.
is it possible to delete the ‘block’ object…?
thanks


#2

Since “block” represents just the original face, I think you would want the erase “grp” instead.

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
grp = ent.add_group

block = grp.entities.add_face([100,100,0],[150,100,0],[150,150,0],[100,150,0])
block.reverse!
block.pushpull 12

block1 = grp.copy
block1.material = "red"
tr = Geom::Transformation.scaling(0.5,2,1)
ent.transform_entities(tr, block1)

tr = Geom::Transformation.new([100,50,30])
ent.transform_entities(tr, block1)

#block.erase!; ## erases the original face only
grp.erase!; ## erases the original group


#3

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.