Loading and editing an .osm file in OS C# binding
Hi everyone,
This question is continuation of my previous post. In that question, I resolved the issue of running Alpha1 test C# implementation with @macumber's helps. As he suggested and since the previous post getting massive, I'm posting the new question here.
I'm trying to load and modify an .osm file via OpenStudio C# binding using Visual Studio 2015. I've a "testModel.osm" file that is working via OpenStudio GUI without any problem. I'm using the following code segment to load it in C#.
Path path = new Path("C:\\Desktop\\testModel.osm");
OpenStudio.Model model = OpenStudio.Model.load(path).get();
and having the following exception O also changed the second line with the following two lines but still having the same exception
OpenStudio.VersionTranslator translator = new OpenStudio.VersionTranslator();
OpenStudio.Model model = translator.loadModel(path).get();
Note that execution of the following line alone is perfectly fine.
Path path = new Path("C:\\Desktop\\testModel.osm");
Thanks for your helps in advance.
Edit after @macumber's comment:
Thanks @macumber, I modify the implementation as in the following :
Path path = new Path("C:\\Desktop\\testModel.osm");
OpenStudio.VersionTranslator translator = new OpenStudio.VersionTranslator();
OpenStudio.OptionalModel optionalModel = translator.loadModel(path);
foreach(var i in translator.errors())
{
Console.WriteLine(i.logMessage());
}
foreach(var i in translator.warnings())
{
Console.WriteLine(i.logMessage());
}
if (optionalModel.is_initialized())
{
OpenStudio.Model model = optionalModel.get();
Console.WriteLine("optional model is initialised");
}
else
{
Console.WriteLine("optional model is not initialized");
}
And here is the console output after executing the program :
Unfortunately, I couldn't get any error or warning message printed. How can we proceed ?