简体   繁体   English

文件名中的 AutoCAD 命令行空格

[英]AutoCAD Command Line Spaces In Filename

I'm creating my own application to programmatically add a block from an external file into the model space.我正在创建自己的应用程序,以编程方式将来自外部文件的块添加到 model 空间中。 My custom command begins by asking the user to specify the filepath of the block to be inserted.我的自定义命令首先要求用户指定要插入的块的文件路径。

The problem is that the filepath has spaces in it, therefore AutoCAD command line accepts each space as pressing enter.问题是文件路径中有空格,因此 AutoCAD 命令行在按回车键时接受每个空格。 Is there any way to suppress this issue for entering the filepath?有什么方法可以抑制输入文件路径的这个问题吗?

I'm hoping someone can help me out with the below code.我希望有人可以帮助我解决以下代码。

Thanks in advance.提前致谢。

        <CommandMethod("AddHardware")>
        Public Shared Sub Add_Hardware()
            Dim doc As Document = AutoCADApp.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using tr As Transaction = db.TransactionManager.StartTransaction()

                Dim FileName As String = ed.GetString("Filename").StringResult

You can use a PromptStringOptions with Allowspaces = true.您可以使用Allowspaces = true 的 PromptStringOptions。 Apart from that, you should check the PromptResult.Satus value before going on.除此之外,您应该在继续之前检查 PromptResult.Satus 值。

var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var options = new PromptStringOptions("\nEnter the file name: ");
options.AllowSpaces = true;
var result = ed.GetString(options);
if (result.Status == PromptStatus.OK)
{
    string fileName = result.StringResult;
    // ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM