创建弧形多段线(polyline)

Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.Geometry
Imports ZwSoft.ZwCAD.EditorInput


Public Class ZwApps
    _
    Public Shared Sub CreateTable()
        Dim ZwDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZwDb As Database = ZwDoc.Database
        Using ZcTran As Transaction = ZwDb.TransactionManager.StartTransaction
            Dim ZcBLT As BlockTable = ZcTran.GetObject(ZwDb.BlockTableId, OpenMode.ForRead)
            Dim ZcBLTR As BlockTableRecord = ZcTran.GetObject(ZcBLT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)


            Dim pl As Polyline = New Polyline()
            pl.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)
            pl.AddVertexAt(1, New Point2d(10, 10), -2, 0, 0)
            pl.AddVertexAt(2, New Point2d(2, -5), 0, 0, 0)


            ZcBLTR.AppendEntity(pl)
            ZcTran.AddNewlyCreatedDBObject(pl, True)
            ZcTran.Commit()


        End Using
    End Sub

End Class


原型为:

public void AddVertexAt(Int32 index,Point2d pt,Double bulge,Double startWidth,Double endWidth);

bulge是弓高的两倍和弦长的比值,或者是弧所对应圆心角的四分之一的正切值。

另外需要一提的是,凸度为正时绘制的圆弧都是逆时针方向的,所以在绘图时一定要规划好,如果确实需要绘制顺时针方向的圆弧,只需将该值变为负数即可。

你可能感兴趣的:(ZWCAD,.NET,API开发)