cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Export drawing to PDF using VB API

ptc-4653571
1-Newbie

Export drawing to PDF using VB API

I am using VB API to connect to Creo Parametric 1.0 to extract data. I want to extract model drawing in PDF format and display it in my VB App.

When I call the Export method exception is thrown as : pfcExceptions::XToolkitInvalidType.

Does any one have any idea, what I should do?

 

Sub Main()

Dim asyncConnection As pfcls.IpfcAsyncConnection = Nothing 'conn

Dim cAC As pfcls.CCpfcAsyncConnection

Dim session As pfcls.IpfcBaseSession

Dim tModel As pfcls.IpfcModel

 

Try

cAC = New pfcls.CCpfcAsyncConnection 'asynconn

 

cAC = CreateObject("pfcls.pfcAsyncConnection")

asyncConnection = cAC.Connect("", "", "", 5)

 

session = asyncConnection.Session

 

Dim descModel As pfcls.IpfcModelDescriptor

Dim expdf As pfcls.IpfcPDFExportInstructions

Dim pdfopt As pfcls.IpfcPDFOption

Dim EpfcPDFOPT_LAUNCH_VIEWER As Boolean

 

EpfcPDFOPT_LAUNCH_VIEWER = False

descModel = (New pfcls.CCpfcModelDescriptor).Create(pfcls.EpfcModelType.EpfcMDL_DRAWING, "test.drw", Nothing)

expdf = (New pfcls.CCpfcPDFExportInstructions).Create()

pdfopt = (New pfcls.CCpfcPDFOption).Create()

pdfopt.OptionValue = (New pfcls.CMpfcArgument).CreateBoolArgValue(EpfcPDFOPT_LAUNCH_VIEWER)

 

expdf.FilePath = "c:\work\test.pdf"

 

tModel = session.CurrentModel

tModel.Export("c:\work\test.pdf", CType(expdf, pfcls.IpfcExportInstructions))

 

Catch ex As Exception

MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)

Finally

asyncConnection.Disconnect(2)

End Try

End Sub

4 REPLIES 4

I solved my problem. I can only export drawings to PDF and not the model.The solution works when I use (open) a drawing.

Hi, Habib. 

Thanks for sharing your problem. But I wonder whether I need some 3rd party pdf text extraction toolkits to help me extract text from pdf files. If so, it will be better if itt offers free trial package for users to check. I will try it later and send you feedback.  

Best regards,

Pan

Zynk
5-Regular Member
(To:epan)

Hi

Could you please tell me how you guys are handling in opening existing drawings..

Is this using session.OpenFile()

If so, could you please send me a sample code snippet...

 

~Zynk

 

Zynk
5-Regular Member
(To:Zynk)

 

Ok, got it... Smiley Very Happy

 

Top Tags