void PrintInternal(string filename, DraftPrintUtilityOptions options) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.DraftPrintUtility draftPrintUtility = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true); // Make sure Solid Edge is visible. application.Visible = true; // Get a reference to the Documents collection. documents = application.Documents; // Get a reference to the DraftPrintUtility. draftPrintUtility = (SolidEdgeDraft.DraftPrintUtility)application.GetDraftPrintUtility(); // Copy all of the settings from DraftPrintUtilityOptions to the DraftPrintUtility object. CopyOptions(draftPrintUtility, options); // Open the document. draftDocument = (SolidEdgeDraft.DraftDocument)documents.Open(filename); // Give Solid Edge time to process. application.DoIdle(); // Add the draft document to the queue. draftPrintUtility.AddDocument(draftDocument); // Print out. draftPrintUtility.PrintOut(); // Cleanup queue. draftPrintUtility.RemoveAllDocuments(); } catch { throw; } finally { // Make sure we close the document. if (draftDocument != null) { draftDocument.Close(); } SolidEdgeCommunity.OleMessageFilter.Register(); } }
public DraftPrintUtilityOptions(SolidEdgeFramework.Application application) : this((SolidEdgeDraft.DraftPrintUtility)application.GetDraftPrintUtility()) { }