Sorry to have to reinvoke this thread but I am having some trouble with the new keywords being noticed as keywords and thus firing the '.KeywordInput event'. It's also worth noting that the '.KeywordInput' event fires when ONLY the useDefault keyword is entered, all other keywords fire the '.UnkownInput' event. How do I add the keywords so that they are considered keywords and thus fire the correct event?
I just noticed some odd behaviour, only the keywords with the following format are recognised (where x = don't care) "xxxxxxxxx_default". Why?
Code is as follows.
''' <summary> ''' Dimension Encapsulation styles. ''' </summary> <CommandMethod("TD1")> Public Shared Sub dimEncapsulation() Dim useDefault As String = "USe_default" Dim fromLibrary As String = "from_LIbrary" Dim manage As String = "MAnage" Dim acDoc As Document acDoc = Core.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = acDoc.Editor Dim db As Database = acDoc.Database 'Retrieve the default encapsulation Dim dimEncapsulationSelected As nDimEncapsulation.ciDimEncapsulationStyle = nDimEncapsulation.cDocumentIO.getDefaultPrefix() useDefault += " " + dimEncapsulationSelected.prefix.text + "<>" + dimEncapsulationSelected.suffix.text Dim promptSelOpt As New PromptSelectionOptions() With promptSelOpt .Keywords.Add(useDefault) .Keywords.Add(fromLibrary) .Keywords.Add(manage) .Keywords.Default = useDefault Dim kws As String = .Keywords.GetDisplayString(False) .MessageForAdding = vbNewLine + "Add objects to selection or " + kws .MessageForRemoval = vbNewLine + "Remove objects from selection or " + kws AddHandler .KeywordInput, AddressOf keywordEntered AddHandler .UnknownInput, AddressOf keywordInputNull End With Dim promptSelRes As PromptSelectionResult = ed.GetSelection(promptSelOpt) 'Handle the result If promptSelRes.Status = PromptStatus.OK Then 'Start the transaction Dim tr As Transaction = db.TransactionManager.StartTransaction Using tr For Each i As SelectedObject In promptSelRes.Value Dim dimension As Dimension = DirectCast(tr.GetObject(i.ObjectId, OpenMode.ForWrite), Dimension) dimension.Prefix = dimEncapsulationSelected.prefix.text dimension.Suffix = dimEncapsulationSelected.suffix.text Next 'Don't forget to commit the changes to the database tr.Commit() End Using End If End Sub
If someone else is struggling with keywords, here is a part of AutoCAD .NET API documentation where it is stated that underscore can't be part of a keyword when using Editor.GetKeyword method. Maybe the same works for Editor.GetSelection with keywords.
Also one more important thing is to avoid conflict with AutoCAD default PromptSelectionOptions keywords which are listed here.
Greetings.