.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Add layers to a layergroup

3 REPLIES 3
Reply
Message 1 of 4
Irvin
735 Views, 3 Replies

How to Add layers to a layergroup

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
3 REPLIES 3
Message 2 of 4
Anonymous
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
Message 3 of 4
Irvin
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.
Message 4 of 4
joantopo
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 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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost