BDYCAD 发表于 2006-6-14 11:01:00

ARX初学请教如何设置osmode变量

<P>我写的</P>
<P>static void Baotest1test(void)<BR>&nbsp;{<BR>&nbsp;&nbsp;// Add your code for command Baotest1.test here<BR>&nbsp;&nbsp;struct resbuf cmd, os, os1 , os2;<BR>&nbsp;&nbsp;ads_real radius , dist;<BR>&nbsp;&nbsp;ads_point pt1 , pt2 , pt3 ;</P>
<P>&nbsp;&nbsp;//acedGetVar("osmode", &amp; os);<BR>&nbsp;&nbsp;cmd.restype = RTREAL;<BR>&nbsp;&nbsp;cmd.resval.rreal = 0;<BR>&nbsp;&nbsp;os.restype = RTREAL;<BR>&nbsp;&nbsp;os.resval.rreal = 0;<BR>&nbsp;&nbsp;acedSetVar("cmdecho", &amp;cmd);//(SETVAR "CMDECHO" 0)<BR>&nbsp;&nbsp;//acadErrorStatusTEXT;</P>
<P>&nbsp;&nbsp;acedGetVar("osmode", &amp;os1);<BR>&nbsp;&nbsp;os.resval.rreal = os1.resval.rreal + 16384;<BR>&nbsp;&nbsp;acedSetVar("osmode", &amp;os);//(setvar "osmode" 0)<BR>&nbsp;&nbsp;acedCommand(RTSTR , "undo" , RTSTR , "_group" , 0);//(vl-cmdf "_.undo" "_group")<BR>&nbsp;&nbsp;acedGetPoint(NULL , "\nGet Center Point :" , pt1);<BR>&nbsp;&nbsp;acedGetDist(NULL ,"\n请输入圆的半径啦靓仔:", &amp;radius);<BR>&nbsp;&nbsp;acedGetDist(NULL ,"\n请输入圆的的圆心距:", &amp;dist);<BR>&nbsp;&nbsp;acutPolar(pt1 , 0 , dist , pt2);<BR>&nbsp;&nbsp;acutPolar(pt1 , 3.14159 , dist , pt3);<BR>&nbsp;&nbsp;acedCommand(RTSTR , "circle" , RT3DPOINT , pt1 , RTREAL, radius , 0);<BR>&nbsp;&nbsp;acedCommand(RTSTR , "circle" , RT3DPOINT , pt2 , RTREAL, radius , 0);<BR>&nbsp;&nbsp;acedCommand(RTSTR , "circle" , RT3DPOINT , pt3 , RTREAL, radius , 0);</P>
<P>&nbsp;&nbsp;acedSetVar("osmode", &amp;os1);<BR>&nbsp;&nbsp;acedCommand(RTSTR , "undo" , RTSTR , "_end" , 0);<BR>&nbsp;&nbsp;//acutPrintf(&amp;os);<BR>&nbsp;&nbsp;acutPrintf("\n可以画圆的ARX写成功了! 呵呵,加油!!!");</P>
<P>&nbsp;}<BR>&nbsp;// ----- ads_setdefun001 symbol (do not rename)<BR></P>

BDYCAD 发表于 2006-6-14 11:06:00

<P>大家好! 我是用LISP转到想用ARX的初级用户.</P>
<P>&nbsp;现在上面这个小小学习用的测试程序我在编写时为了保证可以成功运行, 要把捕捉OSMODE变量设为关, 在LISP的做法是把当前osmode变量加上16384就相当关了捕捉, 可是ARX的编写要转换好多 东东, 我在书本本上找不到, 又不好意思发问, 我闷找书找的一个月找不到(VC++ 基础不好的原因) </P>
<P>还望大家在百忙中指点指点这几句怎么写才对&nbsp;</P>
<P>acedGetVar("osmode", &amp;os1);<BR>&nbsp;&nbsp;os.resval.rreal = os1.resval.rreal + 16384;<BR>&nbsp;&nbsp;acedSetVar("osmode", &amp;os);//(setvar "osmode" 0)<BR></P>
<P>谢谢!!!!!</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bdycad </P>

