Exemplo n.º 1
0
 public static void ExecuteAddInPlugin(string name)
 {
     if (!Autodesk.Navisworks.Api.Application.IsAutomated)
     {
         PluginRecord pluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin(name);
         if (pluginRecord is AddInPluginRecord && pluginRecord.IsEnabled)
         {
             AddInPlugin addinPlugin = (AddInPlugin)(pluginRecord.LoadedPlugin ?? pluginRecord.LoadPlugin());
             addinPlugin.Execute();
         }
     }
 }
Exemplo n.º 2
0
        private int Execute(params string[] parameters)
        {
            string       filePath     = this.ActivePlugin.AssemblyPath;
            PluginLoader pluginLoader = new PluginLoader();
            int          result;

            try
            {
                pluginLoader.HookAssemblyResolve();
                Assembly assembly = pluginLoader.LoadAddinsToTempFolder(filePath);
                if (null == assembly)
                {
                    result = 0;
                }
                else
                {
                    //this.ActiveTempFolder = pluginLoader.TempFolder;
                    AddInPlugin addInPlugin = assembly.CreateInstance(this.ActivePlugin.ClassName) as AddInPlugin;
                    if (addInPlugin == null)
                    {
                        result = 0;
                    }
                    else
                    {
                        result = addInPlugin.Execute(parameters);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                result = 0;
            }
            finally
            {
                pluginLoader.UnhookAssemblyResolve();
            }

            return(result);
        }