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

Vb api Save screen image

SOLVED
Aquamarine

Vb api Save screen image

Hello,

I've made the conection between vb and creo.


Now I need some help to do the following:

 

1st I need to save the screen image to a file *.png to a file

 

2nd If I have an assembly oppened, I need to reed the parameters from the activated part. Not the displayed assembly, but the activated part in the assembly.

 

Any idea of how to do it?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Vb api Save screen image


@CAD_user wrote:

Hello,

I've made the conection between vb and creo.


Now I need some help to do the following:

 

1st I need to save the screen image to a file *.png to a file

 

2nd If I have an assembly oppened, I need to reed the parameters from the activated part. Not the displayed assembly, but the activated part in the assembly.

 

Any idea of how to do it?


@CAD_user 

for 1st question use option IpfcWindow.ExportRasterImage()

for 2nd question, as per my understanding IpfcBaseSession.GetActiveModel() should give the activated model (but not sure). Once you get the model use IpfcParameterOwner.GetParam()

6 REPLIES 6

Re: Vb api Save screen image


@CAD_user wrote:

Hello,

I've made the conection between vb and creo.


Now I need some help to do the following:

 

1st I need to save the screen image to a file *.png to a file

 

2nd If I have an assembly oppened, I need to reed the parameters from the activated part. Not the displayed assembly, but the activated part in the assembly.

 

Any idea of how to do it?


@CAD_user 

for 1st question use option IpfcWindow.ExportRasterImage()

for 2nd question, as per my understanding IpfcBaseSession.GetActiveModel() should give the activated model (but not sure). Once you get the model use IpfcParameterOwner.GetParam()

Re: Vb api Save screen image

That's it.

 

It worked Smiley Happy

Re: Vb api Save screen image

Hi,

Could you share the code for exporting as Raster Image? I'm struggling there a bit.

Thanks

Re: Vb api Save screen image

Try this:

 

Dim conn As pfcls.IpfcAsyncConnection
Dim session
Dim model As IpfcModel
Dim window As IpfcWindow

 

 

Private Sub Get_Creo()
Dim asynconn As New pfcls.CCpfcAsyncConnection
'Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession


conn = asynconn.Connect("", "", ".", 5)
session = conn.Session

'model = session.CurrentModel
model = session.GetActiveModel
window = session.CurrentWindow

'mdlname = session.CurrentModel.FileName
mdlname = session.GetActiveModel.FileName

Work_dir = session.GetCurrentDirectory


End Sub

 

Private Sub Get_Creo()
Dim asynconn As New pfcls.CCpfcAsyncConnection
'Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession


conn = asynconn.Connect("", "", ".", 5)
session = conn.Session

'model = session.CurrentModel
model = session.GetActiveModel
window = session.CurrentWindow

'mdlname = session.CurrentModel.FileName
mdlname = session.GetActiveModel.FileName

Work_dir = session.GetCurrentDirectory


End Sub

Re: Vb api Save screen image

Hi,

That is the code to connect to creo, but I'm looking for Exporting Window as Raster Image. If you could provide that, it would be useful.

Thanks

Re: Vb api Save screen image

sorry, wrong copy paste

 

Dim instructions 'As IpfcRasterImageExportInstructions

Dim rasterHeight As Double = 2
Dim rasterWidth As Double = 3.85
Dim dotsPerInch As Integer
Dim imageDepth As Integer

Dim bmpInstrs As IpfcBitmapImageExportInstructions

Try
dotsPerInch = EpfcDotsPerInch.EpfcRASTERDPI_100
imageDepth = EpfcRasterDepth.EpfcRASTERDEPTH_24

bmpInstrs = (New CCpfcBitmapImageExportInstructions).Create(rasterWidth, rasterHeight)
instructions = bmpInstrs

window.ExportRasterImage(Work_dir + Nome_imagem + ".bmp", instructions)


Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
End Try

If Imagem.Checked = True Then
conn.Disconnect(2)
End If
End Sub