Why the method of Saveas can't setting th FileVersion

Why the method of Saveas can't setting th FileVersion

Anonymous
Not applicable
520 Views
1 Reply
Message 1 of 2

Why the method of Saveas can't setting th FileVersion

Anonymous
Not applicable

I want write a automation to realize one function convert batch file into low  fileversion,

but the method of saveas can't find the parameter.

 

 

0 Likes
521 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

After checking the code you sent to me in private box, it is obvious you wrote the codes wrongly. Since the variable SaveToVersion is null, it cannot definetely work. Please refer to the code snippet below.

 

In addition, a kindly reminding:  remember to share enough code demo thus other peers could diagnose what the problem is. Otherwise, it is hard to priovide a comment only with such short description.

 

// in the plugin

 

//Add two new namespaces
using Nw = Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;

namespace myPlugin
{
    [PluginAttribute("myPlugin", 
                   "ADSK",                  
                   ToolTip = "",
                   DisplayName = "MyPlugin")]         



    public class ABatchSaveAs : AddInPlugin                 
    {
        public override int Execute(params string[] parameters)
        {
           try

           {

                    Nw.ApplicationParts.ApplicationAutomation oApp = Nw.Application.Automation;

                    oApp.OpenFile("c:\\orignalfile.nwd");

                    Nw.Document oCurrentDoc = Nw.Application.ActiveDocument;
                   // Nw.DocumentFileVersion oCurrentFVer = Nw.DocumentFileVersion.Current;
 
                    oCurrentDoc.SaveFile("c:\\newfile.nwd", DocumentFileVersion.Navisworks2011);
               
            }
            catch (Exception es)
            {
                MessageBox.Show("an error occured when  saving!");
            }

            return 0;
        }
    }
}



0 Likes