AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2019->2022 - problem to delete fdo-layers from layer-explorer

2 REPLIES 2
Reply
Message 1 of 3
jan_tappenbeck
369 Views, 2 Replies

2019->2022 - problem to delete fdo-layers from layer-explorer

hi!

 

i hat a funktion to clear all layers in fdo-explorer. current when a display model is loaded:

 

fdo1.png

 

my function delete all layers and groups in 2019

 

 

Public Function RemoveAllFdoLayers(Optional ByVal Silent As Boolean = False, Optional ByRef LogText As String = "") As Integer
        ' ------ https://forums.autodesk.com/t5/autocad-map-3d-developer/remove-special-or-all-layer-by-topobase/m-p/7243854#M5015 ------
        Dim CountOfLayers As Integer = -1
        Dim CountOfGroups As Integer = -1
        Dim MsgCurrentMapDefine As String = "undefine"

        Try
            Dim docLock As DocumentLock = _AcDocument.LockDocument
            Using docLock
                Dim currentMap As Autodesk.Gis.Map.Platform.AcMapMap = Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap()
                Dim layers As OSGeo.MapGuide.MgLayerCollection = currentMap.GetLayers()

                If Not IsNothing(currentMap) Then
                    MsgCurrentMapDefine = "define"
                End If

                CountOfLayers = layers.Count
                CountOfGroups = currentMap.GetLayerGroups.Count

                currentMap.GetLayers().Clear()
                currentMap.GetLayerGroups().Clear()

            End Using

        Catch ex As System.Exception

            Dim Msg As String = "unerwarteter Fehler in EBL.Layer > Layer_DisplayModell > RemoveAllFdoLayers" & vbCrLf &
                "CountOfLayers:= " & CountOfLayers.ToString & vbCrLf &
                "CountOfGroups:= " & CountOfGroups.ToString & vbCrLf &
                "MsgCurrentMapDefine:= " & MsgCurrentMapDefine & vbCrLf &
                ex.ToString & vbCrLf

            LogText += Msg

            If Silent = False Then
                _TryReport.Show("unerwarteter Fehler in EBL.Layer > Layer_DisplayModell > RemoveAllFdoLayers", Msg)
            End If
            Return -1
        End Try
        Return CountOfLayers
    End Function

 

 

in 2022 the result will be

fdo2.png

in 2019 the group "Sielkataster" will even delete.

 

did someone now if there will something changed?

 

if i now load a display modell following error will show (translate):

"error by draw the displaymodel. reason: error by draw in map - unallow arguments - it is  not allow a empty draworder"

 

alternative i would delete the "Sielkataster" coded - but how.

 

if i delete "Sielkataster" manual then i could draw a new displaymodel.

 

????

regards Jan

 

2 REPLIES 2
Message 2 of 3
duckA6L6Q
in reply to: jan_tappenbeck

For English version see below

Hey Jan,

konkret kann ich Dir nicht weiterhelfen. Aber zwei Dinge gehen mir durch den Kopf. 

1) Gibt es zischen der 19er und der 22er Version Unterschiede beim Count ?

2) Gibt es in 22er eventuell ein Parentobjekt oder vllt. Rootobjekt jeweils zu den Gruppen ?

 

Ich würde mir einen Breakpoint setzen und mir die Instanzen von GetLayers() und GetLayerGroups() genauer ansehen. Vermutlich findest Du dort Hinweise bzw. Unterschiede.

 

Etwas OffTopic, aber denoch IMHO zu bemerken.

Statt einen Fehler abzufangen, könnte man auch eine NULL Prüfung machen. Fehler und auch deren Behandlung kosten immer sehr viel und werden üblicherweise soweit es geht vermieden. Nur wenn nicht kontrollierbare Situationen auftreten, z.B. bei Netz-Zugriffen auf DB oder Files ist es wirklich geboten oder in der GUI. Meist - gerade in Methoden, die nichts mit der GUI zu tun haben, ist es aber auch sinnvoll den Fehler passieren zu lassen. Den kannst Du ja dann eher beim Aufruf der Funktion abfangen.

 

 

 

English Version

------

Can't help you directly, but two things go through my mind.

1) Are there diffs between 22 and 19 regarding the Count ?

2) For 22 version: Is there an parent object or an root object in GetLayers() und GetLayerGroups() ?

 

Set a breakpoint at GetLayers() und GetLayerGroups() and maybe you'll find a difference.

 

Offtopic:

Maybe you try to avoid catch statements, if possible. IMHO in this case it would be enough to check for NULL. Errors are expensive in general.

Message 3 of 3
jan_tappenbeck
in reply to: duckA6L6Q

Hi !

(english below)

 

danke für die Rückmeldung. Die 2019er Version kann ich leider nicht mehr testen, da die DB hochgezogen wurde.

 

Ich habe aber einmal eine Iteration durch die Gruppen vorgenommen und namentlich wird die ursprunglich angemerkte Gruppe "Sielkataster" auch gelistet wird. Das Entfernen wurde dann auch manuell durchgeführt. Bis auf die Root-Gruppe hat das auch mit dem Entfernen geklappt.

 

Gruß Jan

 

Hi !

Thanks for the feedback. Unfortunately,

I can no longer test the 2019 version because the DB has been pulled up. But I once did an iteration through the groups and the originally noted group "Sielkataster" is also listed by name.

 

The removal was then also carried out manually. Except for the root group, this also worked with the removal.

Greetings Jan

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

Post to forums  

Autodesk Design & Make Report