'Autocad 2016 API: Is it possible to write multiple commands that require addicional inputs?

I´m new to this api and I´m trying to give a set of commands that saves the pdf file of the drawing to black and white.. Since the drawing is made of Blocks not made by me and some of them don't change colors just by selecting grayscale.ctb to the style, i was trying to automate a process that i found that works witch is the following commands:

acadDoc.SendCommand("CONVERTCTB ");
acadDoc.SendCommand("grayscale.ctb ");
acadDoc.SendCommand("grayscale.stb ");
acadDoc.SendCommand("yes ");
acadDoc.SendCommand("CONVERTPSTYLES ");
acadDoc.SendCommand("grayscale.stb ");

If I do this directly in CAD it works fine, but when I run my app, It stops after it runs the first command...

Any ideas as how can I solve this? Thank you in advance.



Solution 1:[1]

I didn't test that, but in theory is should work if You write command with all parameters in one string like this:

acadDoc.SendCommand("_CIRCLE 0,0 10 ");

The next issue is run command in dialogless mode.

I can not test CONVERTCTB CONVERTPSTYLES on AutoCAD because I'm working on ZWCAD and in ZWCAD both CONVERTCTB CONVERTPSTYLES cannot run dialogless, maybe AutoCAD can do this.

Default way of run command with no dialog is start it name with -. Like this

acadDoc.SendCommand("-CONVERTCTB grayscale.ctb ...");

If it fails, You can also try set system variable FILEDIA to 0. this will disable dialogs. After running Your command, be sure You set FILEDIA to previous version, if You forget that it may make users nervous :) .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CAD Developer