<?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 How to find the current layout in a sheetset in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5238317#M42801</link>
    <description>&lt;P&gt;I have found ways to enumerate through all the sheets in a given sheet set, but I am more interested in how to find the AcSmSheet object of the current layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;P&gt;Detroit, MI&lt;/P&gt;</description>
    <pubDate>Wed, 27 Aug 2014 22:20:57 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-08-27T22:20:57Z</dc:date>
    <item>
      <title>How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5238317#M42801</link>
      <description>&lt;P&gt;I have found ways to enumerate through all the sheets in a given sheet set, but I am more interested in how to find the AcSmSheet object of the current layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;P&gt;Detroit, MI&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 22:20:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5238317#M42801</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-08-27T22:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427024#M42802</link>
      <description>&lt;P&gt;in VBA I use&amp;nbsp;ThisDrawing.ActiveLayout. ...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 03:56:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427024#M42802</guid>
      <dc:creator>elshawadfy</dc:creator>
      <dc:date>2014-11-28T03:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427420#M42803</link>
      <description>&lt;P&gt;In VB this can be done like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim thisLayoutName As String&amp;nbsp;= LayoutManager.Current.CurrentLayout&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this returns a string, the name of the layout&lt;/P&gt;&lt;P&gt;I can use this to get the layout object, but this has no reference to the Sheet Set that I am aware of.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 15:52:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427420#M42803</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-28T15:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427532#M42804</link>
      <description>&lt;P&gt;I have not done coding to manipulate SheetSet, so I could be wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By quickly browsing the Sheet Manager COM API exposed by "AcSmComponents18[20].tlb", I can see&amp;nbsp;following path that could lead you to find out the link between a layout of an opened drawing and a sheet in an opened sheetset/subsheetset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AcSmSheet.GetLayout() -&amp;gt; AcSmAcDbLayoutReference&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AcSmAcDbLayoutReference.GetFileName()/GetName() -&amp;gt; Drawing file name and layout name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, to find out if the current layout of the active drawing in the AutoCAD editor is in one of the&amp;nbsp;sheets of the opened sheet set, you just loop through each AcSmSheet objects in the SheetSet, looking for the same drawing file name and layout name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 17:54:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5427532#M42804</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2014-11-28T17:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5428060#M42805</link>
      <description>&lt;P&gt;Norman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please explain what you mean by saying "&lt;SPAN&gt;By quickly browsing the Sheet Manager COM API exposed by...&amp;nbsp;&lt;/SPAN&gt;". &amp;nbsp;This is probably a obvious question, but it is something I have heard many times and I am unsure if I understand its meaning. &amp;nbsp;Are you simply browsing through the object browser to discover paths and locations of properties and methods? &amp;nbsp;...or is there something more to it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I personally know zero VB delelopers so I am learning in a vaccuum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;P&gt;Detroit, MI&lt;/P&gt;</description>
      <pubDate>Sun, 30 Nov 2014 02:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5428060#M42805</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-30T02:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the current layout in a sheetset</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5428310#M42806</link>
      <description>&lt;P&gt;Norman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked perfectly, thanks you. &amp;nbsp;See below for the outcome:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    ''' &amp;lt;summary&amp;gt;
    ''' Gets the sheet reference of a given DWGs layout
    ''' &amp;lt;/summary&amp;gt;
    ''' &amp;lt;param name="DWGsDB"&amp;gt;The database of the DWG&amp;lt;/param&amp;gt;
    ''' &amp;lt;param name="DWGsLayoutId"&amp;gt;The ObjectID of the layout&amp;lt;/param&amp;gt;
    ''' &amp;lt;returns&amp;gt;The AcSmSheet of the sheet reference, or Nothing if not found&amp;lt;/returns&amp;gt;
    ''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
    Public Shared Function GetLayoutsSheet(ByVal DWGsDB As Database, ByVal DWGsLayoutId As ObjectId) As AcSmSheet
        'Dim DWGsDB As Database = LayoutIn.Database
        Dim SSM As IAcSmSheetSetMgr = New AcSmSheetSetMgr
        Dim SSsDB As AcSmDatabase = Nothing
        Dim SheetOut As AcSmSheet = Nothing

        'Obtain the sheetset DST from the DWGs dictionary entry
        Dim SSsDSTfileName As String = SheetSets.InterrogateDWG(DWGsDB, desiredIntel.ShSetFileName)

        If SSsDSTfileName IsNot Nothing Then
            'See if the sheetset is open, if not open it
            If SSM.FindOpenDatabase(SSsDSTfileName) Is Nothing Then
                Try
                    SSsDB = SSM.OpenDatabase(SSsDSTfileName, False)
                Catch ex As Exception

                End Try
            Else
                SSsDB = SSM.FindOpenDatabase(SSsDSTfileName)
            End If
        Else
            'No sheetset for us to gather a sheets from, abort now
            Return Nothing
        End If

        Dim DWGsLayoutName As String = Nothing
        Dim DWGsLayoutFileName As String = Nothing
        Dim SSsLayoutRef As AcSmAcDbLayoutReference = Nothing

        Using Trans As Transaction = DWGsDB.TransactionManager.StartTransaction
            Dim myLayout As Layout = DWGsLayoutId.GetObject(OpenMode.ForRead)
            DWGsLayoutName = myLayout.LayoutName
            DWGsLayoutFileName = myLayout.Database.Filename
        End Using

        'If the DWG's SS is available, dig deeper
        If SSsDB IsNot Nothing Then
            Dim enumerator As IAcSmEnumPersist = SSsDB.GetEnumerator()
            Dim thisItem As IAcSmPersist = enumerator.Next() 'Get first
            Do While thisItem IsNot Nothing
                Dim thisSheet As AcSmSheet = Nothing
                'Check to see if the object is a sheet
                If thisItem.GetTypeName() = "AcSmSheet" Then
                    thisSheet = thisItem

                    SSsLayoutRef = thisSheet.GetLayout
                    Dim SSsLayoutRefsName As String = SSsLayoutRef.GetName()
                    Dim SSsLayoutRefsFileName As String = SSsLayoutRef.GetFileName()

                    If DWGsLayoutName = SSsLayoutRefsName And _
                        DWGsLayoutFileName = SSsLayoutRefsFileName Then
                        SheetOut = thisSheet
                        Exit Do
                    End If
                End If

                'Get the next item
                thisItem = enumerator.Next
            Loop
        Else
            'SheetSet could not be accessed, abort
            Return Nothing
        End If
        Return SheetOut
    End Function

    Enum desiredIntel
        LayoutHandle
        LayoutName
        SheetDwgName
        ShSetFileName
        ShSetVersion
        UpdateCount
        UpdateTime
    End Enum

    ''' &amp;lt;summary&amp;gt;
    ''' Gets SheetSet info stored in the dictionary of a given drawing database
    ''' &amp;lt;/summary&amp;gt;
    ''' &amp;lt;param name="DbIn"&amp;gt;Drawing database to interrogate&amp;lt;/param&amp;gt;
    ''' &amp;lt;param name="desiredIntel"&amp;gt;Property to retreive&amp;lt;/param&amp;gt;
    ''' &amp;lt;returns&amp;gt;String value of the dictionary entry&amp;lt;/returns&amp;gt;
    ''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
    Public Shared Function InterrogateDWG(ByVal DbIn As Database, ByVal desiredIntel As desiredIntel) As String
        Dim thisDb As Database = HostApplicationServices.WorkingDatabase
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor

        'See if this DWG has a sheetset associated &amp;amp; open
        Dim IntelOut As String = Nothing

        If IntelOut = Nothing Then
            'If not see if this DWG has a sheetset associated &amp;amp; closed
            'Obtain DST file name from the DWG file's dictionary
            Using myTrans As Transaction = thisDb.TransactionManager.StartTransaction
                Dim nod As DBDictionary = myTrans.GetObject(thisDb.NamedObjectsDictionaryId, OpenMode.ForRead)
                If nod.Contains("AcSheetSetData") Then
                    Dim knd As DBDictionary = myTrans.GetObject(nod.GetAt("AcSheetSetData"), OpenMode.ForRead)
                    'Dim dbEnum As DbDictionaryEnumerator = knd.GetEnumerator
                    'Dim thisEntry As DBDictionaryEntry = dbEnum.Current
                    'While IsNothing(thisEntry) = False
                    '    ed.WriteMessage(thisEntry.Key)
                    'End While

                    If knd.Contains(desiredIntel.ToString) Then
                        Dim ksoEntry As ObjectId = knd.GetAt(desiredIntel.ToString)
                        Dim ksoXrecord As Xrecord = myTrans.GetObject(ksoEntry, OpenMode.ForRead)
                        For Each value As TypedValue In ksoXrecord.Data
                            If value.TypeCode = 1 Then
                                IntelOut = value.Value.ToString()
                                Exit For
                            End If
                        Next
                    End If
                End If
            End Using
        End If
        Return IntelOut
    End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;P&gt;Detroit, MI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Nov 2014 20:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-current-layout-in-a-sheetset/m-p/5428310#M42806</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-30T20:07:51Z</dc:date>
    </item>
  </channel>
</rss>

