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

getting values from object on Map

1 REPLY 1
Reply
Message 1 of 2
Anonymous
255 Views, 1 Reply

getting values from object on Map

Greetings! I have some sdf-file with objects(lines) and every line has attributes(e.g featId and Name). I have a code resolving my issue but only with selection all objects. I wanna get the names of lines without selecting objects(e.g when I run my custom pallete which has a combobox filled with list of names of these lines). Is it possible to get attribute data of object on map without selecting objest?

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim listOfNames as List(Of String) = New List(Of String)
        Dim ed =  Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        Dim currentMap As AcMapMap = AcMapMap.GetCurrentMap()
        Dim layers As MgLayerCollection = currentMap.GetLayers()
        Dim selResult As PromptSelectionResult = ed.GetSelection()

        If selResult.Status = PromptStatus.OK Then
            Dim selSet As SelectionSet = selResult.Value
            Dim selectionBase As MgSelectionBase = AcMapFeatureEntityService.GetSelection(selSet)
            Dim myLayer As MgLayerBase = Nothing

            For Each layer As MgLayerBase In selectionBase.GetLayers()

                If layer.Name = "MapOfRoad" Then
                    myLayer = layer
                    Exit For
                End If
            Next

            If myLayer Is Nothing Then
                ed.WriteMessage("No Feature is selected from the designated Layer ! ")
                Return
            End If

            Dim reader As MgFeatureReader = selectionBase.GetSelectedFeatures(myLayer, myLayer.FeatureClassName, False)

            Try

                While reader.ReadNext()
                    Dim featureName As String = reader.GetString("NameRoad")
                    listOfNames.Add(featureName)
                End While

            Finally
                reader.Close()
            End Try
        End If
    End Sub
1 REPLY 1
Message 2 of 2
ChicagoLooper
in reply to: Anonymous

You can retrieve any attribute present in the sdf. The issue is what do you want to do with it after you retrieve, isolate, identify, highlight, stylized, colorized, or manipulate the geometry related to that value? You must provide the 'big picture' of what you want to accomplish because that will determine how to get values from objects on your Map. 

Chicagolooper

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report