ObjectARX

ObjectARX

Reply
Distinguished Contributor
421232206
Posts: 164
Registered: ‎10-21-2010
Message 1 of 5 (461 Views)

how to run lisp fuction with arguments in ARX?

461 Views, 4 Replies
11-22-2012 06:02 AM

as we know, there is a lisp command "flatten" in the CAD express tool, and I want to execute "flatten" in my ARX application, I searched the internet and found the following code:

 

resbuf *rb_in = acutBuildList(RTSTR,"c:flatten",RTNONE);
resbuf *rb_out = NULL;
int rc = acedInvoke(rb_in,&rb_out);
acutRelRb(rb_in);
acutRelRb(rb_out);

 

this works, but i can not add arguments like this,

resbuf *rb_in = acutBuildList(RTSTR,_T("c:flatten"),RTPICKS,ssName,RTNONE);

the comand line returns "too many arguments".

Technology change world! Coding change technology! We coders are coding!
Contributor
oliver253m
Posts: 16
Registered: ‎07-25-2012
Message 2 of 5 (444 Views)

Re: how to run lisp fuction with arguments in ARX?

11-22-2012 04:11 PM in reply to: 421232206

c:flatten does not accept any parameters, it will prompt for the selection set and hidden line removal and pass it on to acet-flatn; I'm not sure there is any way to do what you need with acedInvoke. Perhaps you could define an AutoLISP function, that would accept the selection set as a parameter and call acet-flatn with it?

Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 3 of 5 (434 Views)

Re: how to run lisp fuction with arguments in ARX?

11-23-2012 01:03 AM in reply to: oliver253m

oliver253m wrote:

...I'm not sure there is any way to do what you need with acedInvoke...


With help of acedInvoke can be calling next types of lisp-functions:

a) functions with C: prefix

b) functions registered with (vl-acad-defun 'function_name)

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Distinguished Contributor
421232206
Posts: 164
Registered: ‎10-21-2010
Message 4 of 5 (415 Views)

Re: how to run lisp fuction with arguments in ARX?

11-24-2012 07:27 AM in reply to: Alexander.Rivilis

thanks a lot, I tested my code on Acad2008 according your advice,but failed.

can you do me a favor ?  what's wrong with my following code?

 

first, I modified the lisp file "FlattenSup.lsp" (in the attachment), I added "(vl-acad-defun 'acet-flatn)" in the end.

secondly,I write the following code in VS2005 with objectArx2008.

        AcDbObjectId idNew = Acad_System::cloneObjects(idSpline);
        ads_name ent;
        if (Acad::eOk != acdbGetAdsName(ent,idNew))
        {
            return AcDbObjectId::kNull;
        }
        ads_name ssName;
        ads_ssadd(NULL,NULL,ssName);
        ads_ssadd(ent,ssName,ssName);

        ads_name entLast,entNew;
        ads_entlast(entLast);

        
        resbuf *rb_in = acutBuildList(RTSTR,_T("acet-flatn"),RTPICKS,ssName,RTSHORT,0,RTNONE);
        resbuf *rb_out = NULL;
        int es = acedInvoke(rb_in,&rb_out);
        acutPrintf(_T("\n%d"),es);//I am not sure here, why it always returns RTERROR.
        acutRelRb(rb_in);
        acutRelRb(rb_out);
        ads_ssfree(ssName);
        ads_entlast(entNew);
        //Acad_System::smileyfrustrated:endCommand(_T("no "));
        if (ads_name_equal(entLast,entNew))
        {
        //    ads_entdel(ent);
            return AcDbObjectId::kNull;
        }

        return AcDbObjectId(aname(entNew));

 

Technology change world! Coding change technology! We coders are coding!
Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 5 of 5 (399 Views)

Re: how to run lisp fuction with arguments in ARX?

11-25-2012 02:55 PM in reply to: 421232206

1. I hope your's code is calling from document context.

2. I hope this version of flattensup.lsp was loaded before you call acedInvoke

Other way is calling undocumented function acedEvaluateLisp():

int __cdecl acedEvaluateLisp(wchar_t const *str, struct resbuf *&result);

where str is a lisp-expression, and result is a result of evaluation of this lisp-expression


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.