ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ObjectARX调用LISP方法

2021-04-29 14:35:59  阅读:498  来源: 互联网

标签:调用 return LISP ptList here ptResult ObjectARX


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

发表于2014 年 3 月 31 日boitboy

//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))
)

标签:调用,return,LISP,ptList,here,ptResult,ObjectARX
来源: https://www.cnblogs.com/dianziguan/p/14717758.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有