<?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 OpenAs in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11433625#M11626</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forgot about an extension I was using to make that happen. If anyone else is interested here it is:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Imports System.Runtime.CompilerServices
Imports Autodesk.AutoCAD.DatabaseServices

Module DBObjectExtensions
    &amp;lt;Extension()&amp;gt;
    Public Function OpenAs(Of T As DBObject)(ByVal objectId As ObjectId, tr As Transaction, openMode As OpenMode)

        Return DirectCast(tr.GetObject(objectId, openMode), T)

    End Function

End Module&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2022 14:13:44 GMT</pubDate>
    <dc:creator>David_Prontnicki</dc:creator>
    <dc:date>2022-09-20T14:13:44Z</dc:date>
    <item>
      <title>ObjectId OpenAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11431740#M11624</link>
      <description>&lt;P&gt;I have an older method I wrote and it is still working in other programs written prior. But when creating a new one, I can not use the same method anymore as it tells me "OpenAs is not a member of ObjectId". Has this changed or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;    Public Sub BurstAllBlocks()

        Dim curDb As Database = Active.Database

        Try

            Using tr As Transaction = curDb.TransactionManager.StartTransaction()

                Dim layoutDbDictionary As DBDictionary = tr.GetObject(curDb.LayoutDictionaryId, OpenMode.ForRead)

                For Each layoutDbDictionaryEntry As DBDictionaryEntry In layoutDbDictionary

                    Dim layout As Layout = CType(layoutDbDictionaryEntry.Value.GetObject(OpenMode.ForRead), Layout)
                    Dim blkTblRec As BlockTableRecord = tr.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite)

                    Dim rxClass = RXObject.GetClass(GetType(BlockReference))
                    Dim blocks = blkTblRec.Cast(Of ObjectId).Where(Function(ent) ent.ObjectClass.IsDerivedFrom(rxClass)) _
                        .Select(Function(ent) ent.OpenAs(Of BlockReference)(tr, OpenMode.ForRead))

                    For Each block As BlockReference In blocks

                        BurstBlocks(tr, block, blkTblRec)

                    Next

                Next

                tr.Commit()

            End Using

        Catch ex As Exception

            MessageServices.DisplayError("Error Bursting Blocks!", "Click OK to skip this section and continue.", ex)

        End Try

    End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 19 Sep 2022 19:51:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11431740#M11624</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2022-09-19T19:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectId OpenAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11431813#M11625</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know the ObjectId type never had such OpenAs method (see &lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-__MEMBERTYPE_Methods_Autodesk_AutoCAD_DatabaseServices_ObjectId" target="_blank" rel="noopener"&gt;ObjectId methods&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;This is certainly an extension method which was part of your "other programs written prior".&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 20:30:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11431813#M11625</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-09-19T20:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: ObjectId OpenAs</title>
      <link>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11433625#M11626</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forgot about an extension I was using to make that happen. If anyone else is interested here it is:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Imports System.Runtime.CompilerServices
Imports Autodesk.AutoCAD.DatabaseServices

Module DBObjectExtensions
    &amp;lt;Extension()&amp;gt;
    Public Function OpenAs(Of T As DBObject)(ByVal objectId As ObjectId, tr As Transaction, openMode As OpenMode)

        Return DirectCast(tr.GetObject(objectId, openMode), T)

    End Function

End Module&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 14:13:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/objectid-openas/m-p/11433625#M11626</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2022-09-20T14:13:44Z</dc:date>
    </item>
  </channel>
</rss>

