vb.net cad 重新生成填充边界

这篇博客介绍了如何使用VB.NET来重新生成CAD填充的边界。通过获取Hatch对象的Loop,并针对不同类型的边界(如Polyline、CircularArc2d),处理其点和凸度信息,创建新的多段线。示例代码展示了如何处理Polyline和CircularArc2d,将点和凸度数据转换为多段线,并将其添加到模型空间。
摘要由CSDN通过智能技术生成
    Public Sub GetHatchBorder()
        Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Dim lock As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
        '     Dim db As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        ed.WriteMessage("选择需要重新生成边界的填充" & vbLf)
        Dim acTypValAr(1) As TypedValue
        acTypValAr.SetValue(New TypedValue(DxfCode.Start, "Hatch"), 0)
        acTypValAr.SetValue(New TypedValue(DxfCode.Visibility, 0), 1)
        Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)
        Dim entRes As PromptSelectionResult
        Dim errorcn As Integer = 0
        Dim errorids As New ObjectIdCollection
        Dim errorid As New ObjectId
        Dim mycllids As ObjectIdCollection
        entRes = ed.GetSelection(acSelFtr)
        If entRes.Status <> PromptStatus.OK Then
            ed.WriteMessage("选择对象失败,退出")
            Return
        Else
            mycllids = New ObjectIdCollection(entRes.Value.GetObjectIds)
            Dim db As Database = HostApplicationServices.WorkingDatabase
            Using trans As Transaction = db.TransactionManager.StartTransaction()
                For Each objid In mycllids
                    If Not IsDBNull(objid) Then
                        Try
                            Dim ent As Hatch = TryCast(trans.GetObject(objid, OpenMode.ForWrite), Hatch)
                            errorid = MyDrawBorder(ent, 1)
                            If Not IsDBNull(errorid) And errorids.Contains(errorid) = False Then
                                errorids.Add(errorid)
                           
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值