model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
vertices = selection.grep(Sketchup::Face).map(&:vertices).flatten.uniq
# Explode curves if any
vertices.each do |vertex|
vertex.edges[0].explode_curve
end
vec = Geom::Vector3d.new(0,0,1.m)
tr = Geom::Transformation.new(vec)
entities.transform_entities(tr, vertices)
It seems that the method #transform_entities does not work on vertices that are used in curves. That is why I made sure to explode the curves. I would like to know if this is a BUG or if it is normal.
You are right I was not selecting the group, instead, I was selecting a face.
My confusion was because I didnāt know that variable g was short for āgroupā. I should have figured it out when I saw g.entities but I didnāt. I would recommend to @javalitterboy to not name variables with a single letter next time so the code is understood better.
I would use the following to get a selected group.
model = Sketchup.active_model
selection = model.selection
group = selection.grep(Sketchup::Group)[0]
msg = 'Please select a group before using this tool'
UI.messagebox(msg, MB_OK) if group.nil?
When using the code @DanRathbun posted and I select the group it works, but if you have a circle inside a group it transforms the vertex in the wrong direction. Seems it is using another axis that is different than the group axis.
However when I try running the code on the model that @javalitterboy shared it gives an error.