CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 文档中心

关于使用宏中的 DIESEL 表达式响应 AutoLISP

2023-1-9 00:55| 发布者: admin| 查看: 456| 评论: 0|来自: AutoCAD

您可以将 DIESEL 字符串表达式用作一种方式,用来提供对使用 AutoLISP 或 ObjectARX 定义的命令的响应。

DIESEL 表达式返回字符串值(文字字符串),可以用作对标准命令、AutoLISP 和 ObjectARX ® 程序以及其他宏的响应。

注: AutoLISP 和 ObjectARX 在 AutoCAD LT 中不可用。

由 DIESEL 表达式返回的值是文字字符串,它可用于响应 AutoLISP getxxx 或 ObjectARX acetGetxxx 函数调用。这使菜单项可以对当前图形条件进行求值,并将值返回 AutoLISP 或 ObjectARX 程序。

如果要加载和执行以下样例 AutoLISP 程序,程序将提示输入符号名称、大小以及在图形中的位置。

(defun C:SYMIN()
  (setq sym 
    (getstring 
      "\nEnter symbol name: ")      ; Prompts for a symbol name
  )

  (setq 
    siz (getreal 
          "\nSelect symbol size: ") ; Prompts for a symbol size

    p1 (getpoint 
          "\nInsertion point: ")    ; Prompts for insertion point
  )

  (command "._insert"               ; Issues the INSERT command
           sym                      ; using the desired symbol
           p1 siz siz 0)            ; insertion point, and size

 (princ)                            ; Exits quietly 
)
注: 常用的 AutoLISP 程序应该包括错误检查,以验证用户输入的正确性。

执行上一个样例时,您可以单击执行 DIESEL 表达式的用户界面元素以响应其中一个提示。例如,您可以使用表达式 $M=$(*,$(getvar,dimscale),0.375) 来使用比例因子,该因子为当前 DIMSCALE 的 3/8。

这无法使用类似的 AutoLISP 代码来完成,因为由 AutoLISP 表达式返回的值通常无法用作对 getxxx 函数调用(例如,上例中的 getreal 函数)的响应。


路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 12:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部