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

  • 相关阅读:
    【BZOJ】2729: [HNOI2012]排队
    【BZOJ】2734: [HNOI2012]集合选数
    【BZOJ】3573: [Hnoi2014]米特运输
    【BZOJ】4008: [HNOI2015]亚瑟王
    【BZOJ】[HNOI2015]菜肴制作
    数论六·模线性方程组
    数论五·欧拉函数
    黄金矿工
    数论四·扩展欧几里德
    数论三·约瑟夫问题
  • 原文地址:https://www.cnblogs.com/dianziguan/p/14717758.html
Copyright © 2011-2022 走看看