eDrawings - Print to pdf from a VB6 project

Hi, I hope to be in the right section.

I Should create a project in VB6 for a client of mine.

The customer selects a SLDDRW file and my program should print the file with PDFCreator (to obtain the PDF version), using eDrawings.

I I thought to do this simply by using CreateObject, but I do not know what to write as a class: I know that with Word I have to write CreateObject ("Word.Application"), but for eDrawings I do not know how to do.

At this point I have to change the printer in eDrawings selecting PDFCreator and then start printing.

 

Can anyone help me?

 

Thanks

SolidworksApi macros
Answers 7
ST
ST 2014-01-10 Best Answer

You cannot use CreateObject - you have to use the eDrawings ActiveX control by adding the EmodelView.dll component to your project (Project -> Components -> Browse)

Then add that component to a Form.

Now you can use that control to open a file and print it.

Note that it is multi-threaded, so when opening a file, you need to wait for the OnFinishedLoadingDocument event.

When printing, wait for the OnFinishedPrintingDocument event.

SF
SF 2014-01-13

Thank you for your response.

I tried to do as suggested, but I have a problem.

 

On a form I have inserted the control EModelViewControl and then I wrote the following code

Private Sub Command1_Click()

    Call EModelViewControl1.OpenDoc("C:\Prova.SLDDRW", False, False, True, "")

End Sub

Private Sub EModelViewControl1_OnFinishedLoadingDocument(ByVal FileName As String)

    'Debug.Print "Load Terminato"

     ???????    THIS IS THE PROBLEM!!!!!!

End Sub

 

Private Sub EModelViewControl1_OnFinishedPrintingDocument(ByVal PrintJobName As String)

    Call EModelViewControl1.CloseActiveDoc("")

End Sub

 

What I can not do is tell the control which printer to use and what command to use to print (I think PRINT2).

 

Since one of the parameters of PRINT2 is filename, I must open the file before or do not need?

Thanks for the help

P.S: sorry for my bad english

ST
ST 2014-01-13

I think you have to use EModelViewControl1.SetPageSetupOptions

SF
SF 2014-01-13

I tried, but there are still two problems.

This is the code

Private Sub Command1_Click()

    Call EModelViewControl1.OpenDoc("C:\Prova.SLDDRW", False, False, True, "")

End Sub

Private Sub EModelViewControl1_OnFinishedLoadingDocument(ByVal FileName As String)

   Call EModelViewControl1.SetPageSetupOptions(ePortrait, 1, 0, 0, 1, 7, "PDFCreator", 1, 1, 1, 1)

   Call EModelViewControl1.Print2(True, FileName, True, False, False, eScaleToFit)

End Sub

 

Private Sub EModelViewControl1_OnFinishedPrintingDocument(ByVal PrintJobName As String)

    Call EModelViewControl1.CloseActiveDoc("")

End Sub

1. Making TRUE the first parameter of PRINT2, the print dialog box appears. I wish it was all done automatically. But putting the parameter to FALSE, nothing is printed.

2. I tried anyway to put the parameter to true and I did start printing manually. The problem is that the event OnFinishedPrintingDocument will not fire, so I can not close the document.

 

What is wrong?

Thank's

Have you got some VB& sample code?

ST
ST 2014-01-13

You should be using Print5 instead of Print2.

Print2 is very old and I think it had some bugs in it.

Using your code, Print5 should work and solve both the problems.

SF
SF 2014-01-13

Great

 

Now I'll do the last tests.

 

Thank you very much.

DF
DF 2014-05-19

Has there been success in having the onFinishedPrintingDocument fire when needed?  I have a similar app I have  been using and the events never fired so I run them in sequence with a Sleep inbetween.

Sometimes the sleep is not enough.

Would be great if I could get the events to fire.

Thanks for any information you can give