How to change or reset group axis using ruby code?
Could you give me some example?
This has been answered already. Please learn how to search the Ruby API category.
So in this other topic, it is explained how to create a transformation and apply it to the group’s definition’s entities collection.
There is also a more complex code example in this topic (if instances need to be adjusted) …
[Partially Solved] Rotation transformation not working for me - why not?
def create_rectangle # check for zero height if( @pts != @pts ) entities = Sketchup.active_model.active_entities face = entities.add_face(@pts) face.material = [50, 255, 255] group = entities.add_group(face) myentities = group.definition.entities myentities.transform_entities(transform, myentities.to_a)
Is It right that I use that definition method?
I think I do not understand that topic well enough
Ruby uses 2 space indents.
Do not add arbitrary faces to the active entities as the geometry might merge with existing geometry.
Instead, first create the new empty group, and then add the face to this group …
def create_rectangle(transform) # check for zero height if( @pts != @pts ) entities = Sketchup.active_model.active_entities group = entities.add_group myentities = group.definition.entities face = myentities.add_face(@pts) face.material = [50, 255, 255] myentities.transform_entities(transform, myentities.to_a) end end
In the API …
myentities = group.definition.entities
… is the same as …
myentities = group.entities
… because the latter (
group.entities) is a shortcut to
(At one time in the past, the API tried to hide the fact that a group was really a special kind of component instance that also must have a definition. But we coders complained, and they added the
#definition method the the