Jump to content

LISP calling another LISP


Rooster

Recommended Posts

I'm struggling to get my LISP to call & run another LISP (actually, it's a .vlx file). Here's the relevant bit of code:

 

(LOAD "SPL2PL")

(COMMAND "SPL2PL" "ALL" "" "0.1")

 

And here's my error message:

 

[DS> Another Freebee from http://www.dotsoft.com loaded, type SPL2PL to

run!SPL2PL Unknown command "SPL2PL". Press F1 for help.]

 

I'm confused.....

Link to comment
Share on other sites

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    12

  • Rooster

    8

  • Commandobill

    6

  • alanjt

    3

done that - same message again, no reference to load being successful or not....

 

is it because it's a .vlx file rather than a .lsp? or should that not make a difference?

Link to comment
Share on other sites

is it because it's a .vlx file rather than a .lsp? or should that not make a difference?

 

I wouldn't have thought it'd make a difference... I shall experiment :P

Link to comment
Share on other sites

I'm not sure why your getting that error. As far as passing those arguments in know you can pass a selection set to a lisp like so...

 

  
 (sssetfirst nil (ssget "X" '((0 . "SPLINE"))))
 (C:SPL2PL)

 

That is of course if that is what you meant by "all"

Link to comment
Share on other sites

I'm not sure why your getting that error. As far as passing those arguments in know you can pass a selection set to a lisp like so...

 

  
 (sssetfirst nil (ssget "X" '((0 . "SPLINE"))))
 (C:SPL2PL)

That is of course if that is what you meant by "all"

 

Nice idea, but I think that would depend upon how the LISP is engineered, I think that would only work if the LISP had an ssgetfirst call to start.

Link to comment
Share on other sites

I dont believe thats necessarily true. It works with burst. As long as the lisp is looking for a selection set it should work. as far as the '.01' I'm not sure how you would pass that argument

Link to comment
Share on other sites

Just tested your theory, and yes, I've got to admit, you were right on this one o:)

 

(defun c:test ()
 (if (ssget)
   (alert "CommandoBill was right!")
   (alert "CommandoBill was wrong!"))
 (princ))

 

^^ code used to test theory.

Link to comment
Share on other sites

Just tested your theory, and yes, I've got to admit, you were right on this one o:)

 

(defun c:test ()
 (if (ssget)
   (alert "CommandoBill was right!")
   (alert "CommandoBill was wrong!"))
 (princ))

^^ code used to test theory.

 

Ahahahaha :P

Link to comment
Share on other sites

untested, but this should work:

(defun c:TEST (/)
 (or c:SPL2PL (load "SPL2PL"))
 (vla-sendcommand
   (vla-get-activedocument
     (vlax-get-acad-object)
   ) ;_ vla-get-activedocument
   "SPL2PL all  0.1 "
 ) ;_ vla-sendcommand
 (princ)
) ;_ defun

Link to comment
Share on other sites

I'm still struggling to get my LISP to call & run other LISPS. Below is a simple LISP that someone on here helped me with - it just filters text by style. When I try and call this LISP from another LISP I get an 'unknown command' error. How do I do it??!! aaargh!

 

;FILTER TEXT BY STYLE
(defun c:fts(/ cSet)

 (setq cSet(ssget
              '((0 . "TEXT,MTEXT")(7 . "Standard"))
            ); end ssget
); end setq
 
 (if cSet
   (progn
     (princ(strcat "\n" (itoa(sslength cSet)) " found."))
     (sssetfirst nil cSet)
     ); end progn
    (princ "\nNothing found. ")
   ); end if
 (princ)
 ); end of c:fts

Link to comment
Share on other sites

All this function is doing is calling another function and sending a selection set to it. Give it a shot. Make sure you change the "c:\\fts.lsp" to the correct location and file name of the lisp

 

(defun c:run ()
 (load "c:\\fts.lsp" "Load Failed");change to have the name and location of the lisp
 (sssetfirst nil (ssget))
 (c:fts)
 )

Link to comment
Share on other sites

Something like this?

 

(defun c:fts  (/ cSet)
 (if (setq cSet (ssget '((0 . "*TEXT") (7 . "Standard"))))
   (progn
     (princ (strcat "\n" (rtos (sslength cSet) 2 0) " found."))
     (sssetfirst nil cSet))
   (princ "\n<< Nothing found >>"))
 (princ))

(defun c:test ()
 (c:fts)
 (princ))

 

 

EDIT: Beat me to it by seconds...

Link to comment
Share on other sites

Something like this?

 

(defun c:fts  (/ cSet)
 (if (setq cSet (ssget '((0 . "*TEXT") (7 . "Standard"))))
   (progn
     (princ (strcat "\n" (rtos (sslength cSet) 2 0) " found."))
     (sssetfirst nil cSet))
   (princ "\n<< Nothing found >>"))
 (princ))

(defun c:test ()
 (c:fts)
 (princ))

 

 

EDIT: Beat me to it by seconds...

 

so using this way would be like creating a sub-function within the lisp, right? the fts lisp that i already have is already automatically loaded into every new drawing. if i was using it on its own (ie. not through another lisp) i would just type 'fts' at the commandline and off we go. can i not do something similar when using it within another lisp? i also have quite a few other small simple lisps like the fts one that i also want to use within this lisp, so i don't really want dozens of sub-functions if i can help it. i still can't get what you've coded above to work anyway - same old error: unknown command..... :(

Link to comment
Share on other sites

The fts still remains independent, and can be called on its own, and the "test" LISP is just calling it:

 

(c:fts)

 

It all works fine for me, which command is it saying is unknown?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...