Felipe
Felipe

Reputation: 4375

Running external executable from Design Automation job?

The goal is to run a c++ executable from a Revit DA job in order to do some mesh processing using a 3rd party library. I'm investigating that track first so it removes the need to write custom .Net bindings to interact with the c++ lib... Unfortunately I am getting the following error:

[10/04/2023 19:46:31] Exception RunMeshOptimizer: Not enough quota is available to process this command
[10/04/2023 19:46:31] StackTrace:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
[10/04/2023 19:46:31]    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
[10/04/2023 19:46:31]    at Keystone.DA.Revit.Net.Commands.RunMeshOptimizer(JObject opts, String inputFile, String outputFile)

The c++ test code is very straightforward so I doubt it consumes a lot of memory:

#include <iostream>
#include <fstream>  

int main(int argc, char* argv[])
{

    std::ofstream outfile("test.txt");

    outfile << "test" << std::endl;

    outfile.flush();
    outfile.close();
}

The executable is included in the DA bundle and invoked from .Net as follow:

var asm = Assembly.GetExecutingAssembly();

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = false;
startInfo.FileName = Path.Combine(Path.GetDirectoryName(asm.Location), "MeshOptimizer.exe");

using (Process exeProcess = Process.Start(startInfo))
{
   exeProcess.WaitForExit();
}

My question is if there is any kind of known limitation in spawning external exe from a DA job?

Upvotes: 0

Views: 141

Answers (1)

Adam Nagy
Adam Nagy

Reputation: 2175

In general, running custom programs should be possible on Design Automation servers: Run additional programs inside a WorkItem
The problem might be specific to running the exe from inside a Revit app bundle (the team will investigate that) and running it after the RevitCoreConsole finished should be fine.

I did check running a custom exe on DA4R server and that worked fine for me: enter image description here

So, I guess you could just run your custom exe as a second item in the commandLine array. This is the first solution in the blog post I referenced above - something like:

"commandLine": [
  "$(engine.path)\\RevitCoreConsole.exe /al \"$(appbundles[MyBundle].path)\"",
  "\"$(appbundles[MyBundle].path)\\MyBundlePlugin.bundle\\Contents\\MeshOptimizer.exe\""
]

Upvotes: 0

Related Questions