ObjectId.GetObject(OpenMode.ForWrite) error
Hello everyone.
There is an error that occurs only in bricscad, so I ask a question
I am getting an error in the MoveCircle2 function below.
Is there a solution?
Imports Bricscad.ApplicationServices
Imports Bricscad.Runtime
Imports Bricscad.EditorInput
Imports Teigha.Runtime
Imports Teigha.DatabaseServices
Imports Teigha.Geometry
Public Class Class1
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
<CommandMethod("MOVE-TEST")> Public Sub MOVETEST() Dim acCirc As Circle acCirc = DrawCircle2(0, 0, 0.5) MoveCircle2(50, 50, acCirc) End Sub Private Function DrawCircle2(x As Double, y As Double, r As Double) As Circle Dim acCircD As Circle Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) Dim acBlkTblRec As BlockTableRecord = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) acCircD = New Circle acCircD.SetDatabaseDefaults() acCircD.Center = New Point3d(x, y, 0) acCircD.Radius = r acBlkTblRec.AppendEntity(acCircD) acTrans.AddNewlyCreatedDBObject(acCircD, True) Application.UpdateScreen() acTrans.Commit() End Using Return acCircD End Function Private Sub MoveCircle2(x As Double, y As Double, acCircM As Circle) Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim moveAcCirc As Circle moveAcCirc = acCircM.ObjectId.GetObject(OpenMode.ForWrite) '' //////////////// Error BricsCAD V20~ moveAcCirc.Center = New Point3d(x, y, 0) moveAcCirc.Radius = 0.25 Application.UpdateScreen() acTrans.Commit() End Using End Sub
End Class
0
Comments
-
try
{
// MOVETEST
}
catch (System.Exception e)
{
Bricscad.ApplicationServices.Application.ShowAlertDialog(e);
}
It will give you some ideia of what is happening.
And it's a good ideia using try/catch when interacting with elements of the drawing.
https://docs.microsoft.com/pt-br/dotnet/csharp/language-reference/keywords/try-catch0