.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entity.UpgradeOpen

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
2595 Views, 2 Replies

Entity.UpgradeOpen

i'm having issues with upgrading an entity so i can change its layer... here's what i have

{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction
{color}
{color:#333399}Try
{color}
{color:#333399}ent.UpgradeOpen()
ent.Layer = lay
ent.DowngradeOpen()
{color}
{color:#333399}Catch ex As Exception
{color}
{color:#333399}myUtility.Prompt(vbLf & "Unable to change layer: " & ex.Message)
{color}
{color:#333399}End Try
Trans.Commit()
{color}
{color:#333399}End Using myLock.Dispose(){color}

i tried it with a transaction, without a transaction, with a document lock, without a document lock, all i get is{color:#ff0000} {color}{color:#ff0000}eInvalidOpenState{color}, i'm not sure where i'm going wrong here... any help would be more than appreciated. if you need any other info let me know.

btw, i'm getting my entity from another transaction:
{color:#333399}Dim ent As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(obId, AutoCAD.DatabaseServices.OpenMode.ForRead), AutoCAD.DatabaseServices.Entity){color}
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

here's what i did that worked, not sure if it's the right way, but maybe it'll help someone like me

{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction
Try
Dim wEnt As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(ent.ObjectId, OpenMode.ForWrite), AutoCAD.DatabaseServices.Entity)
wEnt.Layer = lay
wEnt.DowngradeOpen()
Catch ex As Exception
myUtility.Prompt(vbLf & "Unable to change layer: " & ex.Message)
End Try
Trans.Commit()
End Using
myLock.Dispose()
End Sub{color}
Message 3 of 3
Anonymous
in reply to: Anonymous

The reason that's happening is because the original transaction
that you opened the entity in has already ended when you call
UpgradeOpen().

You shouldn't use a DBObject once the transaction you got it from
has ended, and while there'll usually be no error in cases where
you do that with an entity that's open for read, doing it remains
a no-no.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:6051997@discussion.autodesk.com...
i'm having issues with upgrading an entity so i can change its layer... here's what i have

{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction
{color}
{color:#333399}Try
{color}
{color:#333399}ent.UpgradeOpen()
ent.Layer = lay
ent.DowngradeOpen()
{color}
{color:#333399}Catch ex As Exception
{color}
{color:#333399}myUtility.Prompt(vbLf & "Unable to change layer: " & ex.Message)
{color}
{color:#333399}End Try
Trans.Commit()
{color}
{color:#333399}End Using myLock.Dispose(){color}

i tried it with a transaction, without a transaction, with a document lock, without a document lock, all i get is{color:#ff0000} {color}{color:#ff0000}eInvalidOpenState{color}, i'm not sure where i'm going wrong here... any help would be more than appreciated. if you need any other info let me know.

btw, i'm getting my entity from another transaction:
{color:#333399}Dim ent As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(obId, AutoCAD.DatabaseServices.OpenMode.ForRead), AutoCAD.DatabaseServices.Entity){color}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost