.NET

Reply
Member
Posts: 4
Registered: ‎12-18-2012
Message 1 of 6 (288 Views)

how to save a layer group in autocad.net

288 Views, 5 Replies
12-18-2012 04:25 AM

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

Valued Mentor
Posts: 381
Registered: ‎04-11-2010
Message 2 of 6 (275 Views)

Re: how to save a layer group in autocad.net

12-18-2012 05:33 AM in reply to: pauline_liz

Hi,

 

I think this is a translation from C#  to VB from the Kean's blog, it creates a layer group:

 

Imports Autodesk.AutoCAD.LayerManager

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

 Gaston Nunez

Member
Posts: 4
Registered: ‎12-18-2012
Message 3 of 6 (272 Views)

Re: how to save a layer group in autocad.net

12-18-2012 05:47 AM in reply to: gasty1001

hi,

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

Valued Mentor
Posts: 381
Registered: ‎04-11-2010
Message 4 of 6 (266 Views)

Re: how to save a layer group in autocad.net

12-18-2012 05:57 AM in reply to: pauline_liz

Hi,

 

Sorry, can you please explain what do you mean  with "save a layer group", or what is the difference with create one?

 

Gaston Nunez

Member
Posts: 4
Registered: ‎12-18-2012
Message 5 of 6 (264 Views)

Re: how to save a layer group in autocad.net

12-18-2012 06:02 AM in reply to: pauline_liz

Hi,

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.

 

more over if u dont mind can u pls help in c#

 

Regards,

liz

Valued Mentor
Posts: 381
Registered: ‎04-11-2010
Message 6 of 6 (260 Views)

Re: how to save a layer group in autocad.net

12-18-2012 06:15 AM in reply to: pauline_liz

Hi,

 

As you are talking about FDO, I guess you are working in AutoCAD MAP  (or Civil 3D), and that is a complete different animal, FDO has his own API (documentation here: Map API), you can get more help posting in the : Map Developers Group 

 

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.

 

Gaston Nunez

 

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community