AutoLisp 2021 处理正则表达式的方式与 2019 不同

AutoLisp 2021 processing regex differently to 2019

我们有一个函数,通过输入粘贴反应器调用来处理绘图中的一些文本。我们使用 Autodesk 2021 从 2019 年迁移的脚本中得到不同的结果,我不明白为什么会有差异。脚本如下:

;; GDD parser to remove unnecessary info from the paste to prepare for processing
;; Modified Lee mac's unformat function - removes formatting from a string
(defun GDD:removeinfo ( rgx str )
(if
    (null
        (vl-catch-all-error-p
            (setq str
                (apply
                   '(lambda nil
                        (vlax-put-property rgx 'global     actrue)
                        (vlax-put-property rgx 'multiline  actrue)
                        (vlax-put-property rgx 'ignorecase acfalse) 
                        (foreach pair
                           '(
                                ("\032"     . "\\\\")
                                ("\n"        . "\\P")
                                (""       . "\\(\\[ACcFfHKkLlOopQTW])|\\[ACcFfHKkLlOopQTW][^\\;]*;|\\;[ACcFfKkHLlOopQTW]")
                                ("/"  . "([^\\])\\S([^;]*)[/#\^]([^;]*);")
                                (""     . "\\(\\S)|[\\](})|}")
                                (""       . "[\\]({)|{")
                                ("\" . "(\\[ACcFfHKkLlOoPpQSTW])|({)|(})")
                                ("\\"     . "2")
                                ;; Added from LMs original quickunformat
                                (""     . "(?:.*\n)*Const\s+.*\n")
                                (""     . "\w\w\d?\s+\d+\s\d+-\d+-\d+")
                                (""     . "^\s+\n")
                            )
                            (vlax-put-property rgx 'pattern (cdr pair))
                            (setq str (vlax-invoke rgx 'replace str (car pair)))
                        )
                    ) nil
                )
            )
        )
    )
    str
    (prompt (strcat "\nError: " (vl-catch-all-error-message str)))
)
)

粘贴的输入字符串是:

Ranford Rd, Perth WA, Australia
Clear Markers

-3773641.56683170, 12902093.08140300 | 0, 01 feature(s) selected on 1 layer(s)1:
2256.9944
979.35 x 559.54 m

Attribute   Value
SUBTYPE ROUTE
ATTRIBUTE   
TLS_ID              15006025041
Date                30-06-1997
Length              231.0
Shared              NO
Const               MULTI-CONDUIT
                AA     P100  312F   -       SMOF    FNPEHJC/STDCNVL F CNVL 4701:CNVL AD-CNVL AE/1-312
                             312F   -       SMOF    FNPEHJ/STD CNVL F HILN 4602:CNVL AE-CNVL BW/1-312
                             120F   -       SMOF    FNPEHJ/STD CNVL F BATA 1001:CNVL AE-CNVL CR/1-120
                             24F    -       SMOF    FNPEHJ     CNVL F CNVL 1001:CNVL AD-CNVL AE/1-24
                             12F    -       SMOF    FNPEHJC/STDCNVL F BATA 1001:CNVL DL-CNVL HX/1-12
                AB     P100  200    0.40    CPFUT   MB      CNVL CA1:B1901-2100
AA                  15038127628 30-06-1997
AB                  15038127629 30-06-1997

函数中的输出(str)应该是:

                AA     P100  312F   -       SMOF    FNPEHJC/STDCNVL F CNVL 4701:CNVL AD-CNVL AE/1-312
                             312F   -       SMOF    FNPEHJ/STD CNVL F HILN 4602:CNVL AE-CNVL BW/1-312
                             120F   -       SMOF    FNPEHJ/STD CNVL F BATA 1001:CNVL AE-CNVL CR/1-120
                             24F    -       SMOF    FNPEHJ     CNVL F CNVL 1001:CNVL AD-CNVL AE/1-24
                             12F    -       SMOF    FNPEHJC/STDCNVL F BATA 1001:CNVL DL-CNVL HX/1-12
                AB     P100  200    0.40    CPFUT   MB      CNVL CA1:B1901-2100

但是,当我们在 Autodesk 2021 中使用相同输入处理此函数时,输出(对于 str)为:

Ranford Rd, Perth WA, Australia

它看起来像是函数错误或 returns 在它接收并退出的第一个换行符上,尽管在调试器中我可以看到正在处理的正则表达式对。我不知道为什么新版本有什么不同?非常感谢您的帮助。

这是由于 AutoCAD 2021 引入了新的 AutoLISP Unicode 字符支持,同时引入了 VS Code 作为主要 AutoLISP 编辑器。

要恢复到 AutoCAD 2020 及更早版本的行为,您可以将新的 LISPSYS 系统变量设置为 0:

LISPSYS (System Variable)

Controls the default AutoLISP development environment and the editor launched with the VLISP command.


0

Visual LISP IDE (VLIDE) is set as the default editor, however AutoLISP functions don't fully support Unicode characters. AutoLISP source (LSP) files when saved and compiled use the ASCII (MBCS) character set. Note: This setting results in the behavior of AutoCAD 2020 and earlier releases, and is supported on Windows only.


1

Visual Studio (VS) Code is set as the default editor and AutoLISP functions fully support Unicode characters. AutoLISP source (LSP) files, when saved, use the encoding set in VS Code, and when compiled, they use the Unicode character set.


2

Visual Studio (VS) Code is set as the default editor and AutoLISP functions fully support Unicode characters. AutoLISP source (LSP) files, when saved, use the encoding set in VS Code, and when compiled they use the ASCII (MBCS) character set.