<?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 Re: From Handle to Object in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743067#M64309</link>
    <description>&lt;P&gt;I found the problem&lt;/P&gt;&lt;P&gt;If I try to getObject for Read it works fine, but if for write it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can that happen?&lt;/P&gt;&lt;P&gt;ex.message.tostring is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"eLockViolation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Thu, 12 Aug 2010 10:00:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-08-12T10:00:24Z</dc:date>
    <item>
      <title>From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2742317#M64306</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saved a object handle in listview item tag&lt;/P&gt;&lt;PRE&gt;lvItem.tag=objFixture.Handle.ToString&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;later on I pass this handle to another function&lt;/P&gt;&lt;PRE&gt;    Private Sub func(ByVal strHandle As String, ByVal strError As String)

        Dim ed As Editor = acApp.DocumentManager.MdiActiveDocument.Editor
        Dim trans As Transaction = acApp.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction
        Dim db As Database = acApp.DocumentManager.MdiActiveDocument.Database
        Try
            Dim objID As ObjectId = db.GetObjectId(False, New Handle(Convert.ToInt64(strHandle, 16)), 0)
            Dim objFixture As BlockReference = trans.GetObject(objID, OpenMode.ForWrite)  &lt;STRONG&gt;' Here will throw error&lt;/STRONG&gt;
            Dim rbOld As ResultBuffer = objFixture.GetXDataForApplication(STR_XDATA_FIXTURE)
            Dim tvOld() As TypedValue = rbOld.AsArray
                  ....
                  .....      
            Dim rbNew As New ResultBuffer(tvOld)
            objFixture.XData = rbNew
            rbNew.Dispose()
            trans.Commit()
        Catch ex As Exception
            ' strError = ex.Message.ToString
            trans.Abort()
        Finally
            trans.Dispose()
        End Try

    End Sub&lt;/PRE&gt;&lt;P&gt;Calling part is&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Func(lvItem.Tag.ToString, strError)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I would like to get a blockreference based on the handle then get/set its xdata&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;This question may obvious to you guys, as I am new to .Net AutoCAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 16:12:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2742317#M64306</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-11T16:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2742385#M64307</link>
      <description>&lt;P&gt;Instead of using Convert(), use Int64.Parse() and specify the allowhex option.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 17:00:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2742385#M64307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-11T17:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743057#M64308</link>
      <description>&lt;P&gt;I have changed to&lt;/P&gt;&lt;PRE&gt;Dim objID As ObjectId = db.GetObjectId(False, New Handle(Int64.Parse(strHandle, Globalization.NumberStyles.AllowHexSpecifier)), 0)
Dim objFixture As BlockReference = trans.GetObject(objID, OpenMode.ForWrite)&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;but still can not create object.&lt;/P&gt;&lt;P&gt;In my catch&lt;/P&gt;&lt;P&gt;ex.message.tostring is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;"eLockViolation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 09:43:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743057#M64308</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T09:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743067#M64309</link>
      <description>&lt;P&gt;I found the problem&lt;/P&gt;&lt;P&gt;If I try to getObject for Read it works fine, but if for write it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can that happen?&lt;/P&gt;&lt;P&gt;ex.message.tostring is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"eLockViolation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 10:00:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743067#M64309</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T10:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743089#M64310</link>
      <description>&lt;P&gt;Look at: &lt;A target="_blank" href="http://forums.autodesk.com/t5/NET/Newbie-question/m-p/2538468#M15577" rel="nofollow"&gt;http://forums.autodesk.com/t5/NET/Newbie-question/m-p/2538468#M15577&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 10:45:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2743089#M64310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T10:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: From Handle to Object</title>
      <link>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2744141#M64311</link>
      <description>&lt;P&gt;You must use the Document's LockDocument() method to lock the&lt;/P&gt;&lt;P&gt;document before you can open objects for write.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In C# the basic usage is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   using( DocumentLock mylock = myDocument.LockDocument() )
   {
        // here you modify the database.
   }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 21:24:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/from-handle-to-object/m-p/2744141#M64311</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T21:24:50Z</dc:date>
    </item>
  </channel>
</rss>

