乐筑天下

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

C3D调查数据-示例代码?

[复制链接]

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-24 08:22:55 | 显示全部楼层 |阅读模式
大家早上好,
我谷歌了又谷歌,但我在调查数据库中找不到任何使用调查数据的示例代码。特别是,我正在尝试从数据库中删除选定的地物,我还想知道如何切换选定测量地物的“特征线”属性。
有人想分享代码吗,或者您能给我发送一些示例代码的链接吗?我将不胜感激!
谢谢!

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

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

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2014-7-24 09:20:33 | 显示全部楼层
我认为调查数据是一种功能线,因此没有(或几乎没有)API。
回复

使用道具 举报

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-24 09:41:32 | 显示全部楼层
没错,它们本质上是要素线。我可以将选定的测量地物转换或键入要素线,但这无助于我操作测量数据库。
回复

使用道具 举报

14

主题

36

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
92
发表于 2014-7-24 11:12:01 | 显示全部楼层
我认为您正在数据库中查找地物的IsBreakline属性。您需要获取地物集合,然后获取单个地物来设置属性
我还没有找到这样的例子,但您可以做类似的事情:
http://adndevblog.typepad.com/infrastructure/2013/11/how-to-access-the-autocad-civil-3d-survey-database-in-net-application.html
这是一个很好的例子http://adndevblog.typepad.com/infrastructure/2013/08/accessing-survey-database-points-using-autocad-civil-3d-com-api.html
回复

使用道具 举报

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-24 14:38:55 | 显示全部楼层
好吧,以下是我尝试过的(通过使用我找到的示例和计件工作代码):
  1. Public Sub ChangesSurveyFigureToNonBreakline()
  2.             Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
  3.             Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
  4.             Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
  5.             Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
  6.             Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
  7.             Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
  8.             opt1.SetRejectMessage(vbCrLf & "error!")
  9.             opt1.AppendKeywordsToMessage = False
  10.             opt1.AddAllowedClass(GetType(SurveyFigure), True)
  11.             Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
  12.             If (Res1.Status = PromptStatus.OK) Then 'single item picked
  13.                 Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
  14.                     Try
  15.                         If oAcadApp Is Nothing Then
  16.                             oAcadApp = GetObject(, "AutoCAD.Application")
  17.                         End If
  18.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  19.                         ed.WriteMessage(ex.Message)
  20.                     End Try
  21.                     Try
  22.                         oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
  23.                         oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
  24.                         oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
  25.                         Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity = trans.GetObject(Res1.ObjectId, OpenMode.ForRead)
  26.                         Dim oFigure As IAeccSurveyFigure = TryCast(ent, IAeccSurveyFigure)
  27.                         oFigure.IsBreakline = False
  28.                         oFigure.Save()
  29.                         trans.Commit()
  30.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  31.                         ed.WriteMessage("Error : ", ex.Message & vbCrLf)
  32.                     End Try
  33.                 End Using
  34.             End If
  35.         End Sub

这不起作用,我在尝试设置IsBreakline属性时遇到了致命的异常错误。我肯定我没有正确处理互操作。有什么建议吗?谢谢大家的回复!
回复

使用道具 举报

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-24 16:07:52 | 显示全部楼层
此代码有效,尽管仅适用于硬编码的图形项目:
  1. Public Sub ChangesSurveyFigureToNonBreakline()
  2.             Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
  3.             Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
  4.             Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
  5.             Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
  6.             Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
  7.             Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
  8.             opt1.SetRejectMessage(vbCrLf & "error!")
  9.             opt1.AppendKeywordsToMessage = False
  10.             opt1.AddAllowedClass(GetType(SurveyFigure), True)
  11.             Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
  12.             If (Res1.Status = PromptStatus.OK) Then 'single item picked
  13.                 Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
  14.                     Try
  15.                         If oAcadApp Is Nothing Then
  16.                             oAcadApp = GetObject(, "AutoCAD.Application")
  17.                         End If
  18.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  19.                         ed.WriteMessage(ex.Message)
  20.                     End Try
  21.                     Try
  22.                         oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
  23.                         oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
  24.                         oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
  25.                         Dim oProjects As AeccSurveyProjects = CType(oAeccSurveyDB.Projects, AeccSurveyProjects)
  26.                         Dim z As AeccSurveyProject = oProjects.Item(0)
  27.                         Dim oSurveyFigure As AeccSurveyFigure = z.Figures.Item(1)
  28.                         oSurveyFigure.IsBreakline = False
  29.                         oSurveyFigure.Save()
  30.                         oSurveyFigure.Reload()
  31.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  32.                         ed.WriteMessage("Error : ", ex.Message & vbCrLf)
  33.                     End Try
  34.                 End Using
  35.             End If
  36.         End Sub

