AutoLISP 符号
函数 和 让 ObjectARX 应用程序检查和更改 AutoLISP 变量的值。acedGetSym()acedPutSym() 在第一个示例中,用户输入以下 AutoLISP 表达式: 命令:(setq testboole t) T 命令:(setq teststr “HELLO, WORLD”) “你好,世界” 命令:(setq sset1 (ssget)) <选择集:1> 然后,以下示例代码演示如何检索符号的新值。acedGetSym() struct resbuf *rb;
int rc;
long sslen;
rc = acedGetSym("testboole", &rb);
if (rc == RTNORM && rb->restype == RTT)
acutPrintf("TESTBOOLE is TRUE\n");
acutRelRb(rb);
rc = acedGetSym("teststr", &rb);
if (rc == RTNORM && rb->restype == RTSTR)
acutPrintf("TESTSTR is %s\n", rb->resval.rstring);
acutRelRb(rb);
rc = acedGetSym("sset1", &rb);
if (rc == RTNORM && rb->restype == RTPICKS) {
rc = acedSSLength(rb->resval.rlname, &sslen);
acutPrintf("SSET1 contains %lu entities\n", sslen);
}
acutRelRb(rb);
反之,可以创建或更改 AutoLISP 符号的绑定,如下所示:acedPutSym() ads_point pt1;
pt1[X] = pt1[Y] = 1.4; pt1[Z] = 10.9923;
rb = acutBuildList(RTSTR, "GREETINGS", 0);
rc = acedPutSym("teststr", rb);
acedPrompt("TESTSTR has been reset\n");
acutRelRb(rb);
rb = acutBuildList(RTLB, RTSHORT, -1,
RTSTR, "The combinations of the world",
RTSTR, "are unstable by nature.", RTSHORT, 100,
RT3DPOINT, pt1,
RTLB, RTSTR, "He jests at scars",
RTSTR, "that never felt a wound.", RTLE, RTLE, 0);
rc = acedPutSym("longlist", rb);
acedPrompt("LONGLIST has been created\n");
acutRelRb(rb);
要将 AutoLISP 变量设置为 nil,请进行以下赋值和函数调用: rb->restype = RTNIL;
acedPutSym("var1", rb);
用户可以检索这些新值。(如示例中所示,程序应通知用户任何更改。 TESTSTR 已重置。 LONGLIST 已创建。 命令:!teststr (“问候”) 命令:!longlist ((-1 “世界的组合”“本质上是不稳定的。100 (1.4, 1.4, 10.9923) (“他拿伤疤开玩笑”,“从来没有感觉到伤口。 父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-28 13:54
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.