Need help with eDrawings API

Hello all,

I know this might be a long shot, but has anyone of you used C# to program Solidworks eDrawings control?

I am having trouble using the provided Print2 function in the eDrawings API. I emailed Solidworks, but their response team is very slow, the last reply about another issue was like 5 days. So I was hoping if anyone can take a look at my code and tell me what is wrong?

Thanks!

Ke

-----------------------------------------------------------------------

-------------------------------

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Printing;

namespace OmegaDyne_Document_Controller { public partial class eDrawingsWindow : Form { public eDrawingsWindow() { InitializeComponent(); }

private void eDrawingsWindow_Load(object sender, EventArgs e) { //Retrives the path of the drawings file. string docFullPath = Document.FullPath;

//Selects the View or Print action according to the value passed from the main form. if (eDrawingsOption.pvOption == "view") { axEModelViewControl1.OpenDoc(docFullPath, false, false, true, ""); } if (eDrawingsOption.pvOption == "print") { axEModelViewControl1.OpenDoc(docFullPath, false, false, true, "");

axEModelViewControl1.SetPageSetupOptions(EModelView.EMVPrintOrientation .ePortrait, 1, 0, 0, 1, 7, "hp color LaserJet 2550 PCL 6", 1, 1, 1,

1);

axEModelViewControl1.Print2(false, docFullPath, false, false, false, EModelView.EMVPrintType.eOneToOne); } }

} }

Reply to
Ke
Loading thread data ...

The problem you are likely running into is that the open method is multi threaded so you have to catch the LoadComplete event (I am guessing at the name for time) and in that event you process your printing. I had a VBA example but cannot find it or I would post example code.

Reply to
CS

Thank you! I actually got a reply from Solidworks, and will post it here.

Ke

Reply to
Ke

Hello Ke,

I suspect the problem is that the eDrawings Control is not yet ready in the callback:

private void eDrawingsWindow_Load(object sender, EventArgs e)

Better is to first load the form in full and then fire off the loading and printing of a document through a button.

Reply to
Ke

I tested some vb code Don't know if it will be of any help to you

Private Sub EModelViewControl1_OnFinishedLoadingDocument(ByVal FileName As String) 'when the Drawing finishes loading print it off Me.EModelViewControl1.Print2 True, FileName, True, False, False, eScaleToFit End Sub

Private Sub UserForm_Click() 'load the Drawing Me.EModelViewControl1.OpenDoc "C:\9506.edrw", True, False, True, "" End Sub

Reply to
CS

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.