乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 118|回复: 8

如何将直线圆弧连接起来

[复制链接]

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-11 18:51:00 | 显示全部楼层 |阅读模式
如何将直线圆弧连接起来形成多段线,类似于Join命令。[em0]
其实我是想创建一个带倒圆角的矩形。我现在是单独创了4个圆弧和4根直线,之后想把这4个圆弧和4根直线合并。
或者有没有更简单的办法来创建带倒圆角的矩形?
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2016-10-11 19:35:00 | 显示全部楼层
参考我的曲线转换类的ge3dex部分 有个topolyline 是把ge复合曲线转成pl的 和你的要求差不多
回复

使用道具 举报

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-11 21:20:00 | 显示全部楼层

其实我是想创建一个带倒圆角的矩形。我现在是单独创了4个圆弧和4根直线,之后想把这4个圆弧和4根直线合并。
或者有没有更简单的办法来创建带倒圆角的矩形?
回复

使用道具 举报

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-11 21:22:00 | 显示全部楼层
  1. Friend Function CreateArcRectanglePolyline(ByVal acTrans As Transaction, ByVal acBlkTblRec As BlockTableRecord, ByVal sLayerName As String, ByVal rad As Double, _
  2.                                                ByVal ptLowLeft As Point2d, ByVal ptLowRight As Point2d, ByVal ptTopRight As Point2d, ByVal ptTopLeft As Point2d) As Polyline
  3.         Dim acArc1 As Arc = New Arc(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y + rad, 0), rad, Math.PI, 1.5 * Math.PI)  '左下角倒圆角
  4.         Dim acLine1 As Line = New Line(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y, 0), New Point3d(ptLowRight.X - rad, ptLowRight.Y, 0))
  5.         Dim acArc2 As Arc = New Arc(New Point3d(ptLowRight.X - rad, ptLowRight.Y + rad, 0), rad, 1.5 * Math.PI, 2 * Math.PI)  '右下角倒圆角
  6.         Dim acLine2 As Line = New Line(New Point3d(ptLowRight.X, ptLowRight.Y + rad, 0), New Point3d(ptTopRight.X, ptTopRight.Y - rad, 0))
  7.         Dim acArc3 As Arc = New Arc(New Point3d(ptTopRight.X - rad, ptTopRight.Y - rad, 0), rad, 0, 0.5 * Math.PI)  '右上角倒圆角
  8.         Dim acLine3 As Line = New Line(New Point3d(ptTopRight.X - rad, ptTopRight.Y, 0), New Point3d(ptTopLeft.X + rad, ptTopLeft.Y, 0))
  9.         Dim acArc4 As Arc = New Arc(New Point3d(ptTopLeft.X + rad, ptTopLeft.Y - rad, 0), rad, 0.5 * Math.PI, Math.PI)  '左上角倒圆角
  10.         Dim acLine4 As Line = New Line(New Point3d(ptTopLeft.X, ptTopRight.Y - rad, 0), New Point3d(ptLowLeft.X, ptLowLeft.Y + rad, 0))
  11.         Dim acPoly As Polyline = New Polyline()
  12.         '将新对象添加到块表记录和事务
  13.         acBlkTblRec.AppendEntity(acArc1)
  14.         acTrans.AddNewlyCreatedDBObject(acArc1, True)
  15.         acBlkTblRec.AppendEntity(acLine1)
  16.         acTrans.AddNewlyCreatedDBObject(acLine1, True)
  17.         acBlkTblRec.AppendEntity(acArc2)
  18.         acTrans.AddNewlyCreatedDBObject(acArc2, True)
  19.         acBlkTblRec.AppendEntity(acLine2)
  20.         acTrans.AddNewlyCreatedDBObject(acLine2, True)
  21.         acBlkTblRec.AppendEntity(acArc3)
  22.         acTrans.AddNewlyCreatedDBObject(acArc3, True)
  23.         acBlkTblRec.AppendEntity(acLine3)
  24.         acTrans.AddNewlyCreatedDBObject(acLine3, True)
  25.         acBlkTblRec.AppendEntity(acArc4)
  26.         acTrans.AddNewlyCreatedDBObject(acArc4, True)
  27.         acBlkTblRec.AppendEntity(acLine4)
  28.         acTrans.AddNewlyCreatedDBObject(acLine4, True)
  29.       
  30.         Return acPoly
  31.     End Function
回复

使用道具 举报

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-11 21:27:00 | 显示全部楼层

请问哪里可以找到ge3dex这个类,我在贴子中没搜到哦。
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2016-10-11 21:45:00 | 显示全部楼层
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=77565&mobile=2
回复

