[COM] AcadDocument.Export
Hello!I just got my license, installed Bricscad V9 and started to play with the COM a little.I am trying to do a basic dwg to pdf conversion.I keep getting an exception: "Value does not fall within the expected range."I call the method like this: doc.Export(@D:\2110960.pdf, "pdf", null);I can't find anything about the matter using google or this forum.I am programming with VS2008 C#.Give me a jump start please. Any help is appreciated
Comments
-
Welcome Mikko!It’s a little finicky, but it does work, please see the comments in the code
[CommandMethod("MyExport")] public static void MyExport() { try { AcadApplication app = Application.AcadApplication as AcadApplication; if (app == null) throw new Exception("Could Not Get Application"); AcadDocument doc = app.ActiveDocument; AcadSelectionSet ss = doc.SelectionSets.Add("MySet"); ss.Select(AcSelect.acSelectionSetAll, null, null, null, null); try { if (ss.Count > 0) { // Don't put the extention on the file or poof! // You must pass valid selection set or poof! doc.Export("C:\\Test", "pdf", ss); } } finally { ss.Delete(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show (string.Format("{0}\n:\n{1}",ex.Message ,ex.StackTrace)); } }
0 -
Thanks for the quick response! That helped.
0 -
I have another question concerning this matter:Is there a way to export a drawing with a specified Plot Style Table (pen assignments)? To be specific: monochrome.ctb with correct lineweights. The name obviously refers to plotting, but I had to ask anyways. If no, this is propably possible using AcadDocument.PlotToDevice -method, am I right?
0