Esempio n. 1
0
            public static bool ExportDwf(
                Inventor.Application App,
                Document doc,
                string filename)
            {
                try
                {
                    TranslatorAddIn translator = App.ApplicationAddIns.get_ItemById(
                        "{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}") as TranslatorAddIn;

                    Inventor.TranslationContext ctx = App.TransientObjects.CreateTranslationContext();
                    ctx.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism;

                    Inventor.NameValueMap options = App.TransientObjects.CreateNameValueMap();

                    Inventor.DataMedium medium = App.TransientObjects.CreateDataMedium();

                    if (translator.get_HasSaveCopyAsOptions(medium, ctx, options))
                    {
                        options.set_Value("Launch_Viewer", 0);
                        options.set_Value("Publish_Mode", 62723);
                        options.set_Value("Publish_All_Sheets", 1);

                        Inventor.NameValueMap sheets       = App.TransientObjects.CreateNameValueMap();
                        Inventor.NameValueMap sheetOptions = App.TransientObjects.CreateNameValueMap();

                        sheetOptions.Add("Name", "Sheet:1");
                        sheetOptions.Add("3DModel", false);
                        sheets.set_Value("Sheet1", sheetOptions);

                        options.set_Value("Sheets", sheets);
                    }

                    medium.FileName = filename;

                    translator.SaveCopyAs(doc, ctx, options, medium);

                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }