- Friend Function CreateArcRectanglePolyline(ByVal acTrans As Transaction, ByVal acBlkTblRec As BlockTableRecord, ByVal sLayerName As String, ByVal rad As Double, _
- ByVal ptLowLeft As Point2d, ByVal ptLowRight As Point2d, ByVal ptTopRight As Point2d, ByVal ptTopLeft As Point2d) As Polyline
- '每部分单独来创建倒圆角矩形
- 'Dim acArc1 As Arc = New Arc(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y + rad, 0), rad, Math.PI, 1.5 * Math.PI) '左下角倒圆角
- 'Dim acLine1 As Line = New Line(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y, 0), New Point3d(ptLowRight.X - rad, ptLowRight.Y, 0))
- 'Dim acArc2 As Arc = New Arc(New Point3d(ptLowRight.X - rad, ptLowRight.Y + rad, 0), rad, 1.5 * Math.PI, 2 * Math.PI) '右下角倒圆角
- 'Dim acLine2 As Line = New Line(New Point3d(ptLowRight.X, ptLowRight.Y + rad, 0), New Point3d(ptTopRight.X, ptTopRight.Y - rad, 0))
- 'Dim acArc3 As Arc = New Arc(New Point3d(ptTopRight.X - rad, ptTopRight.Y - rad, 0), rad, 0, 0.5 * Math.PI) '右上角倒圆角
- 'Dim acLine3 As Line = New Line(New Point3d(ptTopRight.X - rad, ptTopRight.Y, 0), New Point3d(ptTopLeft.X + rad, ptTopLeft.Y, 0))
- 'Dim acArc4 As Arc = New Arc(New Point3d(ptTopLeft.X + rad, ptTopLeft.Y - rad, 0), rad, 0.5 * Math.PI, Math.PI) '左上角倒圆角
- 'Dim acLine4 As Line = New Line(New Point3d(ptTopLeft.X, ptTopRight.Y - rad, 0), New Point3d(ptLowLeft.X, ptLowLeft.Y + rad, 0))
- ''将新对象添加到块表记录和事务
- 'acBlkTblRec.AppendEntity(acArc1)
- 'acTrans.AddNewlyCreatedDBObject(acArc1, True)
- 'acBlkTblRec.AppendEntity(acLine1)
- 'acTrans.AddNewlyCreatedDBObject(acLine1, True)
- 'acBlkTblRec.AppendEntity(acArc2)
- 'acTrans.AddNewlyCreatedDBObject(acArc2, True)
- 'acBlkTblRec.AppendEntity(acLine2)
- 'acTrans.AddNewlyCreatedDBObject(acLine2, True)
- 'acBlkTblRec.AppendEntity(acArc3)
- 'acTrans.AddNewlyCreatedDBObject(acArc3, True)
- 'acBlkTblRec.AppendEntity(acLine3)
- 'acTrans.AddNewlyCreatedDBObject(acLine3, True)
- 'acBlkTblRec.AppendEntity(acArc4)
- 'acTrans.AddNewlyCreatedDBObject(acArc4, True)
- 'acBlkTblRec.AppendEntity(acLine4)
- 'acTrans.AddNewlyCreatedDBObject(acLine4, True)
- Dim acPoly As Polyline = New Polyline()
- acPoly.Layer = sLayerName
- acPoly.AddVertexAt(0, New Point2d(ptLowLeft.X, ptLowLeft.Y + rad), Math.Tan(0.5 * Math.PI / 4), 0, 0) '左下角倒圆角起点
- acPoly.AddVertexAt(1, New Point2d(ptLowLeft.X + rad, ptLowLeft.Y), 0, 0, 0) '左下角倒圆角终点
- acPoly.AddVertexAt(2, New Point2d(ptLowRight.X - rad, ptLowRight.Y), Math.Tan(0.5 * Math.PI / 4), 0, 0) '右下角倒圆角起点
- acPoly.AddVertexAt(3, New Point2d(ptLowRight.X, ptLowRight.Y + rad), 0, 0, 0) '右下角倒圆角终点
- acPoly.AddVertexAt(4, New Point2d(ptTopRight.X, ptTopRight.Y - rad), Math.Tan(0.5 * Math.PI / 4), 0, 0) '右上角倒圆角起点
- acPoly.AddVertexAt(5, New Point2d(ptTopRight.X - rad, ptTopRight.Y), 0, 0, 0) '右上角倒圆角终点
- acPoly.AddVertexAt(6, New Point2d(ptTopLeft.X + rad, ptTopLeft.Y), Math.Tan(0.5 * Math.PI / 4), 0, 0) '左上角倒圆角起点
- acPoly.AddVertexAt(7, New Point2d(ptTopLeft.X, ptTopLeft.Y - rad), 0, 0, 0) '左上角倒圆角终点
- acPoly.Closed = True '闭合多段线
- '将新对象添加到块表记录和事务
- acBlkTblRec.AppendEntity(acPoly)
- acTrans.AddNewlyCreatedDBObject(acPoly, True)
- Return acPoly
- End Function