Exemplo n.º 1
0
        /// <summary>
        /// Creates DynamoAddinData to generate addin for given Revit product
        /// based on latest Dynamo installed on the system.
        /// </summary>
        /// <param name="revit">Revit Product for which addin to be generated </param>
        /// <param name="dynamos">Dynamo products installed on the system</param>
        /// <param name="dynamoUninstallPath">dynamo path being uninstalled, can be
        /// null or empty string</param>
        /// <returns>DynamoAddinData</returns>
        public static DynamoAddinData Create(IRevitProduct revit, DynamoProducts dynamos, string dynamoUninstallPath)
        {
            //Iterate in reverse order to find the first dynamo that is supported for
            //this revit product
            var products = dynamos.Products.Reverse();

            foreach (var p in products)
            {
                //If the current product is being uninstalled, don't generate addin data
                if (DynamoInstall.PathEquals(p.InstallLocation, dynamoUninstallPath))
                {
                    continue;
                }

                var path = Path.Combine(p.InstallLocation, "DynamoRevit.dll");
                //Should be 0.6.3 only supported for Revit2014
                if (File.Exists(path) && revit.VersionString == "Revit2014")
                {
                    return(new DynamoAddinData(revit, new DynamoInstall(p.InstallLocation)));
                }

                var subfolder = revit.VersionString.Insert(5, "_");
                path = Path.Combine(p.InstallLocation, subfolder, "DynamoRevitVersionSelector.dll");
                if (File.Exists(path))
                {
                    return(new DynamoAddinData(revit, new DynamoInstall(p.InstallLocation)));
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// DynamoAddinData constructor.
        /// </summary>
        /// <param name="product">A revit product to target for addin creation.</param>
        /// <param name="latestDynamoInstall">The newest Dynamo version installed on the machine.</param>
        internal DynamoAddinData(IRevitProduct product, IDynamoInstall latestDynamoInstall)
        {
            //Convert RevitXXXX to Revit_XXXX
            var subfolder = product.VersionString.Insert(5, "_");

            //Pre 0.7.x release
            if (DynamoInstall.PathEquals(latestDynamoInstall.Folder, DynamoVersions.dynamo_063))
            {
                ClassName    = "Dynamo.Applications.DynamoRevitApp";
                AssemblyPath = Path.Combine(latestDynamoInstall.Folder, "DynamoRevit.dll");
            }
            else
            {
                ClassName = "Dynamo.Applications.VersionLoader";
                const string assemblyName = "DynamoRevitVersionSelector.dll";

                AssemblyPath = Path.Combine(latestDynamoInstall.Folder, subfolder, assemblyName);
            }

            RevitSubfolder = subfolder;
            AddinPath      = Path.Combine(product.AddinsFolder, "Dynamo.addin");
        }