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)); }
// clear cache // @handled @logs public static void ClearCache(int revitYear) { // make sure all revit instances are closed if (CommonUtils.VerifyPath(PyRevitLabsConsts.PyRevitPath)) { RevitController.KillRunningRevits(revitYear); CommonUtils.DeleteDirectory(GetCacheDirectory(revitYear)); } // it's just clearing caches. Let's not be paranoid and throw an exception is directory does not exist // if it's not there, the clear cache request is technically already satisfied //else // throw new pyRevitResourceMissingException(pyRevitAppDataPath); }
KillAllRevits(string revitYear) { int revitYearNumber = 0; if (int.TryParse(revitYear, out revitYearNumber)) { RevitController.KillRunningRevits(revitYearNumber); } else { RevitController.KillAllRunningRevits(); } }
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); } } }
public static bool RevitsAreRunning() { return(RevitController.ListRunningRevits().Count > 0); }