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!
Solved! Go to Solution.
@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.
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)
)
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")
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
Can't find what you're looking for? Ask the community or share your knowledge.