wzz1968 发表于 2006-6-14 15:12:00

<P>struct resbuf rb1,rb2;</P>
<P>ads_getvar("osmode",&amp;rb1);</P>
<P>rb2.restype=RTSHORT;&nbsp; //设置系统变量数据类型</P>
<P>rb2.resval.rint=(short)16438;&nbsp; //系统变量的新值.</P>
<P>ads_setvar("osmode",&amp;rb2); //设置新值.</P>
<P>二楼的程序行中缺少类型的设置.类型的设置也是错误的.</P>
<P>另外,用AUTOLISP转arx时,除数学运算、字符运算、文件操作、表处理外。其余函数基本是AUTOLISP函数加前缀ads_构成。</P>
<P>以aced前缀构成的arx库函数与其大部分是等价的。</P>
<P>&nbsp;</P>
<P>这是修改系统变量的标准过程.</P>
<P>&nbsp;</P>

BDYCAD 发表于 2006-6-15 08:41:00

谢谢楼上朋友,我试一下, 可以了,真开心.呵呵!!

BDYCAD 发表于 2006-6-16 16:14:00

<P>三楼朋友下午好!&nbsp; 再请教一下</P>
<P>struct resbuf cmd, os, os1 , os2 ;</P>
<P>ads_getvar("osmode",&amp;os1);<BR>&nbsp;&nbsp;os2.restype=RTSHORT;//设置系统变量数据类型<BR>&nbsp;&nbsp;os2.resval.rint= (short)16438;//系统变量的新值.<BR>&nbsp;&nbsp;ads_setvar("osmode",&amp;os2); //设置新值.</P>
<P>这样只把osmode变量设为 16438, 而我是想把osmode的变量设成 os1+os2的值, 不知怎么办?</P>

easypower 发表于 2006-6-17 10:01:00

