<?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: How to get the Handle of the CAD object  ? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476522#M29199</link>
    <description>&lt;P&gt;Hi Gilles&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;FONT color="#808080"&gt;_gile wrote:&lt;/FONT&gt;&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;You can directly get a Handle from an ObjectId&amp;nbsp; using the ObjectId.Handle property.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I added that option in post 4 ... while you were posting your comment &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reminder note about&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the undocumented &lt;FONT color="#0000FF"&gt;&lt;EM&gt;TryGetObjectId()&lt;/EM&gt; &lt;/FONT&gt;method&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 05:16:18 GMT</pubDate>
    <dc:creator>kerry_w_brown</dc:creator>
    <dc:date>2017-10-20T05:16:18Z</dc:date>
    <item>
      <title>How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476343#M29194</link>
      <description>&lt;DIV class="trans-left"&gt;Hello everyone！&lt;/DIV&gt;&lt;DIV class="trans-right"&gt;&lt;DIV class="output-wrap"&gt;&lt;DIV class="output-mod ordinary-wrap"&gt;&lt;DIV class="output-bd"&gt;&lt;P class="ordinary-output target-output clearfix"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ordinary-output target-output clearfix"&gt;&lt;SPAN&gt;I have a question of ObjectARX！&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ordinary-output target-output clearfix"&gt;&lt;SPAN&gt;I &amp;nbsp;want to&amp;nbsp;get the Handle of the CAD object &amp;nbsp;?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ordinary-output target-output clearfix"&gt;&lt;SPAN&gt;who can help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ordinary-output target-output clearfix"&gt;&lt;SPAN&gt;sample or source!!&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Oct 2017 01:58:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476343#M29194</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-20T01:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476482#M29195</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First&lt;/P&gt;
&lt;P&gt;get the&amp;nbsp;&lt;SPAN&gt;DBObject , call it say dbObj&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Handle dbObjHandle =&amp;nbsp; dbObj.Handle;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;String&amp;nbsp;dbObjHandleString =&amp;nbsp; dbObj.Handle.ToString();&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:30:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476482#M29195</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-10-20T04:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476493#M29196</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you may need these later&lt;/P&gt;
&lt;P&gt;thanks to Jim Awe (from around 2004) published in the&amp;nbsp;&lt;SPAN&gt;MgdDbg project.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://github.com/ADN-DevTech/MgdDbg" target="_blank"&gt;https://github.com/ADN-DevTech/MgdDbg&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;       /// &amp;lt;summary&amp;gt;
       /// Converts a string value to a Handle object.
       /// &amp;lt;/summary&amp;gt;
       /// &amp;lt;param name="strHandle"&amp;gt;&amp;lt;/param&amp;gt;
       /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
       public static Handle
       StringToHandle (String strHandle)
       {
           Handle handle = new Handle();

           try
           {
               Int64 nHandle = Convert.ToInt64(strHandle, 16);
               handle = new Handle(nHandle);
           }
           catch (System.FormatException)
           {
           }
           return handle;
       }

       /// &amp;lt;summary&amp;gt;
       /// Gets the ObjectId that corresponds to the handle.
       /// &amp;lt;/summary&amp;gt;
       /// &amp;lt;param name="db"&amp;gt;&amp;lt;/param&amp;gt;
       /// &amp;lt;param name="h"&amp;gt;&amp;lt;/param&amp;gt;
       /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
       public static ObjectId
       HandleToObjectId (Database db, Handle h)
       {
           ObjectId id = ObjectId.Null;
           try
           {
               id = db.GetObjectId(false, h, 0);
           }
           catch (Autodesk.AutoCAD.Runtime.Exception x)
           {
               if (x.ErrorStatus != Autodesk.AutoCAD.Runtime.ErrorStatus.UnknownHandle)
               {
                   throw x;
               }
           }
           return id;
       }&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:39:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476493#M29196</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-10-20T04:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476504#M29197</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively try&lt;/P&gt;
&lt;PRE&gt;ObjectId.Handle;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autode&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-50FD6118-B2D1-4313-A7D6-830794DFDEFA-htm.html" target="_blank"&gt;sk.A&lt;/A&gt;utoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
 
[CommandMethod("StartTransactionManager")]
public static void StartTransactionManager()
{
    // Get the current document and database
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
    Database acCurDb = acDoc.Database;
 
    // Start a transaction
    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
    {
        // Open the Block table for read
        BlockTable acBlkTbl;
        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                     OpenMode.ForRead) as BlockTable;
 
        // Open the Block table record Model space for read
        BlockTableRecord acBlkTblRec;
        acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                        OpenMode.ForRead) as BlockTableRecord;
 
        // Step through the Block table record
        foreach (ObjectId asObjId in acBlkTblRec)
        {
            acDoc.Editor.WriteMessage("\nDXF name: " + asObjId.ObjectClass.DxfName);
            acDoc.Editor.WriteMessage("\nObjectID: " + asObjId.ToString());
            acDoc.Editor.WriteMessage("\nHandle: " + asObjId.Handle.ToString());
            acDoc.Editor.WriteMessage("\n");
        }
 
        // Dispose of the transaction
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample from&lt;/P&gt;
&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-50FD6118-B2D1-4313-A7D6-830794DFDEFA-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-50FD6118-B2D1-4313-A7D6-830794DFDEFA-htm.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:53:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476504#M29197</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-10-20T04:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476505#M29198</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can directly get a Handle from an ObjectId&amp;nbsp; using the ObjectId.Handle property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's an undocumented TryGetObjectId() method;&lt;/P&gt;
&lt;P&gt;Database.TryGetObjectId(Handle h, out ObjectId id) -&amp;gt; bool&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:54:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476505#M29198</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-10-20T04:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Handle of the CAD object  ?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476522#M29199</link>
      <description>&lt;P&gt;Hi Gilles&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;FONT color="#808080"&gt;_gile wrote:&lt;/FONT&gt;&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;You can directly get a Handle from an ObjectId&amp;nbsp; using the ObjectId.Handle property.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I added that option in post 4 ... while you were posting your comment &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reminder note about&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the undocumented &lt;FONT color="#0000FF"&gt;&lt;EM&gt;TryGetObjectId()&lt;/EM&gt; &lt;/FONT&gt;method&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 05:16:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-handle-of-the-cad-object/m-p/7476522#M29199</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-10-20T05:16:18Z</dc:date>
    </item>
  </channel>
</rss>

