How to generate Thumbnail image for Inventor drawing(.IDW) files Using Camera

How to generate Thumbnail image for Inventor drawing(.IDW) files Using Camera

vijaykumarreddy25
Contributor Contributor
382 Views
3 Replies
Message 1 of 4

How to generate Thumbnail image for Inventor drawing(.IDW) files Using Camera

vijaykumarreddy25
Contributor
Contributor

Please provide some solution for How to generate Thumbnail image for Inventor drawing(.IDW) files Using Camera

0 Likes
383 Views
3 Replies
Replies (3)
Message 2 of 4

johnsonshiue
Community Manager
Community Manager

Hi Vijay,

 

I am not sure I understand the request. Is this about the thumbnail image for an idw file? It is captured from the active sheet based on Front view. Do you want it to be looked at from a different angle?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 4

vijaykumarreddy25
Contributor
Contributor

Hello Johnson Shiue,

   Thank you for your response.

    Actually my requirement is to generate Thumbnails for all document types in structure files.

   I got some piece of code from Online articles. But in below code I am able to generate Thumbnails only Part and Assemblies. I am not able to generate the Drawings(IDW) files.

Can you please suggest how to generate Thumbnails for Drawings(IDW) files.

 

string fileNameImage = "thumbnail.bmp";
string documentFolder = System.IO.Path.GetDirectoryName(document.FullFileName);
string imageFilename = System.IO.Path.Combine(documentFolder, fileNameImage);
if (document.DocumentType == DocumentTypeEnum.kPartDocumentObject)
{

Camera camera = m_server.TransientObjects.CreateCamera();
camera.SceneObject = (document as PartDocument).ComponentDefinition;
camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
camera.Fit();
camera.ApplyWithoutTransition();
Color backgroundColor = m_server.TransientObjects.CreateColor(0xEC, 0xEC, 0xEC, 0.0);
camera.SaveAsBitmap(imageFilename, 512, 512, backgroundColor, backgroundColor);
}
if (document.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
Camera camera = m_server.TransientObjects.CreateCamera();
camera.SceneObject = (document as AssemblyDocument).ComponentDefinition;
camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
camera.Fit();
camera.ApplyWithoutTransition();
Color backgroundColor = m_server.TransientObjects.CreateColor(0xEC, 0xEC, 0xEC, 0.0);
camera.SaveAsBitmap(imageFilename, 512, 512, backgroundColor, backgroundColor);
}

0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor

You can try it like this:

string fileNameImage = "thumbnail.bmp";
string documentFolder = System.IO.Path.GetDirectoryName(document.FullFileName);
string imageFilename = System.IO.Path.Combine(documentFolder, fileNameImage);
Color backgroundColor = m_server.TransientObjects.CreateColor(0xEC, 0xEC, 0xEC, 0.0);
if (document.DocumentType == DocumentTypeEnum.kPartDocumentObject)
{

    Camera camera = m_server.TransientObjects.CreateCamera();
    camera.SceneObject = (document as PartDocument).ComponentDefinition;
    camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
    camera.Fit();
    camera.ApplyWithoutTransition();                
    camera.SaveAsBitmap(imageFilename, 512, 512, backgroundColor, backgroundColor);
}
if (document.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
    Camera camera = m_server.TransientObjects.CreateCamera();
    camera.SceneObject = (document as AssemblyDocument).ComponentDefinition;
    camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
    camera.Fit();
    camera.ApplyWithoutTransition();
    camera.SaveAsBitmap(imageFilename, 512, 512, backgroundColor, backgroundColor);
}
if (document.DocumentType == DocumentTypeEnum.kDrawingDocumentObject)
{
    // for this to work the document needs to be the active document.
    document.Activate();

    Inventor.View view = ThisApplication.ActiveView;                
    Camera camera = view.Camera;
    camera.Fit();
    camera.ApplyWithoutTransition();

    camera.SaveAsBitmap(imageFilename, 512, 512, backgroundColor, backgroundColor);
}

 This is the most basic way that I know. It leaves you with some strange borders. Have a look at this post if you want to remove those (partially).

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/export-to-tiff-without-background/m-...

 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

0 Likes