C3D调查数据-示例代码?
大家早上好,我谷歌了又谷歌,但我在调查数据库中找不到任何使用调查数据的示例代码。特别是,我正在尝试从数据库中删除选定的地物,我还想知道如何切换选定测量地物的“特征线”属性。
有人想分享代码吗,或者您能给我发送一些示例代码的链接吗?我将不胜感激!
谢谢!
**** Hidden Message ***** 我认为调查数据是一种功能线,因此没有(或几乎没有)API。 没错,它们本质上是要素线。我可以将选定的测量地物转换或键入要素线,但这无助于我操作测量数据库。 我认为您正在数据库中查找地物的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 好吧,以下是我尝试过的(通过使用我找到的示例和计件工作代码):
Public Sub ChangesSurveyFigureToNonBreakline()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
opt1.SetRejectMessage(vbCrLf & "error!")
opt1.AppendKeywordsToMessage = False
opt1.AddAllowedClass(GetType(SurveyFigure), True)
Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
If (Res1.Status = PromptStatus.OK) Then 'single item picked
Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Try
If oAcadApp Is Nothing Then
oAcadApp = GetObject(, "AutoCAD.Application")
End If
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(ex.Message)
End Try
Try
oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity = trans.GetObject(Res1.ObjectId, OpenMode.ForRead)
Dim oFigure As IAeccSurveyFigure = TryCast(ent, IAeccSurveyFigure)
oFigure.IsBreakline = False
oFigure.Save()
trans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error : ", ex.Message & vbCrLf)
End Try
End Using
End If
End Sub
这不起作用,我在尝试设置IsBreakline属性时遇到了致命的异常错误。我肯定我没有正确处理互操作。有什么建议吗?谢谢大家的回复!
此代码有效,尽管仅适用于硬编码的图形项目:
Public Sub ChangesSurveyFigureToNonBreakline()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
opt1.SetRejectMessage(vbCrLf & "error!")
opt1.AppendKeywordsToMessage = False
opt1.AddAllowedClass(GetType(SurveyFigure), True)
Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
If (Res1.Status = PromptStatus.OK) Then 'single item picked
Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Try
If oAcadApp Is Nothing Then
oAcadApp = GetObject(, "AutoCAD.Application")
End If
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(ex.Message)
End Try
Try
oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
Dim oProjects As AeccSurveyProjects = CType(oAeccSurveyDB.Projects, AeccSurveyProjects)
Dim z As AeccSurveyProject = oProjects.Item(0)
Dim oSurveyFigure As AeccSurveyFigure = z.Figures.Item(1)
oSurveyFigure.IsBreakline = False
oSurveyFigure.Save()
oSurveyFigure.Reload()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error : ", ex.Message & vbCrLf)
End Try
End Using
End If
End Sub
有没有办法确定所选实体的项目编号? 我可以搜索一个名称,但我对多个调查数字使用相同的名称(例如:EP,TBC)
我想将所选实体转换为调查数字并获取实体的ID,但我认为这与ITEM键没有任何关系。 这段代码做了我想做的事情,尽管它遍历了所有的图,而不是只使用我选择的图:
Public Sub ChangesSurveyFigureToNonBreakline()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Nothing
Dim oAeccSurveyApp As Autodesk.AECC.Interop.UiSurvey.AeccSurveyApplication = Nothing
Dim oAeccSurveyDoc As Autodesk.AECC.Interop.UiSurvey.AeccSurveyDocument = Nothing
Dim oAeccSurveyDB As Autodesk.AECC.Interop.Survey.AeccSurveyDatabase = Nothing
Dim opt1 As New PromptEntityOptions(vbCrLf & "Select survey figure to change to non-breakline: ")
opt1.SetRejectMessage(vbCrLf & "error!")
opt1.AppendKeywordsToMessage = False
opt1.AddAllowedClass(GetType(SurveyFigure), True)
Dim Res1 As PromptEntityResult = ed.GetEntity(opt1)
If (Res1.Status = PromptStatus.OK) Then
Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Try
If oAcadApp Is Nothing Then
oAcadApp = GetObject(, "AutoCAD.Application")
End If
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(ex.Message)
End Try
Try
oAeccSurveyApp = oAcadApp.GetInterfaceObject("AeccXUiSurvey.AeccSurveyApplication.10.3")
oAeccSurveyDoc = oAeccSurveyApp.ActiveDocument
oAeccSurveyDB = oAeccSurveyApp.ActiveDocument.Database
Dim oEnt As Autodesk.AutoCAD.DatabaseServices.Entity = trans.GetObject(Res1.ObjectId, OpenMode.ForRead)
Dim TmpFigure As SurveyFigure = TryCast(oEnt, SurveyFigure)
Dim oSF As SurveyFigure = nothing
Dim oCurrentProject As AeccSurveyProject = oAeccSurveyDB.CurrentProject
For i As Integer = 0 To oCurrentProject.Figures.Count - 1
Dim oSurveyFigure As AeccSurveyFigure = oCurrentProject.Figures.Item(i)
Dim FigureId As ObjectId = New ObjectId(New IntPtr(oSurveyFigure.GetObjectId))
oSF = TryCast(trans.GetObject(FigureId, OpenMode.ForRead), SurveyFigure)
If oSF.Id = TmpFigure.Id Then
oSurveyFigure.IsBreakline = False
oSurveyFigure.Save()
End If
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error : ", ex.Message & vbCrLf)
End Try
End Using
End If
End Sub
尽管如此,我仍然不知道如何从数据库中删除一个数字。我在。net SurveyFigure对象,但它似乎只是从模型空间而不是数据库中删除它? 如果进行调试,是否可以读取TmpFigure的属性以查看是否存在数据库连接id或其他内容? 不幸的是,我使用的是VB 2010 Express,没有启动选项来允许调试。 是的
,我过去使用过 VB.NET Express,您可以调试。有关更多详细信息,请参阅此处:http://through-the-interface.typepad.com/through_the_interface/2006/07/debugging_using.html
页:
[1]
2