﻿{"id":36205,"date":"2012-05-30T16:25:39","date_gmt":"2012-05-30T08:25:39","guid":{"rendered":"http:\/\/www.lanmaowang.com\/?p=36205"},"modified":"2015-04-01T22:32:41","modified_gmt":"2015-04-01T14:32:41","slug":"delphi-net-secondary-development-of-autocad-c-prompts-the-user-for-a","status":"publish","type":"post","link":"http:\/\/www.lanmaowang.com\/?p=36205","title":{"rendered":"delphi.net\u4e8c\u6b21\u5f00\u53d1AutoCAD\uff08\u4e09\uff09\u63d0\u793a\u7528\u6237\u8f93\u5165"},"content":{"rendered":"<p>\u3000\u3000Editor \u5bf9\u8c61\u662f Document \u5bf9\u8c61\u7684\u5b50\u5bf9\u8c61\uff0c\u5b9a\u4e49\u4e86\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u3002\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u5728 AutoCAD \u547d\u4ee4\u884c\u4e2d\u6216\u52a8\u6001\u8f93\u5165\u5de5\u5177\u63d0\u793a\u4e2d\u663e\u793a\u4e00\u4e2a\u63d0\u793a\u4fe1\u606f\uff0c\u5e76\u4e14\u8981\u6c42\u8f93\u5165\u5404\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u503c\u3002\u8fd9\u79cd\u7528\u6237\u8f93\u5165\u5bf9\u4e8e\u4ea4\u4e92\u5f0f\u8f93\u5165\u5c4f\u5e55\u5750\u6807\u3001\u56fe\u5143\u9009\u62e9\u3001\u77ed\u5b57\u7b26\u4e32\u6216\u6570\u503c\u975e\u5e38\u6709\u7528\u3002\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u8981\u6c42\u8f93\u5165\u591a\u4e2a\u9009\u9879\u6216\u503c\uff0c\u5219\u4f7f\u7528 Windows \u7a97\u4f53\u53ef\u80fd\u6bd4\u4f7f\u7528\u5355\u4e2a\u63d0\u793a\u66f4\u5408\u9002\u3002 &nbsp;<\/p>\n<p><\/p>\n<p>\u3000\u3000\u6bcf\u4e2a\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u90fd\u5728 AutoCAD \u547d\u4ee4\u884c\u663e\u793a\u63d0\u793a\uff0c\u5e76\u8fd4\u56de\u7279\u5b9a\u4e8e\u6240\u8bf7\u6c42\u7684\u8f93\u5165\u7c7b\u578b\u7684\u503c\u3002\u4f8b\u5982\uff0cGetString \u8fd4\u56de\u4e00\u4e2a PromptResult\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u5224\u65ad GetString \u65b9\u6cd5\u7684\u72b6\u6001\u5e76\u83b7\u5f97\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u3002\u6bcf\u4e00\u4e2a\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u90fd\u6709\u4e00\u4e2a\u6307\u5b9a\u7684\u8fd4\u56de\u503c\u3002&nbsp;<\/p>\n<p><\/p>\n<p>\u3000\u3000\u8f93\u5165\u65b9\u6cd5\u63a5\u53d7\u4e00\u4e2a\u7528\u4e8e\u663e\u793a\u63d0\u793a\u7684\u5b57\u7b26\u4e32\u6216\u63a7\u5236\u7528\u6237\u8f93\u5165\u7684\u6307\u5b9a\u5bf9\u8c61\u7c7b\u578b\u3002\u8fd9\u4e9b\u5bf9\u8c61\u7c7b\u578b\u8ba9\u7528\u6237\u53ef\u4ee5\u63a7\u5236\u4e00\u4e9b\u8f93\u5165\uff0c\u50cf\u8f93\u5165 NULL\uff08\u6309\u56de\u8f66\uff09\uff0c\u57fa\u70b9\uff0c\u8f93\u5165\u96f6\u6216\u8d1f\u6570\uff0c\u4efb\u610f\u6587\u672c\u503c\u7684\u8f93\u5165\u3002&nbsp;<\/p>\n<p><\/p>\n<p>\u3000\u3000\u8981\u4f7f\u63d0\u793a\u5355\u72ec\u663e\u793a\u5728\u4e00\u884c\u4e2d\uff0c\u5728VB.NET\u4e2d\u4f7f\u7528\u53ef\u4ee5\u5728\u63d0\u793a\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u4f7f\u7528\u56de\u8f66\u7b26\/\u6362\u884c\u5e38\u91cf\u5b57\u7b26 (vbCrLf)\uff0c\u800c\u5728 C# \u4e2d\u4f7f\u7528 \u201c\\n\u201d \u5b57\u7b26\u4e32\u3002&nbsp;<\/p>\n<p><\/p>\n<p>\u3000\u3000GetString \u65b9\u6cd5\u63d0\u793a\u7528\u6237\u5728 AutoCAD \u547d\u4ee4\u63d0\u793a\u4e0b\u8f93\u5165\u5b57\u7b26\u4e32\u3002\u8be5\u65b9\u6cd5\u63a5\u6536\u4e24\u4e2a\u53c2\u6570\u3002PromptStringOptions \u5bf9\u8c61\u5141\u8bb8\u63a7\u5236\u7528\u6237\u8f93\u5165\u4ee5\u53ca\u600e\u6837\u663e\u793a\u63d0\u793a\u4fe1\u606f\u3002PromptStringOptions \u5bf9\u8c61\u7684 AllowSpaces \u5c5e\u6027\u63a7\u5236\u662f\u5426\u5141\u8bb8\u8f93\u5165\u7a7a\u683c\u3002\u5982\u679c\u4e3a False \uff0c\u6309\u7a7a\u683c\u952e\u5c06\u4e2d\u6b62\u7528\u6237\u8f93\u5165\u3002&nbsp;<\/p>\n<p>\u4e0b\u9762\u4f8b\u5b50\u663e\u793a\u4e86\u201c\u8f93\u5165\u540d\u79f0\u201d\u63d0\u793a\uff0c\u5e76\u8981\u6c42\u7528\u6237\u901a\u8fc7\u6309 ENTER \u952e\u6765\u7ec8\u6b62\u8f93\u5165\uff08\u8f93\u5165\u5b57\u7b26\u4e32\u4e2d\u53ef\u4ee5\u5305\u542b\u7a7a\u683c\uff09\u3002\u8f93\u5165\u5b57\u7b26\u4e32\u503c\u5c06\u901a\u8fc7\u4e00\u4e2a\u6d88\u606f\u6846\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p><\/p>\n<pre class=\"brush:delphi;toolbar:false\">namespace&nbsp;ClassLibrary3;&nbsp;\r\ninterface&nbsp;\r\nuses&nbsp;\r\n&nbsp;&nbsp;Autodesk.AutoCAD.Runtime,&nbsp;Autodesk.AutoCAD.ApplicationServices,Autodesk.AutoCAD.EditorInput;&nbsp;\r\ntype&nbsp;\r\n&nbsp;&nbsp;Class1&nbsp;=public&nbsp;&nbsp;class&nbsp;\r\n&nbsp;&nbsp;private&nbsp;\r\n&nbsp;&nbsp;public&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;[CommandMethod(&#39;MyName&#39;)]&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;class&nbsp;method&nbsp;MyName;&nbsp;\r\n&nbsp;&nbsp;end;&nbsp;\r\nimplementation&nbsp;\r\nclass&nbsp;method&nbsp;Class1.MyName;&nbsp;\r\nvar&nbsp;\r\nacDoc:Document;&nbsp;\r\npStrOpts:PromptStringOptions;&nbsp;\r\npStrRes:PromptResult;&nbsp;\r\nbegin&nbsp;\r\n&nbsp;&nbsp;acDoc:=Application.DocumentManager.MdiActiveDocument;&nbsp;&nbsp;\r\n&nbsp;&nbsp;pStrOpts:=New&nbsp;PromptStringOptions(#13+&#39;\u8bf7\u8f93\u5165\u540d\u79f0\uff1a&nbsp;&#39;);&nbsp;\r\n&nbsp;&nbsp;pStrOpts.AllowSpaces:=True;&nbsp;\r\n&nbsp;&nbsp;pStrRes:=&nbsp;acDoc.Editor.GetString(pStrOpts);&nbsp;&nbsp;\r\n&nbsp;&nbsp;Application.ShowAlertDialog(&#39;\u4f60\u8f93\u5165\u7684\u540d\u79f0\u662f\uff1a&#39;+pStrRes.StringResult);&nbsp;\r\nend;&nbsp;\r\nend.<\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000Editor \u5bf9\u8c61\u662f Document \u5bf9\u8c61\u7684\u5b50\u5bf9\u8c61\uff0c\u5b9a\u4e49\u4e86\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u3002\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u5728 AutoCAD  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":36146,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[193],"tags":[194,210,211],"_links":{"self":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36205"}],"collection":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36205"}],"version-history":[{"count":1,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36205\/revisions"}],"predecessor-version":[{"id":36206,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/posts\/36205\/revisions\/36206"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=\/wp\/v2\/media\/36146"}],"wp:attachment":[{"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36205"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.lanmaowang.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}