乐筑天下

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

TraceBoundaryPromptStatus.Cancel后的问题

[复制链接]

10

主题

45

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2018-7-23 10:51:49 | 显示全部楼层 |阅读模式
嗨,亲爱的所有人。
我有一个与trace边界函数的麻烦。
我使用代码让用户输入点通过trace边界函数获取边界。但我总是通过这个函数在用户输入ESC获取点后一无所获。cad说“在屏幕上找不到任何对象”
见下面的代码
  1. Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
  2.         Dim acCurDb As Autodesk.AutoCAD.DatabaseServices.Database = acDoc.Database
  3.         Dim ed As Editor = acDoc.Editor
  4.         Dim cucs As Matrix3d = ed.CurrentUserCoordinateSystem
  5.         ed.CurrentUserCoordinateSystem = Matrix3d.Identity
  6.         Dim rtpts As New List(Of Point3d)
  7.         Try
  8.             Do
  9.                 ' System.Windows.Forms.Application.DoEvents()
  10.                 Dim Mpso As New PromptPointOptions(vbCr & "Insert Points")
  11.                 'Dim Mpso As New PromptPointOptions(vbCr & "编号插入点")
  12.                 Dim psr As PromptPointResult = ed.GetPoint(Mpso)
  13.                 Dim selectpt As Point3d = Point3d.Origin
  14.                 If psr.Status = PromptStatus.OK Then
  15.                     selectpt = psr.Value
  16.                     rtpts.Add(selectpt)
  17.                 Else
  18.                     Exit Do
  19.                 End If
  20.                 '' Start a transaction
  21.                 'Using dblock As Autodesk.AutoCAD.ApplicationServices.DocumentLock = acDoc.LockDocument
  22.                 '    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
  23.                 '        '' Open the Block table for read
  24.                 '        Dim acBlkTbl As BlockTable
  25.                 '        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
  26.                 '                     OpenMode.ForRead)
  27.                 '        '' Open the Block table record Model space for write
  28.                 '        Dim acBlkTblRec As BlockTableRecord
  29.                 '        acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
  30.                 '                        OpenMode.ForWrite)
  31.                 '        '' Create a single-line text object
  32.                 '        Stone.Layer.EnsureLayer("Stone_Points", 3)
  33.                 '        Using acPoint As DBPoint = New DBPoint()
  34.                 '            acPoint.Position = selectpt
  35.                 '            acPoint.Layer = "Stone_Points"
  36.                 '            acBlkTblRec.AppendEntity(acPoint)
  37.                 '            acTrans.AddNewlyCreatedDBObject(acPoint, True)
  38.                 '        End Using
  39.                 '        '' Save the changes and dispose of the transaction
  40.                 '        acTrans.Commit()
  41.                 '    End Using
  42.                 'End Using
  43.             Loop
  44.             Dim dbs As DBObjectCollection = ed.TraceBoundary(rtpts.First, True)
  45.             MsgBox(dbs.Count.ToString)
  46.         Catch ex As Exception
  47.             ed.CurrentUserCoordinateSystem = cucs
  48.    
  49.         Finally
  50.         End Try
  51.         ed.CurrentUserCoordinateSystem = cucs

你总是会得到0 count dbs。但如果我将TraceBoundary函数替换为循环。它工作得很好
见下面的代码
  1. dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
  2.         Dim acCurDb As Autodesk.AutoCAD.DatabaseServices.Database = acDoc.Database
  3.         Dim ed As Editor = acDoc.Editor
  4.         Dim cucs As Matrix3d = ed.CurrentUserCoordinateSystem
  5.         ed.CurrentUserCoordinateSystem = Matrix3d.Identity
  6.         Dim rtpts As New List(Of Point3d)
  7.         Try
  8.             Do
  9.                 ' System.Windows.Forms.Application.DoEvents()
  10.                 Dim Mpso As New PromptPointOptions(vbCr & "Insert Points")
  11.                 'Dim Mpso As New PromptPointOptions(vbCr & "编号插入点")
  12.                 Dim psr As PromptPointResult = ed.GetPoint(Mpso)
  13.                 Dim selectpt As Point3d = Point3d.Origin
  14.                 If psr.Status = PromptStatus.OK Then
  15.                     selectpt = psr.Value
  16.                     Dim dbs As DBObjectCollection = ed.TraceBoundary(selectpt, True)
  17.                     MsgBox(dbs.Count.ToString)
  18.                     rtpts.Add(selectpt)
  19.                 Else
  20.                     Exit Do
  21.                 End If
  22.                 '' Start a transaction
  23.                 'Using dblock As Autodesk.AutoCAD.ApplicationServices.DocumentLock = acDoc.LockDocument
  24.                 '    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
  25.                 '        '' Open the Block table for read
  26.                 '        Dim acBlkTbl As BlockTable
  27.                 '        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
  28.                 '                     OpenMode.ForRead)
  29.                 '        '' Open the Block table record Model space for write
  30.                 '        Dim acBlkTblRec As BlockTableRecord
  31.                 '        acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
  32.                 '                        OpenMode.ForWrite)
  33.                 '        '' Create a single-line text object
  34.                 '        Stone.Layer.EnsureLayer("Stone_Points", 3)
  35.                 '        Using acPoint As DBPoint = New DBPoint()
  36.                 '            acPoint.Position = selectpt
  37.                 '            acPoint.Layer = "Stone_Points"
  38.                 '            acBlkTblRec.AppendEntity(acPoint)
  39.                 '            acTrans.AddNewlyCreatedDBObject(acPoint, True)
  40.                 '        End Using
  41.                 '        '' Save the changes and dispose of the transaction
  42.                 '        acTrans.Commit()
  43.                 '    End Using
  44.                 'End Using
  45.             Loop
  46.         Catch ex As Exception
  47.             ed.CurrentUserCoordinateSystem = cucs
  48.         Finally
  49.         End Try
  50.         ed.CurrentUserCoordinateSystem = cucs

那真的让我很困惑。怎么有人能给你一些非常suggestion.Thank。

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

10

主题

45

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2018-7-23 14:42:14 | 显示全部楼层
就像测试编辑你的第一个示例一样,通过拉出循环Dim selectpt As Point3d = Point3d.Origin。
then changeDim dbs As DBObjectCollection = ed.TraceBoundary(rtpts.首先,真实)。
toDim dbs As DBObjectCollection = ed.TraceBoundary(selectpt, True)。

回复

使用道具 举报

10

主题

45

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2018-7-23 20:37:34 | 显示全部楼层

是的,如果您选择一个点,而不是按ESC键退出,您将获得正确的边界。
但是如果您选择了多个点并按esc、psr退出do。Status = PromptStatus。取消,你将一无所获-!
这几天我真的很困惑
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-2-4 10:41 , Processed in 0.471226 second(s), 69 queries .

© 2020-2025 乐筑天下

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