.NET

Reply
Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 1 of 4 (303 Views)

How to Add layers to a layergroup

303 Views, 3 Replies
04-22-2009 11:21 PM
Hello,

Is there any one how can help me. How do i add layer to a layergroup.

I know how to create a new layer. But i dont know how to add it to a layergroup.

Can any one provide me a sample on how to achive my goal. Im using C# but a VB.net sample
is also welcome.

Kind regards,

Irvin Berkel Edited by: Irvin on Apr 23, 2009 6:31 AM
*Michael Robertson
Message 2 of 4 (303 Views)

Re: How to Add layers to a layergroup

05-15-2009 11:05 AM in reply to: Irvin
Hello Irvin,

Hope this helps:
'Create Layer Group Filter Containing Layers just created
Private Sub CreateLayerFilter(ByRef db As Database, ByVal filename
As String)
Dim lft As LayerFilterTree = db.LayerFilters
Dim lfc As LayerFilterCollection = lft.Root.NestedFilters
Dim lgt As New LayerGroup
Dim lf As New LayerFilter
Dim t As Transaction = db.TransactionManager.StartTransaction()
Dim lt As LayerTable = t.GetObject(db.LayerTableId, OpenMode.ForWrite)

lgt = New LayerGroup
lgt.Name = filename.ToUpper

'get the layerid for each existing layer and add to layer group
For Each ltrID As ObjectId In lt
lgt.LayerIds.Add(ltrID)
Next
lfc.Add(lgt)
db.LayerFilters = lft
t.Commit()
End Sub
Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 3 of 4 (302 Views)

Re: How to Add layers to a layergroup

05-16-2009 11:03 AM in reply to: Irvin
Hi Michael,

Thank's for your code example. Had to converd it to C# but
that was not verry hard. Thanks again.

Kind regards,

Irvin from the Netherlands.
Valued Mentor
joantopo
Posts: 739
Registered: ‎04-25-2010
Message 4 of 4 (109 Views)

Re: How to Add layers to a layergroup

10-31-2013 03:49 PM in reply to: Irvin

Excuse me.

 

Is it possible get LayerCollection for kind "LayerFilter"?

With the method "LayerIds" we can get LayerCollection for "LayerGroup" but this method doesn´t exist for "LayerFilter".

 

Thank you.

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.