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

Running Lisp in Lisp

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1261 Views, 9 Replies

Running Lisp in Lisp

Hi All,

 

I have a stupid quesiton. I just learned that you can run a lisp function in a lisp function entering (c:someLispFunction). This is useful but I was wondering if you can add preset key words for the getkword function. I tried to run overkill in this fashion but I can't figure out how to automat the user input sections of the routine. Is there a way to do this? If so please let me know and BTW you guru's on this forum rock!

9 REPLIES 9
Message 2 of 10
scot-65
in reply to: Anonymous


@Anonymous wrote:

Hi All,

 

I have a stupid quesiton. I just learned that you can run a lisp function in a lisp function entering (c:someLispFunction). This is useful but I was wondering if you can add preset key words for the getkword function. I tried to run overkill in this fashion but I can't figure out how to automat the user input sections of the routine. Is there a way to do this? If so please let me know and BTW you guru's on this forum rock!


No questions are stupid. Young ones need to learn and old ones tend to forget.

 

Look into INITGET and it's flags.

 

Perhaps something like this?

 

(initget "Left Right Center")

(setq a (getkword "Enter justification [Left/Right/Center]<Center>: "))

(if (not a) (setq a "Center") );if

(cond

 ( (= a "Left") (princ) )

 ( (= a "Right") (princ) )

 (T (princ) )

);cond

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 10
Anonymous
in reply to: scot-65

Perhaps. I'll give this a try. Thanks.

Message 4 of 10
Anonymous
in reply to: Anonymous

I think what the OP was asking for was how to use a lisp command as a lisp function without having to make it a lisp function.  There are a couple of ways to do this.  The most correct would be to use vlax-add-cmd to actually add your command to the built-in command set.  Another somewhat simpler (albeit fairly hokey) method is to use vla-SendCommand.  This basically writes a string to the command line in much the same way that a macro is done.  Below is a basic set of commands that demonstrate how to do it.  If you are farily new to lisp I would recommend starting with this method before going to the vlax-add-cmd method.

 

(defun c:test31 ( / val)
  (initget 1)
  (setq val (getint "\nSpecify number: "))
  (alert (strcat "The specified number is " (itoa val) ". "))
  (princ)
  )

(defun c:test32 ( / )
  ;(c:test31)
  (vla-SendCommand (vla-get-ActiveDocument (vlax-get-acad-object)) "test31 2 ")
  (princ)
  )

Message 5 of 10
Anonymous
in reply to: Anonymous

I did not know about vla-sendCommand function. What I'm trying to do is add the effect of overkill to a lisp I'm trying to form, but I want to use predefined variables in the lisp so overkill runs in the background, no user input necessary. I would also like to do this without hacking a copyrighted lisp. Hench the delicate dance around to just run it in the lisp instead of chopping overkill up. Thanks guys for your help.
Message 6 of 10
Anonymous
in reply to: Anonymous

Overkill is already part of the built-in command set so you can just run it with the (command function.  You will need to use the manual entry version to avoid dialogue boxes.  If you already have a selection set of objects to run overkill on you can do

(command ".-overkill" ss "" "done")  If you step through the command manually you will see how to add items to change the tolerance, ignore parts, and etc.  For example

(command ".-overkill" ss "" "tolerance" 0.0001 "" "done")

 

Message 7 of 10
Anonymous
in reply to: Anonymous

I'm using CAD 2011 and overkill is still just a lisp routine in the express tools. So the .-overkill isn't recognized. I'm trying to work around this. Thanks for your help though.
Message 8 of 10
Anonymous
in reply to: Anonymous

I believe the express tools for 2011 include a lisp file called overkillsup.lsp which is a lisp function allowing programtic input of variables to run the function within other lisp routines.  You might try that out.

 

An excerpt from the file is below

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; over-kill - delete overlaping and un-needed entities
;; Takes single list of arguments:
;;  ss           - selection set
;;  fuz          - for numeric comparisons
;;  ignore       - (optional) list of group codes specifying which common group codes to ignore
;;                 when comparing entities.
;;  no-plines    - (optional) flag - T means do NOT optimize segments within plines.
;;  no-partial   - (optional) flag - T means do NOT combine parallel segments that partially overlap
;;  no-endtoend  - (optional) flag - T means do NOT combine parallel segments that are end to end.
;;
(defun acet-overkill2 ( alst / lst ss fuz ignore no-plines no-partial no-EndtoEnd

Message 9 of 10
Anonymous
in reply to: Anonymous

Hmmm..... I'll look into this. Thanks. 🙂
Message 10 of 10
Anonymous
in reply to: Anonymous

Thanks a bunch! This is what I was looking for. I did a google search for overkillsup and it brought me to an older post that explained exactly what I was wanting to do. Here's the link for those who need it:

http://forums.autodesk.com/t5/AutoCAD-Express-Tools/How-do-I-call-Overkill-in-a-lisp-function/td-p/2...

Again Thanks A Bunch!

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report