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

Have hit a trouble spot with a short time saving Routine.

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
HullDrafter
490 Views, 9 Replies

Have hit a trouble spot with a short time saving Routine.

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

9 REPLIES 9
Message 2 of 10
phanaem
in reply to: HullDrafter

Try (C:CLN)
Message 3 of 10
HullDrafter
in reply to: phanaem

Sorry, that didn't work. I do appreciate that one though. I hadn't thought of it.

Message 4 of 10
HullDrafter
in reply to: phanaem

This is what I got;

 

Command: ; error: bad argument type: stringp nil

 

HD

Message 5 of 10
phanaem
in reply to: HullDrafter


@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")?

 

 

Message 6 of 10
HullDrafter
in reply to: phanaem

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

Message 7 of 10
hmsilva
in reply to: HullDrafter

You can try to provide the cln function the prompt answers...
Perhaps something like this:
(vl-load-com);; Loads Visual LISP extensions to AutoLISP
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "cln all\r color\r 252\r")
Is just an example, I don't know the cln function prompts.

HTH
Henrique

EESignature

Message 8 of 10
bhull1985
in reply to: hmsilva

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

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 9 of 10
hmsilva
in reply to: bhull1985


@bhull1985 wrote:

...

The (strcat) is absolutely necessary if more than the call to the function is required (i.e. user input).

 

...


Brandon, really? Smiley Wink

Try

(vla-sendcommand doc "horiz\rALL\r\r")
or even
(vla-sendcommand doc "horiz ALL  ")

 

Cheers

Henrique

EESignature

Message 10 of 10
HullDrafter
in reply to: phanaem

With everybody's help, got it to work most of the way through. Thank you all.

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

Post to forums  

Autodesk Design & Make Report

”Boost