OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Macros/Add-ons (http://forum.oberonplace.com/forumdisplay.php?f=21)
-   -   How to rotate an open curve (http://forum.oberonplace.com/showthread.php?t=24802)

mtracy 10-11-2017 12:21

How to rotate an open curve
Looking for vba to rotate an open curve in such a way that the end nodes are on a horizontal plane. Not align the nodes per say, but rotate the shape based on the position of the nodes on the Y axis.

mtracy 10-11-2017 13:36

Got it.

mtracy 10-11-2017 15:56

Ok, just for giggles here's what I got. Find the radius of any arc.

With the shape tool select the nodes that make up the Arc or curve segment, run the macro and it tells you what the radius is.

Sub FindRadius()
Dim n As Node, x1 As Double, y1 As Double, x2 As Double, y2 As Double, os As ShapeRange, x#, y#, w#, h#
ActiveDocument.Unit = cdrInch
Optimization = True
Set os = ActiveSelectionRange

If os.Count <> 1 Then MsgBox ("Select one shape and run macro again!")
ActiveShape.Curve.Nodes.First.GetPosition x1, y1
ActiveShape.Curve.Nodes.Last.GetPosition x2, y2
If x2 <> x1 Then k = -1 Else myangle = -90: GoTo here:
With os(1)
.RotationCenterX = x1
.RotationCenterY = y1
End With
myangle = Atn((y2 - y1) / (x2 - x1)) * 180 / 3.14159265358979
os(1).Rotate k * myangle

os.GetSize w, h
MsgBox Round((h / 2) + (w * w) / (h * 8), 3)
Optimization = False

End Sub

All times are GMT -5. The time now is 23:38.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com