public static PyRevitRunnerExecEnv Run(PyRevitAttachment attachment, string scriptPath, IEnumerable <string> modelPaths, PyRevitRunnerOptions opts = null) { var product = attachment.Product; var clone = attachment.Clone; var engineVer = attachment.Engine != null ? attachment.Engine.Version : 0; logger.Debug("Running script: \"{0}\"", scriptPath); logger.Debug("With: {0}", product); logger.Debug("Using: {0}", clone); logger.Debug("On Engine: {0}", engineVer); // setup the execution environment if (opts is null) { opts = new PyRevitRunnerOptions(); } var execEnv = new PyRevitRunnerExecEnv(attachment, scriptPath, modelPaths); // purge files if requested if (opts.ImportPath != null) { execEnv.CopyExistingAddons(opts.ImportPath); } // run the process ProcessStartInfo revitProcessInfo = new ProcessStartInfo(product.ExecutiveLocation) { Arguments = execEnv.JournalFile, WorkingDirectory = execEnv.WorkingDirectory, UseShellExecute = false, CreateNoWindow = true }; logger.Debug("Running Revit in playback mode with journal: \"{0}\"", execEnv.JournalFile); var revitProcess = Process.Start(revitProcessInfo); revitProcess.WaitForExit(); // purge files if requested if (opts.PurgeTempFiles) { execEnv.Purge(); } return(execEnv); }
public PyRevitRunnerExecEnv(PyRevitAttachment attachment) { Attachment = attachment; // check if clone is compatible if (!CommonUtils.VerifyFile(PyRevitCloneRunner)) { throw new PyRevitException("Clone does not have Run feature. Update your clone to latest."); } // generate unique id for this execution ExecutionId = Guid.NewGuid().ToString(); // setup working dir WorkingDirectory = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), ExecutionId); CommonUtils.EnsurePath(WorkingDirectory); }
public PyRevitRunnerExecEnv(PyRevitAttachment attachment, string script, IEnumerable <string> modelPaths) { Attachment = attachment; Script = script; ModelPaths = modelPaths; // check if clone is compatible if (!CommonUtils.VerifyFile(PyRevitCloneRunner)) { throw new PyRevitException("Clone does not have Run feature. Update your clone to latest."); } // generate unique id for this execution ExecutionId = Guid.NewGuid().ToString(); // setup working dir WorkingDirectory = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), ExecutionId); CommonUtils.EnsurePath(WorkingDirectory); // generate journal and manifest file GenerateJournal(); GenerateManifest(); }