Lista das lisps carregadas no AutoCAD

A muito tempo atrás, numa galáxia muito distante, houve uma discussão no finado www.autolisp.com.br, sobre como obter uma lista das lisps carregadas no autocad…

Bem, naquela época, cheguei a postar um pequeno programa em ObjectARX na página.

O programa era este aqui:


//-----------------------------loadedlist.cpp-------------------------
#if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
#error _DEBUG should not be defined except in internal Adesk debug builds
#endif

#include "aced.h"
#include "tchar.h"
#include "acdocman.h"
#include "adslib.h"


#define ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))

struct func_entry
{ TCHAR *func_name; int (*func) (struct resbuf *); };

/* Here we declare the functions that handle the calls; */
int LoadedList (struct resbuf *rb);

/* Here we define the array of function names and handlers. */
static struct func_entry func_table[] = { {_T("LoadedLispList"), LoadedList},};

/* To add more functions to this table, just put them in the list, after
declaring the function names. Note that in standard C it's all right to
have a superfluous comma after the last item. */

/* Declarations of other local functions */
int dofun (void);
int funcload (void);


extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
{
switch(msg) {
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(appId);
acrxDynamicLinker->registerAppMDIAware(appId);
break;
case AcRx::kInvkSubrMsg:
dofun();
break;
case AcRx::kLoadDwgMsg:
funcload(); }
return AcRx::kRetOK;
}


static int funcload()
{
int i;
for (i = 0; i < ELEMENTS(func_table); i++)
{
if (!acedDefun(func_table[i].func_name, (short)i))
return RTERROR; }
return RTNORM; }

/*-----------------------------------------------------------------------*/
/* DOFUN -- Execute external function (called upon an RQSUBR request).
Return value from the function executed, RTNORM or RTERROR. */

static int dofun()
{
struct resbuf *rb;
int val;
/* Get the function code and check that it's within range.
(It can't fail to be, but paranoia doesn't hurt.) */
if ((val = acedGetFunCode()) < 0 || val >= ELEMENTS(func_table)) {
acdbFail(_T(/*MSG2*/"Received nonexistent function code."));
return RTERROR; }
/* Fetch the arguments, if any. */
rb = acedGetArgs();

/* Call the handler and return its success-failure status. */
val = (*func_table[val].func)(rb);
acutRelRb(rb);
return val;
}

static int LoadedList(struct resbuf *rb)
{
AcApDocument* ActiveDoc = acDocManager->curDocument();
struct resbuf *resultlist, *rover;
resultlist = rover = acutNewRb(RTLB);
for (int i=0; iGetCountOfLispList(); i++)
{
AcLispAppInfo* appInfo = ActiveDoc->GetItemOfLispList(i);
if (appInfo)
{
rover->rbnext = acutNewRb(RTSTR);
rover = rover->rbnext;
rover->resval.rstring = appInfo->appFileName; }}
rover->rbnext = acutNewRb(RTLE);
rover = rover->rbnext;
rover->rbnext = NULL;
acedRetList(resultlist);
return RTNORM;
}
//-----------------------eof---loadedlist.cpp---------------------------

Bom, se você quiser compilar, terá de baixar o Visual Studio e também o ObjectARX Cuidado para os pré requisitos das versões do ObjectARX.

Eu compilei aqui para o versão 2012 do AutoCAD (VS2010).

Para usar é simples:
Carregue o programa com o APPLOAD, e escolha a versão correta (32 ou 64 bits)

Digite:
 (LoadedLispLisp)
e você terá algo assim:

("C:program filesautodeskautocad civil 3d 2012expressacetutil.fas" 
"C:program filesautodeskautocad civil 3d 2012expressacetauto.LSP"
"C:program filesautodeskautocad civil 3d 2012expressacettest.fas"
"C:program filesautodeskautocad civil 3d 2012supportacad2012.LSP"
"C:program filesautodeskautocad civil 3d 2012supportacad2012doc.LSP"
"C:UsersNeytonappdataroamingautodeskc3d
2012enusupportcivil.mnl")
 

Bacana, não?

Deixe um comentário

Carrinho de compras
Rolar para cima