<?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 save a layer group in autocad.net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738951#M51970</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this is a translation from C# &amp;nbsp;to VB from the Kean's blog, it creates a layer group:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports Autodesk.AutoCAD.LayerManager&lt;BR /&gt;&lt;BR /&gt;Public Function GetLayerId(ByVal LayerName As String) As ObjectId
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim ret As ObjectId

        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim acLyrTbl As LayerTable
            acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead)
            If acLyrTbl.Has(LayerName) Then
                For Each objId As ObjectId In acLyrTbl
                    Dim LyrTblRec As LayerTableRecord = acTrans.GetObject(objId, OpenMode.ForRead)
                    If LyrTblRec.Name.ToUpper = LayerName.ToUpper Then
                        ret = objId
                        Exit For
                    End If
                Next
            End If
        End Using
        Return ret
    End Function
	
	
	
	Public Sub CreateLayerGroup(ByVal LayerList As List(Of String), ByVal groupName As string)
        Dim ObjIdList As New ObjectIdCollection
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim Db As Database = acDoc.Database
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

        For Each Lyr As String In LayerList
            Dim ObjId As ObjectId = GetLayerId(Lyr)
            If Not ObjId.IsNull Then
                ObjIdList.Add(ObjId)
            End If
        Next

        Dim lft As LayerFilterTree = Db.LayerFilters
        Dim lfc As LayerManager.LayerFilterCollection = lft.Root.NestedFilters

        ' Create a new layer group

        Dim lg As New LayerGroup()
        lg.Name = groupName

        ' Add our layers' IDs to the list

        For Each id As ObjectId In ObjIdList
            lg.LayerIds.Add(id)
        Next

        ' Add the group to the collection
        Dim LgExists As Boolean = False

        For i As Integer = 0 To lfc.Count - 1
            Dim lf As LayerFilter = lfc(i)
            If lf.Name = lg.Name Then
                LgExists = True
                Exit For
            End If
        Next

        If Not LgExists Then
            lfc.Add(lg)
        End If

        ' Set them back on the Database
        Db.LayerFilters = lft
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Gaston Nunez&lt;/P&gt;</description>
    <pubDate>Tue, 18 Dec 2012 13:33:24 GMT</pubDate>
    <dc:creator>hgasty1001</dc:creator>
    <dc:date>2012-12-18T13:33:24Z</dc:date>
    <item>
      <title>how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738899#M51969</link>
      <description>&lt;P&gt;actually there is afuntionality provided to save a layer and load a layer but i need to save a layer group and load a layer group&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 12:25:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738899#M51969</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-18T12:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738951#M51970</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this is a translation from C# &amp;nbsp;to VB from the Kean's blog, it creates a layer group:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports Autodesk.AutoCAD.LayerManager&lt;BR /&gt;&lt;BR /&gt;Public Function GetLayerId(ByVal LayerName As String) As ObjectId
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim ret As ObjectId

        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim acLyrTbl As LayerTable
            acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead)
            If acLyrTbl.Has(LayerName) Then
                For Each objId As ObjectId In acLyrTbl
                    Dim LyrTblRec As LayerTableRecord = acTrans.GetObject(objId, OpenMode.ForRead)
                    If LyrTblRec.Name.ToUpper = LayerName.ToUpper Then
                        ret = objId
                        Exit For
                    End If
                Next
            End If
        End Using
        Return ret
    End Function
	
	
	
	Public Sub CreateLayerGroup(ByVal LayerList As List(Of String), ByVal groupName As string)
        Dim ObjIdList As New ObjectIdCollection
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim Db As Database = acDoc.Database
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

        For Each Lyr As String In LayerList
            Dim ObjId As ObjectId = GetLayerId(Lyr)
            If Not ObjId.IsNull Then
                ObjIdList.Add(ObjId)
            End If
        Next

        Dim lft As LayerFilterTree = Db.LayerFilters
        Dim lfc As LayerManager.LayerFilterCollection = lft.Root.NestedFilters

        ' Create a new layer group

        Dim lg As New LayerGroup()
        lg.Name = groupName

        ' Add our layers' IDs to the list

        For Each id As ObjectId In ObjIdList
            lg.LayerIds.Add(id)
        Next

        ' Add the group to the collection
        Dim LgExists As Boolean = False

        For i As Integer = 0 To lfc.Count - 1
            Dim lf As LayerFilter = lfc(i)
            If lf.Name = lg.Name Then
                LgExists = True
                Exit For
            End If
        Next

        If Not LgExists Then
            lfc.Add(lg)
        End If

        ' Set them back on the Database
        Db.LayerFilters = lft
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 13:33:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738951#M51970</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-12-18T13:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738959#M51971</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;Thanks for ur reply but i want to save a layer group not to create a layer group can u please help me in this&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 13:47:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738959#M51971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-18T13:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738972#M51972</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, can you please explain what do you mean &amp;nbsp;with "save a layer group", or what is the difference with create one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 13:57:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738972#M51972</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-12-18T13:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738976#M51973</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;actually m new to autocad. when we rightclick on a single FDO layer we can save that layer in our local system in such a way i want to save a layer group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;more over if u dont mind can u pls help in c#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;liz&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 14:02:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738976#M51973</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-18T14:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to save a layer group in autocad.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738986#M51974</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you are talking about FDO, I guess you are working in AutoCAD MAP &amp;nbsp;(or Civil 3D), and that is a complete different animal, FDO has his own API (documentation here: &lt;A href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=868220" target="_self"&gt;Map API&lt;/A&gt;), you can get more help posting in the :&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/AutoCAD-Map-3D-Developer/bd-p/84" target="_self"&gt;Map Developers Group&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It helps a lot ( both, you and the guys trying to help) to post your exact platform (Map 3D 2012 for example) , 32/64 bits, .NET Framework, OS, and a clear explanation of your intended workflow or aim.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2012 14:15:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-save-a-layer-group-in-autocad-net/m-p/3738986#M51974</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-12-18T14:15:48Z</dc:date>
    </item>
  </channel>
</rss>

