Description Key Set Search Order Help

Description Key Set Search Order Help

David_Prontnicki
Collaborator Collaborator
678 Views
2 Replies
Message 1 of 3

Description Key Set Search Order Help

David_Prontnicki
Collaborator
Collaborator

I found this function online and need some help modifying it. As it stands it will create a DKS and set it to the top of the search order. But I do not want to create one. I just want to move (switch to) an existing one to the top of the list.  If I call the function with a name that does not already exist it will create the DKS and place it at the top of the list. If I call the function with a name that DOES already exist, nothing happens.

 

    Private Function createOrRetrieveDescriptionKeySetAndForce(name As String) As ObjectId

        Dim curDb As Database = Active.Database
        Dim keySets As PointDescriptionKeySetCollection = PointDescriptionKeySetCollection.GetPointDescriptionKeySets(curDb)
        Dim searchOrder As ObjectIdCollection = keySets.SearchOrder

        If keySets.Contains(name) Then

            Return keySets(name)

        End If

        Dim newKeySetId As ObjectId = keySets.Add(name)
        searchOrder.Insert(0, newKeySetId)
        keySets.SearchOrder = searchOrder

        Return newKeySetId

    End Function
0 Likes
Accepted solutions (1)
679 Views
2 Replies
Replies (2)
Message 2 of 3

David_Prontnicki
Collaborator
Collaborator

Ultimately what I am trying to accomplish is this: I would like to switch between DKSs. We have two; plan and raw. I would like to in one command, apply the raw DKS to the _All Points point group and then in another apply the Plan.

 

Can anyone help me figure out how to do this?

0 Likes
Message 3 of 3

David_Prontnicki
Collaborator
Collaborator
Accepted solution

OK, so I figured it out, and figured I would post the answer in case anyone else was looking for the answer to this. Not sure if this is the best way to do it but it works. You have to get the objectid for each DKS in the list, clear the list and reinsert in the DKSs in the order in which you want them. Example snippet below:

 

'Get current description key set collection
        Dim descriptionKeySets As PointDescriptionKeySetCollection = PointDescriptionKeySetCollection.GetPointDescriptionKeySets(curDb)

        'Get current description key set search order
        Dim descriptionKeySearchOrder As ObjectIdCollection = descriptionKeySets.SearchOrder

Try

            'Start the transaction
            Using trans As Transaction = curDb.TransactionManager.StartTransaction()

                'Check if the raw description key set is in the current drawing
                If descriptionKeySets.Contains(rawData) Then

                    'Set object ids for description key sets
                    Dim rawDataKeySetId As ObjectId = descriptionKeySets.Item(rawData)
                    Dim surveyPlanKeySetId As ObjectId = descriptionKeySets.Item(surveyPlan)

                    'Clear current description key set search order
                    descriptionKeySearchOrder.Clear()

                    'Insert description key sets in required order
                    descriptionKeySearchOrder.Insert(0, rawDataKeySetId)
                    descriptionKeySearchOrder.Insert(1, surveyPlanKeySetId)

                    'Re-set description key set search order
                    descriptionKeySets.SearchOrder = descriptionKeySearchOrder 

........