• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Distinguished Contributor
    421232206
    Posts: 140
    Registered: ‎10-21-2010

    how to run lisp fuction with arguments in ARX?

    220 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".

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎07-25-2012

    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?

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    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

    Please use plain text.
    Distinguished Contributor
    421232206
    Posts: 140
    Registered: ‎10-21-2010

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

     

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    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

    Please use plain text.