I want to load a lisp then run the c:CT inside it.
This didn't work.
(defun c:CHT()(load "CHTEXT.LSP") (command "CT"))
This code i want to be inside my acad.lsp so i press the CHT it will load and run the defun.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Not sure whats goin on inside chtext.lsp
(defun c:CHT()
(load "CHTEXT.LSP")
);defun
now anytime you type cht at command prompt chtext.lsp should load
You could also place chtext.lsp code inside of defined function CHT
@Anonymous wrote:I want to load a lisp then run the c:CT inside it.
This didn't work.
(defun c:CHT()(load "CHTEXT.LSP") (command "CT"))
This code i want to be inside my acad.lsp so i press the CHT it will load and run the defun.
The CHTEXT.lsp that I've had for years doesn't have a CT command in it, but it does have a CHT command, which is just a shortcut for the longer CHTEXT command name in there that I can also use. But even if you get the H back in there, the way you have it, every time you type CHT would make it load the Lisp file again. You can avoid that with this line:
(autoload "chtext" '("cht" "chtext"))
in your ACADDOC.lsp file. That "warns" AutoCAD of the possible command names in the file, but doesn't actually load the Lisp file unless and until someone calls for one of those commands. Because the definition of CHT is inside that file, and not separate involving a (load) function, calling for CHT does not cause the file to be loaded except only the first time it's used.
Yea, i went into the chtext.lsp and renamed it to ct in the hopes it wouldn't conflict with cht.
Normally I have this in my lisp file, but decided to take it out since it was not mine, and to keep the code down in size. The autoload might be better but I don't use cht all the time. I would rather find a method to load and execute each time i use. Seems like there was a way to do that at one time. Can i put a startup inside the chtext.lsp?
@Anonymous wrote:Yea, i went into the chtext.lsp and renamed it to ct in the hopes it wouldn't conflict with cht.
.... I would rather find a method to load and execute each time i use.....
Well, it seems to me the (autoload) approach is still good if you "don't use CHT all the time," because it doesn't load the file unless you do call for it, so it's not burdening anything. But if you really want to do it the load-every-time way, it's just occurred to me [I don't have this in mind generally, because I don't usually do this kind of thing] that the (command) function only recognized actual AutoCAD command names. To call for a (defun)'d command name in a Lisp routine, you need to do it this way:
(defun c:CHT () (load "CHTEXT") (C:CT))
And once you've done that, you'd be better off just typing CT to use the command, rather than CHT again. That would at least let it avoid loading the file again every time.
[By the way, Help for (load) says not to include the file-type extension, though it doesn't outright say it won't work if you do.]
I would also recommend using verbose command names, which can then be mapped to 1/2/3 character shortcuts via the PGP. You run out of useable commands *really* quickly otherwise and start running into problems of "Why doesn't my PGP work?" (LSP overrides PGP settings) "I modified the function but theres no change" (same function defined elsewhere with last-loaded winning) or "What does this function XHT do again...?" (c:ExtraHeavyTracing is a little easier to understand)
This should work.
The keystroke is defined when AutoCAD starts, and when first typed, the
program is then loaded and the keystroke is redefined via the loaded program.
No need to type two different commands to get started.
(defun c:CT () (load "CHTEXT") (c:CT) ) ;add brief description of program here.
This geometry was the preferred method when the computers had a yellow
"Turbo" button on the case, and the digital display went from 33 to 50 (mhz).
To have 8 mb RAM installed cost an additional $4000USD.
As others have mentioned, keep an eye on the PGP declarations as it might get a little messy.
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.