Displaying a view into a PictureBox

Displaying a view into a PictureBox

Anonymous
Not applicable
1,102 Views
3 Replies
Message 1 of 4

Displaying a view into a PictureBox

Anonymous
Not applicable

Hi.

Is it possible to create a something like a snapshot or print screen of certain view using API and then displaying it into PictureBox control in a Visual Studio form? Something similar to what we can achieve using Client View through Apprentice Server but as far as I know this solution cannot be contained into an Inventor add-in and that's why I cannot use it in my project.

 

Is there any workaround in this situation? Getting a thumbnail image wouldn't be a good idea in this case so I am looking for another solution.

0 Likes
Accepted solutions (2)
1,103 Views
3 Replies
Replies (3)
Message 2 of 4

NachoShaw
Advisor
Advisor
Accepted solution
hi

there isn't a method inside inventor. although the clientview requires an image of, it's not really an image. I did manage to make a workaround though in visual studio. it takes a bit of setting up but it's not that bad.

add a rectangle to the form at the same size and location as the picturebox.
use it as a snapshot frame and save the image out as a bitmap

I'll look tomorrow at my code projects, see if I can put the code up for you (was a while ago I did that)

thanks

nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 3 of 4

BrianEkins
Mentor
Mentor
Accepted solution

You can do something as simple as what I've done below.  I created a new project and added a button (Button1) and a picture box (PictureBox1).  There's a reference to the Inventor interop and below is the code for the click event of the button.  It connects to Inventor, saves an image of the active few to a file, and then displays that image in the picture box.

 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim invApp As Inventor.Application
        invApp = GetObject(, "Inventor.Application")

        Dim view As View = invApp.ActiveView
        view.SaveAsBitmap("C:\Temp\Junk.png", Me.PictureBox1.Width, Me.PictureBox1.Height)

        PictureBox1.Image = Image.FromFile("C:\Temp\Junk.png")
    End Sub
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 4

Anonymous
Not applicable

Thanks @BrianEkins and @NachoShaw for your contribution.

 

@BrianEkins your code is what I was looking for. I am very thankful for it.

 

@NachoShaw please post your code in this topic. I am very curious how your solution looks like. After that I will mark this topic as solved with two solutions.

0 Likes