.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem trying to load an image into a PictureBox

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
stevenelliott3894
678 Views, 7 Replies

Problem trying to load an image into a PictureBox

I'm trying to convert a VBA application to .Net.

 

First things first: AutoDesk's .Net implementation sucks and the lack of cohesive documentation is pathetically shameful. Why should I have to search far and wide to try and get enough information to make this crap work? This situation is unconscionable. And yet here we are, years after release, and they still don't have their crap together on this. Seems like everything about AutoCAD is steadily going downhill. It used to be a professional quality package. Now, it is rife with problems that the company ignores and it has absolutely the WORST documentation of the API of any professional product I have ever seen.

 

My latest go-around with this travesty:

 

I need to load a PictureBox with an image from a file at runtime.

 

PictureBox1.Image = Image.FromFile("Image.bmp")

-> Results in the error: 'FromFile' is not a member of 'Autodesk.AutoCAD.DatabaseServices.Image'.

Huh? This is how Visual Studio tells me to load an image. I guess AutoDesk thought better of it.

 

PictureBox1.Image.FromFile("Image.bmp")

-> Results in the error: 'Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.'

 

These examples were both taken directly from Visual Studio's help. Does anybody know of an approach that works?

 

 

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
7 REPLIES 7
Message 2 of 8
Hallex
in reply to: stevenelliott3894

Have you tryed:

Imports System.Drawing

--------------------------

PictureBox1.Image = System.Drawing.Image.FromFile("Image.bmp")?

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 8
stevenelliott3894
in reply to: Hallex

I thought I had tried that using IntelliSense to guide me, but it didn't work that way. Just putting it in manually seemed to do the trick. Thanks!

 

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 4 of 8

Try the attached class. Works fine on 2007 and 2008 on 32 and 64 bits machines.

I use it to provide previews of DWGs of dynamic blocks and other blocks that are not currently opened.

I use it this way combined with a list box with the full names of the dwgs

 

string myDWGPath = Path.Combine(FileServer, listBoxProfiles.Text);
Bitmap dwgThumb = ThumbnailReader.GetThumbnail(myDWGPath,false);
      pictureBox.Image = dwgThumb;
      if (dwgThumb != null)
      {
        // whatever you like
      }
      else
      {
        // whatever exception handling you like
      }

Message 5 of 8

It's obvious that you have Imported Autodesk.AutoCAD.DatabaseServices, and have not imported System.Drawing.  If you do Import System.Drawing, then the Image reference will be ambiguous, existing in both System.Drawing, and Autodesk.AutoCAD.DatabaseServices.

 

You just need to explicitly specify the System.Drawing.Image

 

PictureBox1.Image = System.Drawing.Image.FromFile("Image.bmp")

Dave O.                                                                  Sig-Logos32.png
Message 6 of 8

Thanks, ognyandim, but you seem to have replied to the wrong topic...

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 7 of 8

That explains my problem.

 

Thanks, guys.

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 8 of 8

You can get a thumb from you file either with the same class. It doesnt matter if it is DWG or JPG, or BMP or whatever. You can strech yout thumb to whatever size you want after you get it.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost