Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to list all of loaded lisps in Autocad?

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
aqdam1978
3598 Views, 17 Replies

how to list all of loaded lisps in Autocad?

Hi,

 

I want to list all of loaded lisp programs in AutoCAD (both .lsp and .fas)

 

It's easy for .ARX files:

 

(vlax-safearray->list (vlax-variant-value (vlax-invoke-method (vlax-get-acad-object) 'listarx)))

 

But I don't have any idea for lisp programs, does anybody knows how can I do that?

 

Thanks,

Abbas

17 REPLIES 17
Message 2 of 18
alanjt_
in reply to: aqdam1978

Doesn't count subroutines: 

 

(vl-remove-if-not (function (lambda (x) (wcmatch x "C:*"))) (atoms-family 1))

 

Message 3 of 18
aqdam1978
in reply to: alanjt_

Hi alanjt_

 

Thanks for your code, But I loaded a lisp program and your code could not detect it.

😞

 

Message 4 of 18
BlackBox_
in reply to: aqdam1978


@aqdam1978 wrote:

 

I want to list all of loaded lisp programs in AutoCAD (both .lsp and .fas)


Beyond what Alan has already offered, I'm not sure that the LISP API has the ability to do this... Without some sort of custom .NET LispFunction Method (I'm looking into that now).

 

Also, as an alternative to this:


@aqdam1978 wrote:

 

It's easy for .ARX files:

 

(vlax-safearray->list (vlax-variant-value (vlax-invoke-method (vlax-get-acad-object) 'listarx)))

 

... You could simply use:

(arx)

 

** Note that (arx) returns all .ARX, and .DBX assemblies... For .NET assemblies, you can also try my DLL .NET LispFunction.



"How we think determines what we do, and what we do determines what we get."

Message 5 of 18
alanjt_
in reply to: aqdam1978


@aqdam1978 wrote:

Hi alanjt_

 

Thanks for your code, But I loaded a lisp program and your code could not detect it.

😞

 


At first glance, it works for me.

 

What're you trying to accomplish?

Message 6 of 18
BlackBox_
in reply to: alanjt_


@alanjt_ wrote:

@aqdam1978 wrote:

Hi alanjt_

 

Thanks for your code, But I loaded a lisp program and your code could not detect it.

😞

 


At first glance, it works for me.

 

What're you trying to accomplish?


1+... Works for me (for my loaded C: prefixed functions).



"How we think determines what we do, and what we do determines what we get."

Message 7 of 18
alanjt_
in reply to: BlackBox_

Has always worked for me. That's how I protect my subroutines. I filter the atoms-family list by "AT:*" and protect the leftovers.

Message 8 of 18
hmsilva
in reply to: alanjt_


@alanjt_ wrote:

Has always worked for me. That's how I protect my subroutines. I filter the atoms-family list by "AT:*" and protect the leftovers.


Always worked for me too!

 

Henrique

EESignature

Message 9 of 18
BlackBox_
in reply to: alanjt_

Hooray - Pragma!

 

Boo - Autodesk Online [not-so-much-] Help!

 

adn.beta.2014.help.search.fail0930.png

 

 

* Wonders if this post will now show up as part of the 'Autodesk Web Results' * 

 

#WishfulThinking



"How we think determines what we do, and what we do determines what we get."

Message 10 of 18
aqdam1978
in reply to: hmsilva

Hi Henrique,

 

Please try my lisp code in attachement.

I cant find my lisp code using Alan's code!

 

Thanks,

Abbas

 

Message 11 of 18
hmsilva
in reply to: aqdam1978

Abbas,

case sensitive...

 

_$ (vl-remove-if-not (function (lambda (x) (wcmatch x "GETLOC*"))) (atoms-family 1))
("GETLOCALEID")
_$ 

 

Cheers

Henrique

EESignature

Message 12 of 18
alanjt_
in reply to: hmsilva

@OP, are you just trying to see if the routine is loaded?

 

If so, just use: (and GetLocaleID)

Message 13 of 18
alanjt_
in reply to: alanjt_

or: (member "GETLOCALID" (atoms-family 1))

 

but the first is much less processiing and all you need. 

Message 14 of 18
alanjt_
in reply to: alanjt_

This is why it's also important to let us know what you are wanting this data for. We might have a beter solution.

Message 15 of 18
aqdam1978
in reply to: alanjt_

Hi Alan,

 

Thanks for your good ideas,

All I am looking for is to find a solution to make a list for all .lsp/.fas loaded in AutoCAD.

I am beginner in Lisp and  I don't know is it possible via lisp or not!

 

Thanks

Abbas

 

 

Message 16 of 18
alanjt_
in reply to: aqdam1978

@aqdam1978 wrote:

Hi Alan,

 

Thanks for your good ideas,

All I am looking for is to find a solution to make a list for all .lsp/.fas loaded in AutoCAD.

I am beginner in Lisp and  I don't know is it possible via lisp or not!

 

Thanks

Abbas

 

 


No worries. (atoms-family-1) is going to be your best option. Out of curiousity, why do you need a list of loaded LSP/FAS files?

Message 17 of 18
aqdam1978
in reply to: alanjt_

Hi Alan,

 

As I told you, I am beginner and would like to learn about lisp programming.

So, I just exploring AutoLISP and AutoCAD!

 

Thanks for your good information.

 

Abbas

(defun C:listLSP ( / lst L i S fl fn)
;---------------------------
;(setq lst CORE-SYMBOL-LIST)
;(setq lst COM-SYMBOL-LIST)
(setq lst (vl-remove-if-not (function (lambda (x) (wcmatch x "C:*"))) (atoms-family 1)))
;---------------------------
(setq fl (open (setq fn "List.txt") "w" ))
(setq lst (vl-sort lst '<) L (length lst) i 0 S "")
(repeat L
	(write-line (nth i lst) fl)
	(setq i (1+ i))
);repeat
(close fl)
(startapp "notepad" fn)
);

 

Message 18 of 18
alanjt_
in reply to: aqdam1978


@aqdam1978 wrote:

Hi Alan,

 

As I told you, I am beginner and would like to learn about lisp programming.

So, I just exploring AutoLISP and AutoCAD!

 

Thanks for your good information.

 

Abbas

(defun C:listLSP ( / lst L i S fl fn)
;---------------------------
;(setq lst CORE-SYMBOL-LIST)
;(setq lst COM-SYMBOL-LIST)
(setq lst (vl-remove-if-not (function (lambda (x) (wcmatch x "C:*"))) (atoms-family 1)))
;---------------------------
(setq fl (open (setq fn "List.txt") "w" ))
(setq lst (vl-sort lst '<) L (length lst) i 0 S "")
(repeat L
	(write-line (nth i lst) fl)
	(setq i (1+ i))
);repeat
(close fl)
(startapp "notepad" fn)
);

 


Looking good so far. Keep in mind, when stepping through a list, use mapcar + lambda or foreach (depending on your desired return). For this, I'd use foreach, since you don't care about a return list.

 

eg.

(defun c:Test (/ lst file fOpen)
  (if (and (setq lst (vl-remove-if-not (function (lambda (x) (wcmatch x "C:*"))) (atoms-family 1)))
           (setq fOpen (open (setq file "c:\\List.txt") "W"))
      )
    (progn

      (foreach item (vl-sort lst '<)
        (write-line item fOpen)
      )

      (close fOpen)
      (startapp "NOTEPAD" file)
    )
  )
  (princ)
)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

State of Sustainability Webinar


AutoCAD Inside the Factory