From: Ke on
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);
}
}

}
}

From: CS on
On Jan 30, 12:42 pm, "Ke" <kesun....(a)gmail.com> wrote:
> 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);
> }
> }
>
> }
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

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.

From: Ke on
On Jan 30, 5:40 pm, "CS" <csche...(a)ae-solutions.com> wrote:
> On Jan 30, 12:42 pm, "Ke" <kesun....(a)gmail.com> wrote:
>
>
>
>
>
> > 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);
> > }
> > }
>
> > }
>
> > }- Hide quoted text -
>
> > - Show quoted text -
>
> 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.- Hide quoted text -
>
> - Show quoted text -

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

Ke

From: Ke on
On Jan 31, 7:28 am, "Ke" <kesun....(a)gmail.com> wrote:
> On Jan 30, 5:40 pm, "CS" <csche...(a)ae-solutions.com> wrote:
>
>
>
>
>
> > On Jan 30, 12:42 pm, "Ke" <kesun....(a)gmail.com> wrote:
>
> > > 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);
> > > }
> > > }
>
> > > }
>
> > > }- Hide quoted text -
>
> > > - Show quoted text -
>
> > 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.- Hide quoted text -
>
> > - Show quoted text -
>
> Thank you! I actually got a reply from Solidworks, and will post it
> here.
>
> Ke- Hide quoted text -
>
> - Show quoted text -

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.

From: CS on
On Jan 31, 8:04 am, "Ke" <kesun....(a)gmail.com> wrote:
> On Jan 31, 7:28 am, "Ke" <kesun....(a)gmail.com> wrote:
>
>
>
>
>
> > On Jan 30, 5:40 pm, "CS" <csche...(a)ae-solutions.com> wrote:
>
> > > On Jan 30, 12:42 pm, "Ke" <kesun....(a)gmail.com> wrote:
>
> > > > 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);
> > > > }
> > > > }
>
> > > > }
>
> > > > }- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > 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.- Hide quoted text -
>
> > > - Show quoted text -
>
> > Thank you! I actually got a reply from Solidworks, and will post it
> > here.
>
> > Ke- Hide quoted text -
>
> > - Show quoted text -
>
> 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.- Hide quoted text -
>
> - Show quoted text -



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