How to Add layers to a layergroup

How to Add layers to a layergroup

Anonymous
Not applicable
1,149 Views
3 Replies
Message 1 of 4

How to Add layers to a layergroup

Anonymous
Not applicable
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
0 Likes
1,150 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
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
0 Likes
Message 3 of 4

Anonymous
Not applicable
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.
0 Likes
Message 4 of 4

joantopo
Mentor
Mentor

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 C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
0 Likes