使用道具 举报

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-12 10:07:00 | 显示全部楼层

  1.     Friend Function CreateArcRectanglePolyline(ByVal acTrans As Transaction, ByVal acBlkTblRec As BlockTableRecord, ByVal sLayerName As String, ByVal rad As Double, _
  2.                                                ByVal ptLowLeft As Point2d, ByVal ptLowRight As Point2d, ByVal ptTopRight As Point2d, ByVal ptTopLeft As Point2d) As Polyline
  3.         '每部分单独来创建倒圆角矩形
  4.         'Dim acArc1 As Arc = New Arc(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y + rad, 0), rad, Math.PI, 1.5 * Math.PI)  '左下角倒圆角
  5.         'Dim acLine1 As Line = New Line(New Point3d(ptLowLeft.X + rad, ptLowLeft.Y, 0), New Point3d(ptLowRight.X - rad, ptLowRight.Y, 0))
  6.         'Dim acArc2 As Arc = New Arc(New Point3d(ptLowRight.X - rad, ptLowRight.Y + rad, 0), rad, 1.5 * Math.PI, 2 * Math.PI)  '右下角倒圆角
  7.         'Dim acLine2 As Line = New Line(New Point3d(ptLowRight.X, ptLowRight.Y + rad, 0), New Point3d(ptTopRight.X, ptTopRight.Y - rad, 0))
  8.         'Dim acArc3 As Arc = New Arc(New Point3d(ptTopRight.X - rad, ptTopRight.Y - rad, 0), rad, 0, 0.5 * Math.PI)  '右上角倒圆角
  9.         'Dim acLine3 As Line = New Line(New Point3d(ptTopRight.X - rad, ptTopRight.Y, 0), New Point3d(ptTopLeft.X + rad, ptTopLeft.Y, 0))
  10.         'Dim acArc4 As Arc = New Arc(New Point3d(ptTopLeft.X + rad, ptTopLeft.Y - rad, 0), rad, 0.5 * Math.PI, Math.PI)  '左上角倒圆角
  11.         'Dim acLine4 As Line = New Line(New Point3d(ptTopLeft.X, ptTopRight.Y - rad, 0), New Point3d(ptLowLeft.X, ptLowLeft.Y + rad, 0))
  12.         ''将新对象添加到块表记录和事务
  13.         'acBlkTblRec.AppendEntity(acArc1)
  14.         'acTrans.AddNewlyCreatedDBObject(acArc1, True)
  15.         'acBlkTblRec.AppendEntity(acLine1)
  16.         'acTrans.AddNewlyCreatedDBObject(acLine1, True)
  17.         'acBlkTblRec.AppendEntity(acArc2)
  18.         'acTrans.AddNewlyCreatedDBObject(acArc2, True)
  19.         'acBlkTblRec.AppendEntity(acLine2)
  20.         'acTrans.AddNewlyCreatedDBObject(acLine2, True)
  21.         'acBlkTblRec.AppendEntity(acArc3)
  22.         'acTrans.AddNewlyCreatedDBObject(acArc3, True)
  23.         'acBlkTblRec.AppendEntity(acLine3)
  24.         'acTrans.AddNewlyCreatedDBObject(acLine3, True)
  25.         'acBlkTblRec.AppendEntity(acArc4)
  26.         'acTrans.AddNewlyCreatedDBObject(acArc4, True)
  27.         'acBlkTblRec.AppendEntity(acLine4)
  28.         'acTrans.AddNewlyCreatedDBObject(acLine4, True)
  29.         Dim acPoly As Polyline = New Polyline()
  30.         acPoly.Layer = sLayerName
  31.         acPoly.AddVertexAt(0, New Point2d(ptLowLeft.X, ptLowLeft.Y + rad), Math.Tan(0.5 * Math.PI / 4), 0, 0)  '左下角倒圆角起点
  32.         acPoly.AddVertexAt(1, New Point2d(ptLowLeft.X + rad, ptLowLeft.Y), 0, 0, 0)  '左下角倒圆角终点
  33.         acPoly.AddVertexAt(2, New Point2d(ptLowRight.X - rad, ptLowRight.Y), Math.Tan(0.5 * Math.PI / 4), 0, 0)  '右下角倒圆角起点
  34.         acPoly.AddVertexAt(3, New Point2d(ptLowRight.X, ptLowRight.Y + rad), 0, 0, 0)  '右下角倒圆角终点
  35.         acPoly.AddVertexAt(4, New Point2d(ptTopRight.X, ptTopRight.Y - rad), Math.Tan(0.5 * Math.PI / 4), 0, 0)  '右上角倒圆角起点
  36.         acPoly.AddVertexAt(5, New Point2d(ptTopRight.X - rad, ptTopRight.Y), 0, 0, 0)  '右上角倒圆角终点
  37.         acPoly.AddVertexAt(6, New Point2d(ptTopLeft.X + rad, ptTopLeft.Y), Math.Tan(0.5 * Math.PI / 4), 0, 0)  '左上角倒圆角起点
  38.         acPoly.AddVertexAt(7, New Point2d(ptTopLeft.X, ptTopLeft.Y - rad), 0, 0, 0)  '左上角倒圆角终点
  39.         acPoly.Closed = True  '闭合多段线
  40.         '将新对象添加到块表记录和事务
  41.         acBlkTblRec.AppendEntity(acPoly)
  42.         acTrans.AddNewlyCreatedDBObject(acPoly, True)
  43.         Return acPoly
  44.     End Function
