GIS/CAD

Arc to Polyline

프란5 2019. 9. 4. 18:08
반응형

Function arc2line(myArc As AcadArc) As AcadEntity

    Dim retobj As AcadEntity
    Dim delta As Double
    Dim numOfSegments As Integer
    Dim points() As Double
    
    Dim tol As Double
    
    tol = getDefaultTolerance
    
    delta = myArc.EndAngle - myArc.StartAngle
    If delta < 0 Then delta = delta + (2 * PI)
    
    numOfSegments = CInt(myArc.ArcLength / tol)
    ReDim points(0 To 2 * numOfSegments + 1)
    ang = 1 / (myArc.Radius / tol)
    points(0) = myArc.startPoint(0)
    points(1) = myArc.startPoint(1)
    adir = ang
    For x = 2 To UBound(points) - 2 Step 2
        mypolarpoint = ThisDrawing.Utility.PolarPoint(myArc.Center, myArc.StartAngle + adir, myArc.Radius)
        adir = adir + ang
        points(x) = mypolarpoint(0)
        points(x + 1) = mypolarpoint(1)
    Next x
    points(UBound(points) - 1) = myArc.endPoint(0)
    points(UBound(points) - 0) = myArc.endPoint(1)
    Set retobj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    
    Set arc2line = retobj

End Function

반응형