I am in the process of writing a small program to go in, delete 4 layers that aren't needed. Then using a command that is in another package of commands that end with .FAS, I will use this command to select everything, and turn it all gray (COLOR:252). The first part works perfectly.
(command ".laydel" "n" "s-grid" "n" "a-anno-dims" "n" "a-anno-symb" "n" "a-detl-genf" "" "y")
The second part. Accessing the command that is now part of my start-up. Doesn't happen. I can type the command in right after I run my LISP, and it works. But, inside my lisp, it doesn't. I've tried with command "cln", "_cln" and "-cln". Nothing seems to work.
Any suggestions?
HD
Solved! Go to Solution.
Solved by phanaem. Go to Solution.
Sorry, that didn't work. I do appreciate that one though. I hadn't thought of it.
@HullDrafter wrote:This is what I got;
Command: ; error: bad argument type: stringp nil
HD
It looks like an error in lisp, after routine started.
This is the same error you had before, when you tried (command "cln")?
Short story. As Cln is not an autocad command, a coworker had to show me where they got it from. I loaded it into my startup so I now have it. I wrote the lisp routine to remove 4 layers and everything on them, as they are always the same four layers. Cln works. I type the command, tell it 252 for a color change, hit enter. It grabs everything, including blocks, changes it all to gray (color:252). I am trying to set up the block to do everything. Open drawing, activate LISP, saveas, move onto the next background drawing. Outside the Lisp routine, Cln works fine. Inside, no go.
HD
Yes exactly.
The problem you're having is because it's tough to call a lisp function while currently running a lisp function, unless it's a subfunction.
The "C:CLN" , specifically the "C:" portion means that you're not using a sub...the (vla-sendcommand) is the method I used to accomplish a similar task, calling one routine while in the middle of another routine.
Here's a snippet from my .lsp
(vla-sendcommand doc (strcat "horiz" " " "ALL" " " " "))
Where the horiz is defined as the following:
(defun C:HORIZ (/ ss) (if (setq ss (ssget '((0 . "INSERT")))) (foreach obj (ssvla ss) (foreach att (vlax-safearray->list (vlax-variant-value (vla-getattributes obj))) (vla-put-rotation att 0.0)))) (princ) );horiz defun
So you can see here how the (vla-sendcommand) works for a C: function. The (strcat) is absolutely necessary if more than the call to the function is required (i.e. user input).
And yes, you will need to obtain a pointer to the active document for sendcommand to work.
That's the (vlax-get-acad-object) nested statement, usually sets activedoc to a variable. Include all of that in your routine, have the sendcommand have your pointer as the argument (mine is using "doc" in the example above), and it should work for your purposes.
HTH
@bhull1985 wrote:
...
The (strcat) is absolutely necessary if more than the call to the function is required (i.e. user input).
...
Brandon, really?
Try
(vla-sendcommand doc "horiz\rALL\r\r")
or even
(vla-sendcommand doc "horiz ALL ")
Cheers
Henrique
With everybody's help, got it to work most of the way through. Thank you all.