zoukankan      html  css  js  c++  java
  • ObjectARX调用LISP方法(含参数传递)返回值

    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(“ 调用LISP失败,请检查依赖的LISP是否加载”));
    acutRelRb(ptList);
    return;
    }
    acutRelRb(ptList);
    if(ptResult==NULL)
    {
    acutPrintf(_T(“ 调用LISP失败,返回空值”));
    return;
    }
    if(ptResult->restype!=RTSTR)
    {
    acutPrintf(_T(“ 调用LISP失败,返回错误的值类型”));
    acutRelRb(ptResult);
    return;
    }
    CString strRC=ptResult->resval.rstring;
    acutRelRb(ptResult);
    acutPrintf(_T(“ 返回值:%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))
    )

  • 相关阅读:
    vim 多窗口编辑
    opengl笔记——旋转,一段代码的理解
    用条件变量实现事件等待器的正确与错误做法
    opengl笔记—— glMultMatrixf() 区别 glLoadMatrixf()
    Mule与其它web应用服务器的区别
    海量数据相似度计算之simhash短文本查找
    关于协方差矩阵的理解
    C++ STL中的常用容器浅谈
    唐-诗:《枫桥夜泊》
    唐-诗:《肚桑干》
  • 原文地址:https://www.cnblogs.com/mjgw/p/12436776.html
Copyright © 2011-2022 走看看