Exemple #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));
        }
Exemple #2
0
 PrintExtensionLookupSources()
 {
     PyRevitCLIAppCmds.PrintHeader("Extension Sources - Default");
     Console.WriteLine(PyRevitExtensions.GetDefaultExtensionLookupSource());
     PyRevitCLIAppCmds.PrintHeader("Extension Sources - Additional");
     foreach (var extLookupSrc in PyRevitExtensions.GetRegisteredExtensionLookupSources())
     {
         Console.WriteLine(extLookupSrc);
     }
 }