首页 > 其他 > 详细

ObjectARX调用LISP方法(含参数传递)返回值

时间:2020-03-07 21:01:46      阅读:169      评论:0      收藏:0      [点我收藏+]

ObjectARX调用LISP方法(含参数传递)返回值

//acrxEntryPoint.cpp

void Test()
{
struct resbuf *ptList,*ptResult=NULL;
//注意,一定要写成_T(“c:lisp_test”),写成”c:lisp_test”调用会失败
double dx=135.6;
double dy=147.5;
ptList=acutBuildList(RTSTR,_T(“c:lisp_test”),RTREAL,dx,RTREAL,dy,RTNONE);
int rc=acedInvoke(ptList,&ptResult);
if(rc!=RTNORM)
{
acutPrintf(_T(“\r\n调用LISP失败,请检查依赖的LISP是否加载”));
acutRelRb(ptList);
return;
}
acutRelRb(ptList);
if(ptResult==NULL)
{
acutPrintf(_T(“\r\n调用LISP失败,返回空值”));
return;
}
if(ptResult->restype!=RTSTR)
{
acutPrintf(_T(“\r\n调用LISP失败,返回错误的值类型”));
acutRelRb(ptResult);
return;
}
CString strRC=ptResult->resval.rstring;
acutRelRb(ptResult);
acutPrintf(_T(“\r\n返回值:%s”),strRC);
}
//—————————————————————————–
//—– ObjectARX EntryPoint
class CInvokeLispTestApp : public AcRxArxApp {

public:
CInvokeLispTestApp () : AcRxArxApp () {}

virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// TODO: Load dependencies here

// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
acedRegCmds->addCommand(_T(“InvokeLispTestApp”),_T(“Test”),_T(“Test”),0,Test);

// TODO: Add your initialization code here

return (retCode) ;
}

virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
// TODO: Add your code here

// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

// TODO: Unload dependencies here
acedRegCmds->removeGroup(_T(“InvokeLispTestApp”));

return (retCode) ;
}

virtual void RegisterServerComponents () {
}

} ;

//—————————————————————————–
IMPLEMENT_ARX_ENTRYPOINT(CInvokeLispTestApp)

 

//InvokeLispTest.lsp

;;定义函数lisp_test
;;函数有两个参数x,y
;;函数名必须写成c:xx否则ARX无法调用
(defun c:lisp_test(x y)
;;将X转换成字符串
(setq strX(rtos x 2 10))
;;将Y转换成字符串
(setq strY(rtos y 2 10))
;;将X,Y转换的字符串合并起来,并返回给ARX函数
;;返回给ARX调用
;;LISP最后一个运算的返回值做为函数的返回值
(setq strXY(strcat strX “|” strY))
)

ObjectARX调用LISP方法(含参数传递)返回值

原文:https://www.cnblogs.com/mjgw/p/12436776.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!