这段代码做了我想做的事情,尽管它遍历了所有的图,而不是只使用我选择的图:
- 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对象,但它似乎只是从模型空间而不是数据库中删除它? |