static void Main(string[] args) { if (args.Length > 0) { // First argument should be the debug assembly path debugPath = args[0]; } var allProducts = RevitProductUtility.GetAllInstalledRevitProducts(); var prodColl = new RevitProductCollection(allProducts.Select(x => new DynamoRevitProduct(x))); if (!prodColl.Products.Any()) { Console.WriteLine("There were no Revit products found."); return; } var installs = DynamoInstallCollection.FindDynamoInstalls(debugPath); var dynamoColl = new DynamoInstallCollection(installs); if (!dynamoColl.Installs.Any()) { Console.WriteLine("There were no Dynamo installations found."); DeleteExistingAddins(prodColl); return; } DeleteExistingAddins(prodColl); GenerateAddins(prodColl, dynamoColl); }
/// <summary> /// Gets revit install path by version number. /// </summary> /// <returns></returns> private static string GetRevitInstallPath() { var products = RevitProductUtility.GetAllInstalledRevitProducts(); var product = products.FirstOrDefault(f => f.Name.Contains(_version)); return(product.InstallLocation); }
public override void Install(IDictionary stateSaver) { // Debugger.Launch(); // make sure addin manifest is written var assemblyFolder = Path.GetDirectoryName(Context.Parameters["assemblypath"]); var assemblyPath = Path.Combine(assemblyFolder, "RevitPythonShell.dll"); var manifest = new RevitAddInManifest(); var application = new RevitAddInApplication("RevitPythonShell", assemblyPath, Guid.Parse("3a7a1d24-51ed-462b-949f-1ddcca12008d"), "RevitPythonShell.RevitPythonShellApplication", "RIPS"); manifest.AddInApplications.Add(application); var revitProducts = RevitProductUtility.GetAllInstalledRevitProducts(); if (revitProducts.Count < 1) { throw new InvalidOperationException("No Autodesk Revit products found"); } foreach (var product in revitProducts.Where(p => p.Version == RevitVersion.Revit2013)) { var manifestFolder = Context.Parameters["allusers"] == "1" ? product.AllUsersAddInFolder : product.CurrentUserAddInFolder; var manifestPath = Path.Combine(manifestFolder, "RevitPythonShell2013.addin"); manifest.SaveAs(manifestPath); } base.Install(stateSaver); }
private static string DetectAddinFileLocation(Autodesk.Revit.ApplicationServices.Application applictaion) { string addinFileFolderLocation = null; IList <RevitProduct> installedRevitList = RevitProductUtility.GetAllInstalledRevitProducts(); foreach (RevitProduct revit in installedRevitList) { if (revit.Version.ToString().Contains(applictaion.VersionNumber)) { string allUsersAddInFolder = revit.AllUsersAddInFolder; string currentUserAddInFolder = revit.CurrentUserAddInFolder; if (File.Exists(Path.Combine(allUsersAddInFolder, thisAddinFileName))) { addinFileFolderLocation = allUsersAddInFolder; } else if (File.Exists(Path.Combine(currentUserAddInFolder, thisAddinFileName))) { addinFileFolderLocation = currentUserAddInFolder; } break; } } return(addinFileFolderLocation); }
public static bool Install() { if (RevitProductUtility.GetAllInstalledRevitProducts().Count == 0) { return(false); } foreach (var product in RevitProductUtility.GetAllInstalledRevitProducts()) { if (product.Version == RevitVersion.Unknown) { continue; } var addinFile = product.CurrentUserAddInFolder + "\\rubyshell.addin"; var pluginFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("\\RevitRubyShell{0}.dll", product.Version); var manifest = File.Exists(addinFile) ? AddInManifestUtility.GetRevitAddInManifest(addinFile) : new RevitAddInManifest(); if (!File.Exists(pluginFile)) { MessageBox.Show(string.Format("{0} is not supported by this version of RevitRubyShell", product.Version), "RevitRubyShell", MessageBoxButton.OK, MessageBoxImage.Error); continue; } //Search manifest for app RevitAddInApplication app = null; foreach (var a in manifest.AddInApplications) { if (a.AddInId == AppGuid) { app = a; } } if (app == null) { app = new RevitAddInApplication("RevitRubyShell", pluginFile, AppGuid, AppClass, "NOSYK"); manifest.AddInApplications.Add(app); } else { app.Assembly = pluginFile; app.FullClassName = AppClass; } if (manifest.Name == null) { manifest.SaveAs(addinFile); } else { manifest.Save(); } MessageBox.Show(string.Format("RevitRubyShell for {0} was successully installed ", product.Version), "RevitRubyShell"); } return(true); }
/// <summary> /// 获取当前所有的Revit产品信息 /// </summary> /// <returns></returns> public IEnumerable <RevitProduct> GetRevitProducts() { IEnumerable <RevitProduct> list = ( from item in RevitProductUtility.GetAllInstalledRevitProducts() orderby item.Name select item).ToList <RevitProduct>(); return(list); }
public static IList <RevitProduct> FindRevit() { var products = RevitProductUtility.GetAllInstalledRevitProducts(); if (products.Any()) { products = products.Where(x => x.Version == RevitVersion.Revit2014).ToList(); } return(products); }
public static IList <RevitProduct> FindRevit() { var products = RevitProductUtility.GetAllInstalledRevitProducts(); if (!products.Any()) { Console.WriteLine("No versions of revit could be found"); return(null); } return(products); }
static void Main(string[] args) { bool uninstall = false; foreach (string s in args) { if (s == @"/uninstall") { uninstall = true; } else if (Directory.Exists(s)) { debugPath = s; } } if (uninstall && string.IsNullOrEmpty(debugPath)) { //just use the executing assembly location var assemblyPath = Assembly.GetExecutingAssembly().Location; debugPath = Path.GetDirectoryName(assemblyPath); } var allProducts = RevitProductUtility.GetAllInstalledRevitProducts(); var prodCollection = new RevitProductCollection(allProducts.Select(x => new DynamoRevitProduct(x))); if (!prodCollection.Products.Any()) { Console.WriteLine("There were no Revit products found."); return; } var dynamos = DynamoProducts.FindDynamoInstallations(debugPath); if (!dynamos.Products.Any()) { Console.WriteLine("No Dynamo installation found at {0}.", debugPath); DeleteExistingAddins(prodCollection); return; } DeleteExistingAddins(prodCollection); if (uninstall) { GenerateAddins(prodCollection, debugPath); } else { GenerateAddins(prodCollection); } }
public override void Uninstall(IDictionary savedState) { Debugger.Break(); // remove addin manifest var revitProducts = RevitProductUtility.GetAllInstalledRevitProducts(); if (revitProducts.Count > 0) { File.Delete(Path.Combine(revitProducts[0].CurrentUserAddInFolder, "RevitPythonShell.addin")); } base.Uninstall(savedState); }
private static bool FindRevit(IList <RevitProduct> productList) { var products = RevitProductUtility.GetAllInstalledRevitProducts(); if (!products.Any()) { Console.WriteLine("No versions of revit could be found"); return(false); } products.ForEach(productList.Add); return(true); }
public static IList <RevitProduct> FindRevit() { var products = RevitProductUtility.GetAllInstalledRevitProducts(); //For now let's return all the installed products. Sometimes the products in development //might return Unknown version. //if (products.Any()) //{ // products = products.Where(x => x.Version == RevitVersion.Revit2015 || x.Version==RevitVersion.Revit2016 || x.Version==RevitVersion.Revit2017 || x.Version==RevitVersion.Revit2018 || x.Version==RevitVersion.Revit2019).ToList(); //} return(products); }
/// <summary> /// Show all the installed Revit product information of user's PC in the tree view /// </summary> private void RevitProductsButton_Click(object sender, EventArgs e) { this.treeView1.Nodes.Clear(); TreeNode allProductsNode = this.treeView1.Nodes.Add("Installed Revit Products: "); foreach (RevitProduct revitProduct in RevitProductUtility.GetAllInstalledRevitProducts()) { TreeNode productNode = allProductsNode.Nodes.Add(revitProduct.Name); productNode.Nodes.Add("Product Name: " + revitProduct.Name); productNode.Nodes.Add("AllUsersAddInFolder: " + revitProduct.AllUsersAddInFolder); productNode.Nodes.Add("Architecture: " + revitProduct.Architecture); //productNode.Nodes.Add("Build: " + revitProduct.Build); // deprecated productNode.Nodes.Add("Current User AddIn Folder: " + revitProduct.CurrentUserAddInFolder); productNode.Nodes.Add("Install Location: " + revitProduct.InstallLocation); productNode.Nodes.Add("ProductCode: " + revitProduct.ProductCode); productNode.Nodes.Add("Version: " + revitProduct.Version); } }
public override void Uninstall(IDictionary savedState) { // Debugger.Launch(); // remove addin manifest foreach (var product in RevitProductUtility.GetAllInstalledRevitProducts().Where(p => p.Version == RevitVersion.Revit2013)) { var manifestFolder = Context.Parameters["allusers"] == "1" ? product.AllUsersAddInFolder : product.CurrentUserAddInFolder; var manifestPath = Path.Combine(manifestFolder, "RevitPythonShell2013.addin"); if (File.Exists(manifestPath)) { File.Delete(manifestPath); } } base.Uninstall(savedState); }
public override void Install(IDictionary stateSaver) { // make sure addin manifest is written var assemblyFolder = Path.GetDirectoryName(Context.Parameters["assemblypath"]); var assemblyPath = Path.Combine(assemblyFolder, "RevitPythonShell.dll"); var manifest = new RevitAddInManifest(); var application = new RevitAddInApplication("RevitPythonShell", assemblyPath, Guid.NewGuid(), "RevitPythonShell.RevitPythonShellApplication"); manifest.AddInApplications.Add(application); var revitProducts = RevitProductUtility.GetAllInstalledRevitProducts(); if (revitProducts.Count < 1) { throw new InvalidOperationException("No Autodesk Revit products found"); } manifest.SaveAs(Path.Combine(revitProducts[0].CurrentUserAddInFolder, "RevitPythonShell.addin")); base.Install(stateSaver); }
/// <summary> /// 获取当前的安装的所有revit的版本信息 /// </summary> /// <returns></returns> public List <RevitProduct> GetAllInstalledRevitProducts() { return(RevitProductUtility.GetAllInstalledRevitProducts()); }
public static IEnumerable <string> GetAllAddInLocations() { return(RevitProductUtility.GetAllInstalledRevitProducts().Select(p => p.CurrentUserAddInFolder)); }
public static string GetInstallationFolder(string revitProductName) { return((from revitProgram in RevitProductUtility.GetAllInstalledRevitProducts() where revitProgram.Name.Equals(revitProductName) select revitProgram.InstallLocation).First()); }
private static IEnumerable <RevitProduct> AllInstalledProducts() { return(RevitProductUtility.GetAllInstalledRevitProducts()); }
private static void Main(string[] args) { try { //create a new addin manifest var manifest = new RevitAddInManifest(); #if Revit2015 var revitProduct = RevitProductUtility.GetAllInstalledRevitProducts() .FirstOrDefault(p => p.Version == RevitVersion.Revit2015); const string revitVersion = "Revit 2015"; #elif Revit2016 var revitProduct = RevitProductUtility.GetAllInstalledRevitProducts() .FirstOrDefault(p => p.Version == RevitVersion.Revit2016); const string revitVersion = "Revit 2016"; #endif if (revitProduct != null) { var addinPath = Path.Combine(revitProduct.AllUsersAddInFolder, "CzechBimLibrary.addin"); //uninstall option - delete addin file if (args.FirstOrDefault() == "-u") { if (File.Exists(addinPath)) { File.Delete(addinPath); } } //install addin - create addin file and save it to register the addin else { var location = typeof(DummyReference).Assembly.Location; //create an external application var id = new Guid("936A5434-1A11-484C-BFE3-A310658180B1"); var application = new RevitAddInApplication("BimLibraryApplication", location, id, "BimLibraryAddin.AddInApplication", "ADSK"); //add both command(s) and application(s) into manifest manifest.AddInApplications.Add(application); //save manifest to a file manifest.SaveAs(addinPath); //delete shared parameter file for the case its structure has been changed //if (File.Exists(Paths.SharedParamFile)) // File.Delete(Paths.SharedParamFile); } } else { if (args.FirstOrDefault() != "-u") { MessageBox.Show( "There is no " + revitVersion + " installed on your machine. Run this again after you have Revit installed.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception e) { MessageBox.Show( "There was an error during registration of the Add-in. Tool functionality will be affected.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); #if DEBUG var log = new ExceptionLog(); log.Add(e); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path = Path.Combine(path, "RevitExceptions.xml"); log.SaveToFile(path); #endif } }