Пример #1
0
        CreateEnvJson()
        {
            // collecet search paths
            var searchPaths = new List <string>()
            {
                PyRevitConsts.DefaultExtensionsPath
            };

            searchPaths.AddRange(PyRevitExtensions.GetRegisteredExtensionSearchPaths());

            // collect list of lookup sources
            var lookupSrc = new List <string>()
            {
                PyRevitExtensions.GetDefaultExtensionLookupSource()
            };

            lookupSrc.AddRange(PyRevitExtensions.GetRegisteredExtensionLookupSources());

            // create json data object
            var jsonData = new Dictionary <string, object>()
            {
                { "meta", new Dictionary <string, object>()
                  {
                      { "version", "0.1.0" }
                  } },
                { "clones", PyRevitClones.GetRegisteredClones() },
                { "attachments", PyRevitAttachments.GetAttachments() },
                { "extensions", PyRevitExtensions.GetInstalledExtensions() },
                { "searchPaths", searchPaths },
                { "lookupSources", lookupSrc },
                { "installed", RevitProduct.ListInstalledProducts() },
                { "running", RevitController.ListRunningRevits() },
                { "pyrevitDataDir", PyRevitLabsConsts.PyRevitPath },
                { "userEnv", new Dictionary <string, object>()
                  {
                      { "osVersion", UserEnv.GetWindowsVersion() },
                      { "execUser", string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName) },
                      { "activeUser", UserEnv.GetLoggedInUserName() },
                      { "isAdmin", UserEnv.IsRunAsAdmin() },
                      { "userAppdata", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) },
                      { "latestFramework", UserEnv.GetInstalledDotNetVersion() },
                      { "targetPacks", UserEnv.GetInstalledDotnetTargetPacks() },
                      { "targetPacksCore", UserEnv.GetInstalledDotnetCoreTargetPacks() },
                      { "cliVersion", PyRevitCLI.CLIVersion },
                  } },
            };

            var jsonExportCfg = new JsonSerializerSettings {
                Error = delegate(object sender, pyRevitLabs.Json.Serialization.ErrorEventArgs args) {
                    args.ErrorContext.Handled = true;
                },
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            jsonExportCfg.Converters.Add(new JsonVersionConverter());

            return(JsonConvert.SerializeObject(jsonData, jsonExportCfg));
        }
 PrintLocalRevits(bool running = false)
 {
     if (running)
     {
         PyRevitCLIAppCmds.PrintHeader("Running Revit Instances");
         foreach (var revit in RevitController.ListRunningRevits().OrderByDescending(x => x.RevitProduct.Version))
         {
             Console.WriteLine(revit);
         }
     }
     else
     {
         PyRevitCLIAppCmds.PrintHeader("Installed Revits");
         foreach (var revit in RevitProduct.ListInstalledProducts().OrderByDescending(x => x.Version))
         {
             Console.WriteLine(revit);
         }
     }
 }
Пример #3
0
 public static bool RevitsAreRunning()
 {
     return(RevitController.ListRunningRevits().Count > 0);
 }