<?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: ObjectID from Excel to AutoCAD in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8041338#M25739</link>
    <description>&lt;P&gt;I think you have to do the .Value prop on cells method&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jun 2018 15:52:45 GMT</pubDate>
    <dc:creator>JamesMaeding</dc:creator>
    <dc:date>2018-06-01T15:52:45Z</dc:date>
    <item>
      <title>ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8036690#M25735</link>
      <description>&lt;P&gt;I have created some code to extract the information from an AutoCAD block and put it into a Excel Sheet.&amp;nbsp; I am now working on the code to put the updated information back into the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the items I extracted out was the ObjectID using the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;myXLWS.Cells(CurRow, 23) = myObjID.ToString&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it is stored in the excel sheet in this format:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;(1943116255376)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I try to use this value and try to find this block, I get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 457px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/506692i5E33BEFF756DB589/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code for the reverse process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim myTransMan As DatabaseServices.TransactionManager&lt;BR /&gt;Dim myTrans As DatabaseServices.Transaction&lt;BR /&gt;Dim myDB As DatabaseServices.Database&lt;BR /&gt;Dim myXLApp As Microsoft.Office.Interop.Excel.Application&lt;BR /&gt;Dim myXLWS As Microsoft.Office.Interop.Excel.Worksheet&lt;BR /&gt;myXLApp = GetObject(, "Excel.Application")&lt;BR /&gt;myXLWS = myXLApp.ActiveSheet&lt;BR /&gt;myDB = ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;myTransMan = myDB.TransactionManager&lt;BR /&gt;myTrans = myTransMan.StartTransaction&lt;BR /&gt;Dim CurRow As Long = 9&lt;BR /&gt;Dim LastRow As Long = myXLWS.UsedRange.Rows(myXLWS.UsedRange.Rows.Count).Row&lt;BR /&gt;If CurRow &amp;lt;&amp;gt; LastRow + 1 Then&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Dim myObjID As DatabaseServices.ObjectId = myXLWS.Cells(CurRow, 23)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Dim myBlockRef As DatabaseServices.BlockReference =&amp;nbsp; &amp;nbsp; myObjID.GetObject(DatabaseServices.OpenMode.ForRead)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Class1_Obj.Setattributes(myObjID, "Length", myXLWS.Cells(CurRow, 2))&lt;BR /&gt;&amp;nbsp; &amp;nbsp;CurRow = CurRow + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;' End Transactions&lt;/P&gt;&lt;P&gt;myTrans.Dispose()&lt;BR /&gt;myTransMan.Dispose()&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 23:13:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8036690#M25735</guid>
      <dc:creator>conveyor1</dc:creator>
      <dc:date>2018-05-30T23:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8036725#M25736</link>
      <description>The value within an ObjectId is just a memory address, so it is only good for the current session of that drawing in AutoCAD.  If you want something that is persistent in a drawing, then you should get the Handle from the ObjectId and store that in your spreadsheet.&lt;BR /&gt;&lt;BR /&gt;For going the other way, you can use the Database.GetObjectId method to get the objectId from the handle.&lt;BR /&gt;&lt;BR /&gt;If you really do want to work within the single drawing session using ObjectIds, then for going from the memory address you've stored in the spreadsheet, I believe you'll need to convert that to a System.IntPtr and then use the ObjectId constructor that takes a System.IntPtr argument to create an ObjectId that uses that memory address.</description>
      <pubDate>Wed, 30 May 2018 23:56:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8036725#M25736</guid>
      <dc:creator>artc2</dc:creator>
      <dc:date>2018-05-30T23:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8038747#M25737</link>
      <description>&lt;P&gt;Handles are not guaranteed unique between drawing files either, so it's generally a good idea to include a filename if not a full path to help ensure both data sets refer to the same thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Might also be a good idea to include an object type reference ("AcDbBlockReference", for example) before using the externally stored object data, in case someone overwrote the original DWG file with something else entirely.&amp;nbsp; That handle may refer to something else entirely in the new file and trying to treat a block reference as a line or text will cause problems.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 17:08:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8038747#M25737</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2018-05-31T17:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8039396#M25738</link>
      <description>&lt;P&gt;Afternoon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So no i have changed gear from looking it up with the ObjectID to the Block Handle.&amp;nbsp; I am able to now find the blocks by Handle from the excel sheet in the AutoCAD drawing.&amp;nbsp; However, the values from excel are coming in as System._ComObject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea on how to correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line of code where it starts to error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;If myBlockRef.Handle.Value = myXLWS.Cells(CurRow, 18) Then&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 20:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8039396#M25738</guid>
      <dc:creator>conveyor1</dc:creator>
      <dc:date>2018-05-31T20:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8041338#M25739</link>
      <description>&lt;P&gt;I think you have to do the .Value prop on cells method&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 15:52:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8041338#M25739</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2018-06-01T15:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8041847#M25740</link>
      <description>&lt;P&gt;I eventually did a sub routine to fine the values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Main Program:&lt;/P&gt;&lt;P&gt;Class1_Obj.Setattributes(myObjID, "Length", GetExcelValue(myXLWS.Cells(CurRow, 2)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub Routine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function GetExcelValue(ByVal ExcelCell As Excel.Range) As String&lt;BR /&gt;Dim EXLRANGE As Excel.Range&lt;BR /&gt;EXLRANGE = CType(ExcelCell, Excel.Range)&lt;BR /&gt;Dim ExcelValue As String&lt;BR /&gt;ExcelValue = EXLRANGE.Value&lt;BR /&gt;Return ExcelValue&lt;BR /&gt;End Function&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 19:12:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8041847#M25740</guid>
      <dc:creator>conveyor1</dc:creator>
      <dc:date>2018-06-01T19:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042055#M25741</link>
      <description>&lt;P&gt;why not just:&lt;/P&gt;&lt;P&gt;Class1_Obj.Setattributes(myObjID, "Length", myXLWS.Cells(CurRow, 2).Value)&lt;/P&gt;&lt;P&gt;I think your sub just shuffles the same data around and typing .Value is easier than GetExcelValue( by 8 characters plus no sub to maintain. Take the easy ones &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 21:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042055#M25741</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2018-06-01T21:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042100#M25742</link>
      <description>Afternoon,&lt;BR /&gt;&lt;BR /&gt;I did try that. But it was not an option.&lt;BR /&gt;&lt;BR /&gt;Only options were equals, gethashcode, getype and tostring.&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Jun 2018 21:55:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042100#M25742</guid>
      <dc:creator>conveyor1</dc:creator>
      <dc:date>2018-06-01T21:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectID from Excel to AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042107#M25743</link>
      <description>&lt;P&gt;that makes no sense, your GetExcelValue takes in an Excel.Range, then converts it to same type with CType.&lt;/P&gt;&lt;P&gt;Wonder why...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function GetExcelValue(ByVal ExcelCell As &lt;STRONG&gt;Excel.Range&lt;/STRONG&gt;) As String&lt;BR /&gt;Dim EXLRANGE As Excel.Range&lt;BR /&gt;EXLRANGE = CType(ExcelCell,&lt;STRONG&gt; Excel.Range&lt;/STRONG&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 22:01:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-from-excel-to-autocad/m-p/8042107#M25743</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2018-06-01T22:01:02Z</dc:date>
    </item>
  </channel>
</rss>

