Is it possible to add a layergroup in the Task Pane (Display Manager) with .Net code?
I have tried this code but I get an error when I use grp.add(...). Have also tried with grp.Insert(...) but also an error show up. What do I need to do more to get it to work properly?
If I save the dwg file, and then open it again, the layergroup is there and it works.
Public Sub MapCreateGroup(ByVal sGrp As String)
Dim currentMap As AcMapMap = AcMapMap.GetCurrentMap()
Dim sName As String = currentMap.Name
Dim grpcol As MgLayerGroupCollection = currentMap.GetLayerGroups()
If (Not grpcol.Contains(sGrp)) Then
Dim MgLayGroup As New MgLayerGroup(sGrp)
MgLayGroup.SetDisplayInLegend(True)
MgLayGroup.SetExpandInLegend(False)
MgLayGroup.SetLegendLabel(sGrp)
grpcol.Add(MgLayGroup)
End If
End Sub
Error: An unclassified exception occurred.