My macro to replace ellipses that were converted to curves back to ellipses

Create an ellipse (oval), rotate it 15deg, convert it to curves.

I created this macro to replace the shape with an ellipse but would like to add to it. I'd like to get the angle of rotation of the shape then after the shape is replaced have it rotate it to what it was.

Could probably be streamlined too but beyond my code hacking skills.

Sub ConvertCirclesBack()
Dim sr As ShapeRange, s As Shape
Dim x#, y#, w#, h#, dOffset#
ActiveDocument.BeginCommandGroup ("Convert")
Set sr = ActiveSelectionRange
If sr.Shapes.Count < 1 Then
MsgBox "Select at least one shape"
Exit Sub
End If
Optimization = True
ActiveDocument.Unit = cdrInch
If sr.Count = 0 Then Exit Sub
For Each s In sr
s.GetBoundingBox x, y, w, h
Set s = ActiveLayer.CreateEllipse2(x + w / 2, y + h / 2, w / 2, h / 2)
s.Flip cdrFlipVertical
Next s
sr.Delete
Optimization = False
ActiveWindow.Refresh
ActiveDocument.EndCommandGroup
End Sub

Parents
No Data
Reply
  • Create an ellipse (oval), rotate it 15deg, convert it to curves.

    If a Curve was created in the way you describe, then it will have four nodes.

    Some math could be used to use the coordinates of those nodes - or the coordinates of two of those nodes, and also of the center - to figure out the Radius1 and Radius2 values for the new Ellipse, and the angle to which you would need to rotate it.

    That's just off the top of my head. I haven't given much thought to whether there is any really clever way to do it. I guess one way to do less math would be to create a couple of two-node Curves based on the center and two of the nodes, and then get the lengths and angle from them. You wouldn't have to create actual Curve shapes in the document to do that.

    if you only had a few of these to do, it's pretty quick to draw a new Ellipse manually using the 3-Point Ellipse tool, and snapping to the nodes of the existing curve shape.

Children