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.
I found a solution to this problem to anyone that might have it. The way I did it was by creating this method:
private static void PressEnterKey(Object o)
{
SendKeys.SendWait("{ENTER}");
}
and then when I send the commands to AutoCad:
Object mxNull = 0;
_timer = new System.Threading.Timer(PressEnterKey, null, 3000, 0);
acadDoc.SendCommand("CONVERTCTB grayscale.ctb\ngrayscale.stb\nyes\n");
_timer = new System.Threading.Timer(PressEnterKey, null, 3000, 0);
acadDoc.SendCommand("CONVERTPSTYLES grayscale.stb\n ");
This just awaits 3 seconds after the command is sent to CAD and then simulates a KeyStroke of {ENTER} to close the warning window.