Jump to content

Search the Community

Showing results for tags 'promptkeywordoptions'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 1 result

  1. Hi folks My target was to do a little routine that creates layouts for the views and sets page setups for these layouts. Name of the page setup is asked from the user before making the layouts and I try to use PromptKeywordOptions so that user can only select existing page setups. And here comes the problem. If there is underscore (_) or more in the page setup's name and I type that name, I get error "Invalid option keyword." in the command line. When I messed with page setup manager and tried to rename setups with special characters, I got the following message: "The following characters are not supported: \ / ? " : ; * | , = `". but there are no mention about the underscore. How do I select the name with underscore or do I have to replace all underscores from my page setup names? Here is the routine for selecting page setup: using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using System; using System.Collections.Generic; namespace CAD { public class PageSetupSelector { Document doc; [CommandMethod("SelectPageSetup")] public void SelectPageSetup() { doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; using (Transaction trans = db.TransactionManager.StartTransaction()) { DBDictionary pageSetups = (DBDictionary)trans.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead); List<string> setupNames = new List<string>(); doc.Editor.WriteMessage("\nPage setups:"); foreach (DBDictionaryEntry entry in pageSetups) { doc.Editor.WriteMessage("\n {0}", entry.Key); setupNames.Add(entry.Key); } if (pageSetups.Count > 0) { string question = "\nSelect pagesetup: "; string answer = AskKeywordFromUser(question, setupNames.ToArray(), setupNames[0]); doc.Editor.WriteMessage("\nSelected setup: {0} ", answer); } trans.Abort(); } } protected string AskKeywordFromUser(string question, string[] words, string defaultWord) { PromptKeywordOptions pko = new PromptKeywordOptions(""); pko.Message = question; pko.AllowNone = false; foreach (string word in words) { pko.Keywords.Add(word); } pko.Keywords.Default = defaultWord; PromptResult pr = doc.Editor.GetKeywords(pko); if (pr.Status != PromptStatus.OK) { return String.Empty; } return pr.StringResult; } } } And here is the output from the command line: Page setups: test-A3 test_A3 Select pagesetup [test-A3/test_A3] <test-A3>: test_A3 Invalid option keyword. Select pagesetup [test-A3/test_A3] <test-A3>: "test_A3" Invalid option keyword. Select pagesetup [test-A3/test_A3] <test-A3>: 'test_A3' Invalid option keyword. Select pagesetup [test-A3/test_A3] <test-A3>: Selected setup: test-A3
×
×
  • Create New...