Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

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.Center = New Point3d(x, y, 0)
        acCircD.Radius = r
        acTrans.AddNewlyCreatedDBObject(acCircD, True)
    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 2020
        moveAcCirc.Center = New Point3d(x, y, 0)
        moveAcCirc.Radius = 0.25
    End Using
End Sub

End Class

Sign In or Register to comment.
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam