How C++/Lisp funcitons call each other?
1 virtual AcRx::AppRetCode On_kLoadDwgMsg (void *pkt) {
2 AcRx::AppRetCode retCode =AcRxDbxApp::On_kLoadDwgMsg (pkt) ;
3
4 // Reg function for Lisp
5 acedDefun(_T(/*MSG0*/"lisp_call_arxfunction"), 1);
6 acedRegFunc(LispCallArxFunction, 1);
7
8 // Reg Lisp Functions
9 if (RegLispFunc(_T("c:arx_call_lisp")) == true)
10 {
11 MessageBox(NULL, _T("Successfully"), _T("Register Lisp Function"), 1);
12 }
13
14 return (retCode) ;
15 }
16
17 bool RegLispFunc(const TCHAR* funcname)
18 {
19 if (acDocManager->documentCount() == 0)
20 return false;
21
22 bool ret = false;
23 resbuf* rb = NULL;
24 CString cmd;
25 CString temp = _T(/*MSG0*/"(vl-acad-defun '%s)");
26 cmd.Format( temp, funcname );
27
28 struct resbuf* pFuncCall = acutBuildList( RTSTR, _T(/*MSG0*/"veval-str+"),
29 RTSTR, cmd,
30 0 );
31 if( RTNORM == acedInvoke(pFuncCall, &rb) )
32 ret = true;
33
34 if( pFuncCall )
35 acutRelRb(pFuncCall);
36 if( rb )
37 acutRelRb(rb);
38
39 return ret;
40 }
41
42 // Use lisp functions
43 int GetAcadVersion()
44 {
45 int iVersion = 0;
46 if( acDocManager->documentCount() == 0 )
47 return false;
48
49 struct resbuf* pResult = NULL;
50 struct resbuf* pFuncCall = acutBuildList( RTSTR, _T(/*MSG0*/"c:arx_call_lisp"), 0 ); // call c:arx_call_lisp function which defined in Lisp Code
51 if (pFuncCall != NULL)
52 {
53 if(acedInvoke(pFuncCall, &pResult) == RTNORM)
54 {
55 if (pResult->restype = AcDb::kDxfInt32 )
56 {
57 iVersion = pResult->resval.rint;
58 }
59
60 }
61 }
62
63 if( pFuncCall )
64 acutRelRb(pFuncCall);
65 if( pResult )
66 acutRelRb(pResult);
67
68 return iVersion;
69 }