-1

I have a document open in solid edge that I would like to be saved as an image (TIFF to be specific). Currently, this is the code I use to save the file:

    FileName = objDocument.Name
    NewFileName = "C:\Folder" & "\" & "OrtBo" & FileName & ".tif"
    objDocument.SaveAs(NewFileName)

Where NewFileName dictates where the file is to be saved and with what extension. When I run the program in vb.net, the file saves, however when I open the saved file with irfan, I get an error that says either the "cannot read header, file format is not recognized or the file cannot be found". I thought it was a problem with the original file, however when I save the document as a TIFF file directly in solid edge, everything is fine. So there must be a problem with my vb.net code. Any suggestions for saving a file as an image? Thanks in advance!

Aidan Kehoe
  • 104
  • 3
  • 14
  • Just to be clear: There's **not** a problem with VB.NET, but with your code. You can't just give a file another extension and think that it would work, you are required to convert it to that type. The extension can be anything, it's the content that matters. Solid edge doesn't know that you want to save it as an image just because you give the file such an extension. – Visual Vincent May 23 '16 at 08:14
  • @VisualVincent great thank you! By the way, by "problem with vb.net code", I meant my code. I'll change that to make it a bit more clear. How would you suggest I convert the file to an image? – Aidan Kehoe May 23 '16 at 08:18
  • I've never used Solid Edge so I cannot answer that... You'd have to look at the possible documentation to see if there's anything, or Google. – Visual Vincent May 23 '16 at 08:40

1 Answers1

0

TIFF file is a kind of an image file. Try opening your document as an image and then save it as a TIFF file using this.

You can open a document as an image using this.

Leprechaun
  • 349
  • 2
  • 16
  • thanks for the suggestion! I'm trying it now. I'm getting an out of memory error but when I figure that out I'll let you know if this works. – Aidan Kehoe May 23 '16 at 08:39
  • I'm still having trouble with the out of memory exception when I call the image.fromfile command. From what I have read, this is a very general error and can be given for a wide variety of reasons (not necessarily because there is not enough memory). Do you have any suggestions to fix this? – Aidan Kehoe May 23 '16 at 08:48
  • Try using a filestream to open the image and see if that [works](http://stackoverflow.com/questions/1108607/out-of-memory-exception-on-system-drawing-image-fromfile) – Leprechaun May 23 '16 at 10:14
  • Filestream did not work for me. I tried Image.FromFile but I keep getting an OutOfMemory exception. – Aidan Kehoe May 23 '16 at 10:51
  • Solved it! Do not save the document. Save the window itself using SaveAsImage (The window is 2D unlike the document so this works) – Aidan Kehoe May 23 '16 at 11:42