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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Vb api Save screen image

CAD_user
14-Alexandrite

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?

ACCEPTED SOLUTION

Accepted Solutions
Manjunath
13-Aquamarine
(To:CAD_user)


@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()

View solution in original post

6 REPLIES 6
Manjunath
13-Aquamarine
(To:CAD_user)


@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()

CAD_user
14-Alexandrite
(To:Manjunath)

That's it.

 

It worked 🙂

Hi,

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

Thanks

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

pgovindaiah
7-Bedrock
(To:T_F)

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

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

Announcements


Top Tags