Reply
Solved! Go to solution

How to Refreashing Thumbnail preview C# CreatePreview not working

[ Edited ]

I am learning C# at a very slow pace, please bare with me.

 

I have reviewed the handful of post showing how to create a thumbnail, but I would like to know how to refrease them? If its a matter of creating a new thumbnail then how do I name it so it's linked to the appropeate file?

 

 

So now i have found "Create.Preview()" but i can not seem to get this to same a new preview.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.IO;
using System.Globalization;
using System.Windows.Forms;



namespace btExit
{
    class Program
    {  
        
        static void Main(string[] args)
        {
           
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.SolidEdgeDocument document = null;

            try
            {
                application = (SolidEdgeFramework.Application)
                    Marshal.GetActiveObject("SolidEdge.Application");

                //PAR Enviroment

                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartConstructionShowAllSurfaces);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartFormatShadedwithVisibleEdges);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartSketchHideAllSketches);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartReferencePlaneHideAllReferencePlanes);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartReferencePlaneHideAllReferenceAxes);
                
                // Turns off coords
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)40270);


                //ASM Enviroment

                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsShowAll);
                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.AssemblyCommandConstants.AssemblyAssemblyToolsHideAllReferencePlanes);
                


            }

            catch (System.Exception ex)

            {

                Console.WriteLine(ex.Message);

            }

            finally

            {

                //int white = 16777215;
                int SkyBlue = 13477484;



                object backGround = null;


                application.GetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorBackground, ref backGround);

                //application.GetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorBackground, ref ); 

                application.SetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorBackground, SkyBlue);

                //Bitmap image = pbImageHolder.Image as Bitmap
                
                document = application.ActiveDocument as SolidEdgeFramework.SolidEdgeDocument;

                document.CreatePreview();

                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartFileSave);

                application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.AssemblyCommandConstants.AssemblyFileSave);

                application.SetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorBackground, backGround);

 


            }
        }
    }
}
Nathan M. Gardner

https://www.etsy.com/people/NathanMGardner

Be sure to check out my work!!
Made in Maine Wood Carvings

5 REPLIES
Solution
Solution
Accepted by topic author ngardner
‎08-26-2015 04:32 AM

Re: How to Refreashing Thumbnail preview C# CreatePreview not working

I'm curious why CreatePreview() even exists. Documentation is non existent. It is my understanding that thumbnail previews get generated during save. I thought that there was an option to enable\disable it but I don't see it in ST7. If my understanding is correct, then you would need to develop an addin that listened for the BeforeSave document event and set the view the way you want it before it saves.

 

Anyone feel free to correct me if I'm wrong.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How to Refreashing Thumbnail preview C# CreatePreview not working

good morning Jason, in st6 the option is there. i don't know about st7.

 

Nathan M. Gardner

https://www.etsy.com/people/NathanMGardner

Be sure to check out my work!!
Made in Maine Wood Carvings

Re: How to Refreashing Thumbnail preview C# CreatePreview not working

That's it. I knew it was somewhere but couldn't find it. Anyway, with the "On save" option selected, it will always generate a new preview on save thus overwriting your generated preview. In order for your generated preview to stick, you'll need the "On button select" option checked. The problem that I see, I cannot find a way to programmatically change that setting. I've looked everywhere. If there is a way to change it via the API, I can't find it.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How to Refreashing Thumbnail preview C# CreatePreview not working

No problem, Its working as is right now with those settings. Do you know how to hide PMI ? I can not seem to find it. If not don't worry about it.

Nathan M. Gardner

https://www.etsy.com/people/NathanMGardner

Be sure to check out my work!!
Made in Maine Wood Carvings

Re: How to Refreashing Thumbnail preview C# CreatePreview not working

Off hand I don't. I'll look into more and see if I can come up with anything.

Jason Newell
Applications Architect
www.jasonnewell.net