<P>老朋友了,送你几个函数</P>
<P><BR>/////////////////////////////////////////////////////////////////////////////<BR>//////////////////////////// GLOBAL GETVAR FUNCTIONS ////////////////////////<BR>/////////////////////////////////////////////////////////////////////////////</P>
<P><BR>/****************************************************************************<BR>**<BR>**&nbsp; getSysVar (INT)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>getSysVar(LPCTSTR varName, int&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; if (acedGetVar(varName, &amp;rb)== RTNORM) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(rb.restype == RTSHORT);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = rb.resval.rint;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eOk);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eInvalidInput);<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; getSysVar (DOUBLE)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>getSysVar(LPCTSTR varName, double&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; if (acedGetVar(varName, &amp;rb) == RTNORM) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(rb.restype == RTREAL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = rb.resval.rreal;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eOk);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eInvalidInput);<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; getSysVar (string)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>getSysVar(LPCTSTR varName, CString&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; if (acedGetVar(varName, &amp;rb) == RTNORM) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(rb.restype == RTSTR);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = rb.resval.rstring;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free(rb.resval.rstring);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eOk);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eInvalidInput);<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; getSysVar (2D point)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>getSysVar(LPCTSTR varName, AcGePoint2d&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; if (acedGetVar(varName, &amp;rb) == RTNORM) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(rb.restype == RTPOINT);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val.set(rb.resval.rpoint, rb.resval.rpoint);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eOk);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eInvalidInput);<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; getSysVar (3D point)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>getSysVar(LPCTSTR varName, AcGePoint3d&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; if (acedGetVar(varName, &amp;rb) == RTNORM) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT(rb.restype == RT3DPOINT);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val.set(rb.resval.rpoint, rb.resval.rpoint, rb.resval.rpoint);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eOk);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return(Acad::eInvalidInput);<BR>}</P>
<P>/////////////////////////////////////////////////////////////////////////////<BR>//////////////////////////// GLOBAL SETVAR FUNCTIONS ////////////////////////<BR>/////////////////////////////////////////////////////////////////////////////</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; setSysVar(INT)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>setSysVar(LPCTSTR varName, int val)<BR>{<BR>&nbsp;&nbsp;&nbsp; ASSERT(varName != NULL);</P>
<P>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; rb.restype = RTSHORT;<BR>&nbsp;&nbsp;&nbsp; rb.resval.rint = val;</P>
<P>&nbsp;&nbsp;&nbsp; return(SdSysVarStack::setVar(varName, &amp;rb));<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; setSysVar (DOUBLE)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>setSysVar(LPCTSTR varName, double val)<BR>{<BR>&nbsp;&nbsp;&nbsp; ASSERT(varName != NULL);</P>
<P>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; rb.restype = RTREAL;<BR>&nbsp;&nbsp;&nbsp; rb.resval.rreal = val;</P>
<P>&nbsp;&nbsp;&nbsp; return(SdSysVarStack::setVar(varName, &amp;rb));<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; setSysVar (STRING)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>setSysVar(LPCTSTR varName, const char* val)<BR>{<BR>&nbsp;&nbsp;&nbsp; ASSERT(varName != NULL);</P>
<P>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; rb.restype = RTSTR;<BR>&nbsp;&nbsp;&nbsp; rb.resval.rstring = const_cast&lt;char*&gt;(val);</P>
<P>&nbsp;&nbsp;&nbsp; return(SdSysVarStack::setVar(varName, &amp;rb));<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; setSysVar (3D POINT)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>setSysVar(LPCTSTR varName, const AcGePoint3d&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; ASSERT(varName != NULL);</P>
<P>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; rb.restype = RT3DPOINT;<BR>&nbsp;&nbsp;&nbsp; copyAdsPt(rb.resval.rpoint, asDblArray(val));</P>
<P>&nbsp;&nbsp;&nbsp; return(SdSysVarStack::setVar(varName, &amp;rb));<BR>}</P>
<P>/****************************************************************************<BR>**<BR>**&nbsp; setSysVar (2D POINT)<BR>**<BR>**&nbsp; **jma<BR>**<BR>*************************************/</P>
<P>Acad::ErrorStatus<BR>setSysVar(LPCTSTR varName, const AcGePoint2d&amp; val)<BR>{<BR>&nbsp;&nbsp;&nbsp; ASSERT(varName != NULL);</P>
<P>&nbsp;&nbsp;&nbsp; resbuf rb;<BR>&nbsp;&nbsp;&nbsp; rb.restype = RTPOINT;<BR>&nbsp;&nbsp;&nbsp; copyAdsPt(rb.resval.rpoint, asDblArray(val));</P>
<P>&nbsp;&nbsp;&nbsp; return(SdSysVarStack::setVar(varName, &amp;rb));<BR>}<BR></P>

easypower 发表于 2006-6-17 10:02:00

<P>使用示例</P>
<P>&nbsp;&nbsp;setSysVar("LIMCHECK", 1);<BR>&nbsp;&nbsp;setSysVar("LIMMAX", AcGePoint2d(WorkLength,0));<BR>&nbsp;&nbsp;setSysVar("LIMMIN", AcGePoint2d(0,0 - WorkWidth));<BR>&nbsp;&nbsp;setSysVar("ISAVEBAK", 0);</P>

easypower 发表于 2006-6-17 10:03:00

具体要设置全局变量,请查阅《AutoCAD2000ARX开发技术.pdf》书的附录,有很详细的说明

wzz1968 发表于 2006-6-19 08:25:00

<P>回答5楼:</P>
<P>" 这样只把osmode变量设为 16438, 而我是想把osmode的变量设成 os1+os2的值, 不知怎么办?"</P>
<P>struct resbuf 0s1,0s2;</P>
<P>ads_getvar("osmode",&amp;os1);</P>
<P>os2.restype=RTSHORT;</P>
<P>os2.resval.rint=(short)(os1.resval.rint | 14638);</P>
<P>ads_setvar("osmode",&amp;os2);</P>
<P>上行用位操作而不用加操作的原因是加法操作可能引起进位,影响下位的设置.</P>
<P>&nbsp;</P>
<P>&nbsp;</P>

lionguns 发表于 2016-1-8 10:59:06

看看
页: [1]
查看完整版本: ARX初学请教如何设置osmode变量