有没有办法确定所选实体的项目编号? 我可以搜索一个名称,但我对多个调查数字使用相同的名称(例如:EP,TBC)
我想将所选实体转换为调查数字并获取实体的ID,但我认为这与ITEM键没有任何关系。
回复

使用道具 举报

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-25 09:37:19 | 显示全部楼层
这段代码做了我想做的事情,尽管它遍历了所有的图,而不是只使用我选择的图:
  1. Public Sub ChangesSurveyFigureToNonBreakline()
  2.             Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
  3.             Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
  4.             Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
  5.             Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
  6.             Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
  7.             Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
  8.             opt1.SetRejectMessage(vbCrLf & "error!")
  9.             opt1.AppendKeywordsToMessage = False
  10.             opt1.AddAllowedClass(GetType(SurveyFigure), True)
  11.             Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
  12.             If (Res1.Status = PromptStatus.OK) Then
  13.                 Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
  14.                     Try
  15.                         If oAcadApp Is Nothing Then
  16.                             oAcadApp = GetObject(, "AutoCAD.Application")
  17.                         End If
  18.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  19.                         ed.WriteMessage(ex.Message)
  20.                     End Try
  21.                     Try
  22.                         oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
  23.                         oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
  24.                         oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
  25.                         Dim oEnt As Autodesk.AutoCAD.DatabaseServices.Entity = trans.GetObject(Res1.ObjectId, OpenMode.ForRead)
  26.                         Dim TmpFigure As SurveyFigure = TryCast(oEnt, SurveyFigure)
  27.                         Dim oSF As SurveyFigure = nothing
  28.                         Dim oCurrentProject As AeccSurveyProject = oAeccSurveyDB.CurrentProject
  29.                         For i As Integer = 0 To oCurrentProject.Figures.Count - 1
  30.                             Dim oSurveyFigure As AeccSurveyFigure = oCurrentProject.Figures.Item(i)
  31.                             Dim FigureId As ObjectId = New ObjectId(New IntPtr(oSurveyFigure.GetObjectId))
  32.                             oSF = TryCast(trans.GetObject(FigureId, OpenMode.ForRead), SurveyFigure)
  33.                             If oSF.Id = TmpFigure.Id Then
  34.                                 oSurveyFigure.IsBreakline = False
  35.                                 oSurveyFigure.Save()
  36.                             End If
  37.                         Next
  38.                     Catch ex As Autodesk.AutoCAD.Runtime.Exception
  39.                         ed.WriteMessage("Error : ", ex.Message & vbCrLf)
  40.                     End Try
  41.                 End Using
  42.             End If
  43.         End Sub

尽管如此,我仍然不知道如何从数据库中删除一个数字。我在。net SurveyFigure对象,但它似乎只是从模型空间而不是数据库中删除它?
回复

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2014-7-25 10:05:06 | 显示全部楼层
如果进行调试,是否可以读取TmpFigure的属性以查看是否存在数据库连接id或其他内容?
回复

使用道具 举报

6

主题

27

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
51
发表于 2014-7-25 11:46:59 | 显示全部楼层
不幸的是,我使用的是VB 2010 Express,没有启动选项来允许调试。
回复

使用道具 举报

14

主题

275

帖子

6

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
331
发表于 2014-7-25 12:43:02 | 显示全部楼层
是的
,我过去使用过 VB.NET Express,您可以调试。有关更多详细信息,请参阅此处:http://through-the-interface.typepad.com/through_the_interface/2006/07/debugging_using.html
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-2-5 05:00 , Processed in 0.357978 second(s), 72 queries .

© 2020-2025 乐筑天下

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