回复

使用道具 举报

2

主题

10

帖子

1

银币

初来乍到

Rank: 1

铜币
18
发表于 2016-10-12 10:09:00 | 显示全部楼层
http://379910987.blog.163.com/blog/static/33523797201011184552167/
回复

使用道具 举报

0

主题

4

帖子

1

银币

初来乍到

Rank: 1

铜币
4
发表于 2017-7-29 15:41:00 | 显示全部楼层

我的土办法,还挺管用的
  Public Sub 转为多段线()
        Dim dm As DocumentCollection = Application.DocumentManager
        Dim ed As Editor = dm.MdiActiveDocument.Editor
        '获取当前数据库作为目标数据库
        Dim Db As Database = dm.MdiActiveDocument.Database
        Dim 起始图形 As Entity
        Dim pl As Polyline
        '拾取对象----------------------------------------------------------
        Dim optEnt As New PromptEntityOptions(vbCrLf & "请选择对象")
        Dim resEnt As PromptEntityResult = ed.GetEntity(optEnt)
        If resEnt.Status = PromptStatus.OK Then
            Using trans As Transaction = Db.TransactionManager.StartTransaction()
                起始图形 = trans.GetObject(resEnt.ObjectId, OpenMode.ForWrite)
                pl = Polyline_Select.转换为多段线(起始图形, False)
                起始图形.Erase()
                Db.AddToCurrentSpace(pl)
                Dim resSel As PromptSelectionResult = ed.SelectAll
                ' 得到选择集对象.
                Dim sSet As SelectionSet = resSel.Value
                ' 得到选择集中所有对象的ObjectId集合.
                Dim ids As ObjectId() = sSet.GetObjectIds()
                Dim rb As ResultBuffer = New ResultBuffer
                rb.Add(New TypedValue(ResBufCode.String, "_PEDIT"))
                rb.Add(New TypedValue(ResBufCode.ObjectId, pl.ObjectId))
                rb.Add(New TypedValue(ResBufCode.String, "_J"))
                rb.Add(New TypedValue(ResBufCode.PickSet, sSet))
                ed.AcedCmd(rb)
                dm.MdiActiveDocument.SendCommand("  ")
                trans.Commit()
            End Using
        End If
    End Sub
Public Shared Function 转换为多段线(ent As Entity, ByRef isOK As Boolean) As Polyline
        Dim pl As Polyline = New Polyline
        Dim l As Line
        Dim ac As Arc
        Dim pol As Polyline = New Polyline
        isOK = False
        Try
            If TypeOf ent Is Line Then
                l = ent
                pl.AddVertexAt(0, New Point2d(l.StartPoint.X, l.StartPoint.Y), 0, 0, 0)
                pl.AddVertexAt(1, New Point2d(l.EndPoint.X, l.EndPoint.Y), 0, 0, 0)
                isOK = True
            ElseIf TypeOf ent Is Arc Then
                ac = ent
                Dim 角度差 As Double = ac.EndAngle - ac.StartAngle
                If 角度差 < 0.0 Then 角度差 += Math.PI * 2
                Dim tD As Double = Math.Tan(角度差 / 4)
                pl.AddVertexAt(0, New Point2d(ac.StartPoint.X, ac.StartPoint.Y), tD, 0, 0)
                pl.AddVertexAt(1, New Point2d(ac.EndPoint.X, ac.EndPoint.Y), tD, 0, 0)
                isOK = True
            ElseIf TypeOf ent Is Polyline Then
                pol = ent
                pl = pol.Clone
                isOK = True
            End If
        Catch
            MsgBox("转换失败")
        End Try
        Return pl
    End Function
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2024-11-22 05:45 , Processed in 0.184271 second(s), 70 queries .

© 2020-2024 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表