GetString 方法 (.NET)
该方法在命令提示符下提示用户输入字符串。该对象允许您控制输入的输入以及提示消息的显示方式。该对象的属性控制在提示符下是否允许空格。如果设置为 false,则按空格键终止输入。GetStringPromptStringOptionsAllowSpacesPromptStringOptions 在命令行中从用户处获取字符串值以下示例显示“输入您的姓名”提示,并要求按 Enter 键终止用户的输入(输入字符串中允许有空格)。输入的字符串将显示在消息框中。 VB.NETImports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
<CommandMethod("GetStringFromUser")> _
Public Sub GetStringFromUser()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim pStrOpts As PromptStringOptions = New PromptStringOptions(vbLf & _
"Enter your name: ")
pStrOpts.AllowSpaces = True
Dim pStrRes As PromptResult = acDoc.Editor.GetString(pStrOpts)
Application.ShowAlertDialog("The name entered was: " & _
pStrRes.StringResult)
End Sub
C#using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
[CommandMethod("GetStringFromUser")]
public static void GetStringFromUser()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
PromptStringOptions pStrOpts = new PromptStringOptions("\nEnter your name: ");
pStrOpts.AllowSpaces = true;
PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);
Application.ShowAlertDialog("The name entered was: " +
pStrRes.StringResult);
}
VBA/ActiveX 代码参考Sub GetStringFromUser()
Dim retVal As String
retVal = ThisDrawing.Utility.GetString _
(1, vbCrLf & "Enter your name: ")
MsgBox "The name entered was: " & retVal
End Sub
相关概念父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 09:48
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.