I need to create Elliptical Arc/Ellipse using VBA, can anyone help please
Thanks, i need to draw an elliptical arc, given Start angle, End angle, center point and Upper Right X & Y, Lower Left X & Y points.
The help file is a terrible thing to waste: Sub Example_AddEllipse() ' This example creates an ellipse in model space. Dim ellObj As AcadEllipse Dim majAxis(0 To 2) As Double Dim center(0 To 2) As Double Dim radRatio As Double ' Create an ellipse in model space center(0) = 5#: center(1) = 5#: center(2) = 0# majAxis(0) = 10: majAxis(1) = 20#: majAxis(2) = 0# radRatio = 0.3 Set ellObj = ThisDrawing.ModelSpace.AddEllipse(center, majAxis, radRatio) ZoomAll End Sub *IF* you have other data such as start/end angles, you'll need to transform/translate that info using basic geometry into the object's requirements.
Thanks a lot Mike. I did use the start angle and end angle and get the elliptical arc... after loosing my sleep over it for 2 days... and the Help is a waste of time. revision of your program: Sub Example_AddEllipse() ' This example creates an ellipse in model space. Dim ellObj As AcadEllipse Dim majAxis(0 To 2) As Double Dim center(0 To 2) As Double Dim radRatio As Double Dim StartAng as Double Dim EndAng as Double ' Create an ellipse in model space center(0) = 5#: center(1) = 5#: center(2) = 0# 'I think we need to modify this if the major axis is not X axis majAxis(0) = 10: majAxis(1) = 20#: majAxis(2) = 0# radRatio = 0.3 Set ellObj = ThisDrawing.ModelSpace.AddEllipse(center, majAxis, radRatio) 'My data required the following as the EndAng was the Included Angle, not necessarily applicable for all data If (StartAng + EndAng) > 360 Then EndAng = (StartAng + EndAng) - 360 Else EndAng = (StartAng + EndAng) Endif 'Convert degrees to radians ellObj.Startangle = StartAng * (3.14 / 180) ellObj.EndAngle= EndAng * (3.14 / 180) ellObj.Update ZoomAll End Sub
Glad you got it! But, you missed the point - it wasn't my program, it was directly out of the help file