Need help with eDrawings API

Discussion in 'SolidWorks' started by Ke, Jan 30, 2007.

  1. Ke

    Ke Guest

    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);
    }
    }

    }
    }
     
    Ke, Jan 30, 2007
    #1
  2. Ke

    CS Guest

    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.
     
    CS, Jan 30, 2007
    #2
  3. Ke

    Ke Guest

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

    Ke
     
    Ke, Jan 31, 2007
    #3
  4. Ke

    Ke Guest

    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.
     
    Ke, Jan 31, 2007
    #4
  5. Ke

    CS Guest



    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
     
    CS, Jan 31, 2007
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.