<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Entity.UpgradeOpen in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362206#M73048</link>
    <description>i'm having issues with upgrading an entity so i can change its layer... here's what i have&lt;BR /&gt;
&lt;BR /&gt;
{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()&lt;BR /&gt;
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction&lt;BR /&gt;
{color}
&lt;BLOCKQUOTE&gt;
	{color:#333399}Try&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
		{color:#333399}ent.UpgradeOpen()&lt;BR /&gt;
		ent.Layer = lay&lt;BR /&gt;
		ent.DowngradeOpen()&lt;BR /&gt;
		{color}
&lt;/BLOCKQUOTE&gt;
	{color:#333399}Catch ex As Exception&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
		{color:#333399}myUtility.Prompt(vbLf &amp;amp; "Unable to change layer: " &amp;amp; ex.Message)&lt;BR /&gt;
		{color}
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
	{color:#333399}End Try&lt;BR /&gt;
	Trans.Commit()&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
{color:#333399}End Using
myLock.Dispose(){color}&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
btw, i'm getting my entity from another transaction:&lt;BR /&gt;
{color:#333399}Dim ent As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(obId, AutoCAD.DatabaseServices.OpenMode.ForRead), AutoCAD.DatabaseServices.Entity){color}</description>
    <pubDate>Wed, 15 Oct 2008 16:35:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-10-15T16:35:41Z</dc:date>
    <item>
      <title>Entity.UpgradeOpen</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362206#M73048</link>
      <description>i'm having issues with upgrading an entity so i can change its layer... here's what i have&lt;BR /&gt;
&lt;BR /&gt;
{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()&lt;BR /&gt;
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction&lt;BR /&gt;
{color}
&lt;BLOCKQUOTE&gt;
	{color:#333399}Try&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
		{color:#333399}ent.UpgradeOpen()&lt;BR /&gt;
		ent.Layer = lay&lt;BR /&gt;
		ent.DowngradeOpen()&lt;BR /&gt;
		{color}
&lt;/BLOCKQUOTE&gt;
	{color:#333399}Catch ex As Exception&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
		{color:#333399}myUtility.Prompt(vbLf &amp;amp; "Unable to change layer: " &amp;amp; ex.Message)&lt;BR /&gt;
		{color}
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
	{color:#333399}End Try&lt;BR /&gt;
	Trans.Commit()&lt;BR /&gt;
	{color}
&lt;/BLOCKQUOTE&gt;
{color:#333399}End Using
myLock.Dispose(){color}&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
btw, i'm getting my entity from another transaction:&lt;BR /&gt;
{color:#333399}Dim ent As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(obId, AutoCAD.DatabaseServices.OpenMode.ForRead), AutoCAD.DatabaseServices.Entity){color}</description>
      <pubDate>Wed, 15 Oct 2008 16:35:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362206#M73048</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-15T16:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Entity.UpgradeOpen</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362207#M73049</link>
      <description>here's what i did that worked, not sure if it's the right way, but maybe it'll help someone like me &lt;IMG class="emoticon" src="https://forums.autodesk.com/images/emoticons/cool.gif" border="0" alt="" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
            {color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()&lt;BR /&gt;
            Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction&lt;BR /&gt;
                Try&lt;BR /&gt;
                    Dim wEnt As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(ent.ObjectId, OpenMode.ForWrite), AutoCAD.DatabaseServices.Entity)&lt;BR /&gt;
                    wEnt.Layer = lay&lt;BR /&gt;
                    wEnt.DowngradeOpen()&lt;BR /&gt;
                Catch ex As Exception&lt;BR /&gt;
                    myUtility.Prompt(vbLf &amp;amp; "Unable to change layer: " &amp;amp; ex.Message)&lt;BR /&gt;
                End Try&lt;BR /&gt;
                Trans.Commit()&lt;BR /&gt;
            End Using&lt;BR /&gt;
            myLock.Dispose()&lt;BR /&gt;
        End Sub{color}</description>
      <pubDate>Wed, 15 Oct 2008 16:51:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362207#M73049</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-15T16:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Entity.UpgradeOpen</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362208#M73050</link>
      <description>The reason that's happening is because the original transaction&lt;BR /&gt;
that you opened the entity in has already ended when you call &lt;BR /&gt;
UpgradeOpen().&lt;BR /&gt;
&lt;BR /&gt;
You shouldn't use a DBObject once the transaction you got it from&lt;BR /&gt;
has ended, and while there'll usually be no error in cases where&lt;BR /&gt;
you do that with an entity that's open for read, doing it remains &lt;BR /&gt;
a no-no.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;TIMBOT&gt; wrote in message news:6051997@discussion.autodesk.com...&lt;BR /&gt;
i'm having issues with upgrading an entity so i can change its layer... here's what i have&lt;BR /&gt;
&lt;BR /&gt;
{color:#333399}Dim myLock As AutoCAD.ApplicationServices.DocumentLock = myDoc.LockDocument()&lt;BR /&gt;
Using Trans As AutoCAD.DatabaseServices.Transaction = myDb.TransactionManager.StartTransaction&lt;BR /&gt;
{color} &lt;BR /&gt;
  {color:#333399}Try&lt;BR /&gt;
  {color} &lt;BR /&gt;
    {color:#333399}ent.UpgradeOpen()&lt;BR /&gt;
    ent.Layer = lay&lt;BR /&gt;
    ent.DowngradeOpen()&lt;BR /&gt;
    {color} &lt;BR /&gt;
  {color:#333399}Catch ex As Exception&lt;BR /&gt;
  {color} &lt;BR /&gt;
    {color:#333399}myUtility.Prompt(vbLf &amp;amp; "Unable to change layer: " &amp;amp; ex.Message)&lt;BR /&gt;
    {color} &lt;BR /&gt;
  {color:#333399}End Try&lt;BR /&gt;
  Trans.Commit()&lt;BR /&gt;
  {color} &lt;BR /&gt;
{color:#333399}End Using myLock.Dispose(){color}&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
btw, i'm getting my entity from another transaction:&lt;BR /&gt;
{color:#333399}Dim ent As AutoCAD.DatabaseServices.Entity = CType(Trans.GetObject(obId, AutoCAD.DatabaseServices.OpenMode.ForRead), AutoCAD.DatabaseServices.Entity){color}&lt;/TIMBOT&gt;</description>
      <pubDate>Wed, 15 Oct 2008 19:14:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-upgradeopen/m-p/2362208#M73050</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-15T19:14:27Z</dc:date>
    </item>
  </channel>
</rss>

