Thanks you all you guys in this wonderful forum . It’s very useful for me to learn many things from here
I’m just a newbie of sketchup ruby .
When I did search here I found this nice code , I tried to make it to ‘Plugin’ but very hard . Would somebody please make this to small plugin for me .
Many thanks
def self.copy_entities(tr, entarray)
# Copies and transforms an array of entities
model = Sketchup.active_model # Open model
ent = model.entities # All entities in model
if entarray.length == 0
UI.messagebox "Select object"
return
end
tempgroup = ent.add_group entarray
temptrans = tempgroup.transformation
tempdef = tempgroup.definition
newgroup = ent.add_instance tempdef, temptrans
ent.transform_entities(tr, newgroup)
newgroup.explode
tempgroup.erase!
end #def
#test using selection entities
model = Sketchup.active_model # Open model
ent = model.entities # All entities in model
sel = model.selection # Current selection
ss = model.active_entities
entities = model.active_entities
# define some delta transform
model.start_operation "Erase Inside"
ent_face = entities.grep(Sketchup::Face).find_all
ent_edges = entities.grep(Sketchup::Edge).find_all
ent_face.to_a.each { | entity| entity.erase! }
ent_edges.to_a.each { | entity| entity.erase! }
ent_group = entities.grep(Sketchup::Group).find_all
ent_group.to_a.each { | entity| entity.explode }
vector = Geom::Vector3d.new(0.m , 0.m, 0)
tr = Geom::Transformation.translation(vector)
result = self.copy_entities(tr, sel)
model.commit_operation
model.close_active until model.entities == model.active_entities
# Add menu
unless file_loaded?(__FILE__)
menu = UI.menu('Plugins')
menu.add_item('ATI') {
self.create_cube
}
file_loaded(__FILE__)
end