In an extension I’m working on to array numbers and optionally rotate them individually or as a collection in a group, my first rotation works, but the second almost identical one doesn’t, and I can’t see why not.
# Rotate the text just drawn to the selected angle
# Calculate text centre point
cp = Geom::Point3d.new(textx_position, 0, 0)
# ents.add_cpoint cp # Use for testing to see component origin point position
text_rotate = Geom::Transformation.rotation cp, Z_AXIS, rotate_angle.degrees
my_flat_text_group.transform! text_rotate
That does what I intend: for example, with the rotate_angle
set to 45°:
A few lines later, when I have assembled a text_group
containing several individual items of text (as shown in the image above), I can’t get this group to rotate as a whole.
# Rotate the array to the selected slope_angle
array_rotate = Geom::Transformation.rotation ORIGIN, Z_AXIS, slope_angle.degrees
text_group.transform! array_rotate
name = text_component.definition.name = text_name
text_component = text_group.to_component
model.place_component text_component.definition
In the Ruby console I checked that all the values in the second Geom::Transformation
exist
slope_angle = 30.0
true
> Z_AXIS
(0, 0, 1)
> ORIGIN
(0", 0", 0")
>
The format of the two transformations is identical. I know that text_group
exists because in the next few lines of code I convert it to a component and place it in the model. And THAT part works. It just won’t rotate first!
It’s probably something dumb that I’m not seeing, but I’m pretty sure it isn’t a typo, and the two lines with .transform!
in them appear identical in format.
But one works, and the other doesn’t, and at the moment I don’t understand why not.
In the meantime I’ll get on with working on other parts of the code, but I’d really like to understand what’s wrong with this bit. No errors are shown in the Ruby console.
Suggestions welcome!