반응형
Sub PrintDrawingWithPCF()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim CreoSession As pfcls.IpfcBaseSession
Dim CreoCurrentModel As pfcls.IpfcModel
'Make an asynchronous connection with Pro/ENGINEER
Set conn = asynconn.Connect("", "", ".", 5)
'Get the current session
Set CreoSession = conn.session
'Show the current Working Directory
MsgBox "This is the current Working Directory: " & vbCrLf & CreoSession.GetCurrentDirectory
Set CreoCurrentModel = CreoSession.CurrentModel
'Show the name of the Pro/E Model in a messagebox
MsgBox "Model name = " & CreoCurrentModel.Filename
Set oWindow = CreoSession.GetModelWindow(CreoCurrentModel)
'Activate the new window before printing
oWindow.Activate
Dim PrinterInstrCreate As CCpfcPrinterInstructions
Dim PrinterInstr As IpfcPrinterInstructions
Dim printerPCFOptionsCreate As CCpfcPrinterPCFOptions
Dim printerPCFOptions As IpfcPrinterPCFOptions
Dim creoWindow As IpfcWindow
Set PrinterInstrCreate = New CCpfcPrinterInstructions
Set PrinterInstr = PrinterInstrCreate.Create
Set printerPCFOptionsCreate = New CCpfcPrinterPCFOptions
Set printerPCFOptions = printerPCFOptionsCreate.Create
Set printerPCFOptions = CreoSession.GetPrintPCFOptions("C:\temp\postscript.pcf", CreoCurrentModel)
PrinterInstr.PrinterOption = printerPCFOptions.PrinterOption
PrinterInstr.ModelOption = printerPCFOptions.ModelOption
PrinterInstr.PlacementOption = printerPCFOptions.PlacementOption
'Set SaveToFile = True if a plot file has to be saved to Disk
PrinterInstr.PrinterOption.SaveToFile = True
' Set the output plot file name here
PrinterInstr.PrinterOption.Filename = CreoCurrentModel.InstanceName
'Set SendToPrinter = True if the plot should be directed to Printer
PrinterInstr.PrinterOption.SendToPrinter = True
'Print command should be set to print to a printer if it is not set in the PCF file
PrinterInstr.PrinterOption.PrintCommand = "windows_print_manager \\machine_name\Device_Name"
Set creoWindow = CreoSession.GetModelWindow(CreoCurrentModel)
PrinterInstr.WindowId = creoWindow.GetId
CreoCurrentModel.Export CreoCurrentModel.InstanceName, PrinterInstr
'Disconnect with Pro/ENGINEER
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set oModel = Nothing
End Sub
'VBA, VB.NET For Creo' 카테고리의 다른 글
모델의 Parameter 이름 및 타입, 값 과 엑셀 내용과 비교 (0) | 2022.10.25 |
---|---|
엑셀에서 Parameter 값 입력 -> Creo 변경 (0) | 2022.10.23 |
작업 폴더에 있는 Drawing 파일 인쇄 ver0.1 - PDF 변환 (0) | 2022.10.11 |
Creo Drawing 파일 PDF 변환 하기 (0) | 2022.10.11 |
모듈화 구성 해보기 (0) | 2022.10.11 |