Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

cemal's profile - activity

2016-09-30 12:00:18 -0500 commented answer Loading and editing an .osm file in OS C# binding

I was modifying it to simplify the post. You're right @macumber, I corrected the path and everything is working. Thanks again for your support.

2016-09-30 04:27:33 -0500 commented answer Loading and editing an .osm file in OS C# binding

Thanks @macumber, even if I changed the code as you suggested, I couldn't get and warning and/or error message. I've edited the question and explained what I did.

2016-09-30 04:27:33 -0500 received badge  Commentator
2016-09-29 04:58:50 -0500 received badge  Scholar (source)
2016-09-29 04:58:47 -0500 commented question How to get start modeling with OS C# Binding

I've closed the question and open a new one to continue the discussion on loading and modifying an .osm file from c#. I've also joined the slack channel. Thanks.

2016-09-29 04:52:28 -0500 asked a question 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 image description 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 :

image description

Unfortunately, I couldn't get any error or warning message printed. How can we proceed ?

2016-09-28 05:48:19 -0500 commented question How to get start modeling with OS C# Binding

Thanks @macumber, I successfully load an idf file. However, still having issues to load and modify an osm file as explained in the modified question.

2016-09-27 12:30:07 -0500 commented answer How to get start modeling with OS C# Binding

Thanks @macumber, I've tried your recommendations and edited the question with new issues.

2016-09-23 04:18:01 -0500 commented answer Use C# SqlFile to get the Energy Plus result

An unhandled exception of type 'System.TypeInitializationException' occurred in OpenStudio.dll

Additional information: The type initializer for 'OpenStudio.OpenStudioUtilitiesCorePINVOKE' threw an exception.

Any idea to fix this exception ?

An unhandled exception of type 'System.TypeInitializationException' occurred in OpenStudio.dll

2016-09-23 04:17:43 -0500 commented answer Use C# SqlFile to get the Energy Plus result

I'm using OpenStudio 1.12.0 with EnergyPlusV8-5-0. There is no .sql file within Examples folder. Hence, I use one of .idf files to generate a, .sql file. Although a simple simulation model runs and generates outputs -including an .sql-file, code in the above returns the following exception : (see the next comment)

2016-09-22 12:32:26 -0500 commented answer Use C# SqlFile to get the Energy Plus result

@MatthewSteen, I tried to add my post as a comment but due to its length, I couldn't do that. I believe that my post is highly related with the original question and the proposed answer.

2016-09-22 11:33:43 -0500 commented answer How to get start modeling with OS C# Binding

Thanks @macumber for your answer but problem still exists. I've edited my question to give more insight and explain what I tried.

2016-09-22 11:32:30 -0500 received badge  Editor (source)
2016-09-22 08:52:59 -0500 received badge  Teacher (source)
2016-09-21 17:32:33 -0500 commented question How to get start modeling with OS C# Binding

@David Goldwasser I need to directly interact with the OpenStudio API. Thanks in advance.

2016-09-21 10:35:59 -0500 received badge  Student (source)
2016-09-21 10:35:44 -0500 asked a question How to get start modeling with OS C# Binding

I'm trying to learn modelling building energy systems through OS C# binding. Is there any complete tutorial to be used ? I've tried the following questions and answers but found them not complete :

  1. https://unmethours.com/question/19848...
  2. https://unmethours.com/question/19123...
  3. https://unmethours.com/question/17865...
  4. https://unmethours.com/question/15093...
  5. https://unmethours.com/question/11404...
  6. https://github.com/NREL/OpenStudio/tr...
  7. https://unmethours.com/question/11881...
  8. http://nrel.github.io/OpenStudio-user...
  9. https://unmethours.com/question/9864/...
  10. https://unmethours.com/questions/1264...

A minimal example to run a simple model would be more than enough.

Edit after @macumber's answer :

Based on your suggestion, I've copied Alpha1 C# example to a different directory and also copy all dependent dll files into the corresponding folder and follow the instructions given here . Implementation executes without an error and produce a form to import .idf files. When I load the idf file here C:\Program Files\OpenStudio 1.12.0\Examples\resultsviewer\SmallOffice\SmallOffice.idf and say "Go", I got the following error message (similar error message are noted in this message also ):

image description

Based on this, I've the following questions/issues :

  1. When the problem is resolved, will I be able to modify the simulation model (SmallOffice.idf) from C# ? Which methods should I use for this ?
  2. Inline with this error message, I wanted to test my OS installation with a different setting and used the implementation given here. However, this time I got the following exception image description
  3. Then, I minimize the code in (3) to check what is wrong as in the following :

    Path path = new Path("C:\Desktop\testModel.osm") but still get the same error.

  4. If the problem resolved, is the following code starting point to modify a model in C# ? If not, what should I do to load/create and execute a simple simulation model (.idf and or .osm files) from C# API ? Which methods should I use ?

     Path path = new Path("C:\\Desktop\\testModel.osm");
     OpenStudio.Model model = OpenStudio.Model.load(path).get();
    

Note that, the second line of the code was previously mentioned in this and this answers/questions.

Edit after @macumber's comments

  1. I've ensured that all dlls are copied and solution configuration set as x64 accordingly as in the following : image description However, after that, I got the following error message :

Error CS0104 'Application' is an ambiguous reference between 'System.Windows.Forms.Application' and 'OpenStudio.Application' Alpha1 D:\OpenStudio\Alpha1\Alpha1\Program.cs 24 Active

so that I modified the code in Alpha1 as in the following :

         System.Windows.Forms.Application.EnableVisualStyles();
         System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
         System.Windows.Forms.Application.Run(new MainForm());

now, the form successfully created but I got an exception when I want to load an IDF file (clicking the pointed button in the following picture)

image description

Here is the exception and highlighted code segment in MainForm.cs that cause the exception

image description

What I observed is, I was able to successfully clicking that button and pointing an IDF file ... (more)

2016-09-21 10:16:34 -0500 answered a question Use C# SqlFile to get the Energy Plus result

I'm using OpenStudio 1.12.0 with EnergyPlusV8-5-0. There is no .sql file within Examples folder. Hence, I use one of .idf files to generate a, .sql file. Although a simple simulation model runs and generates outputs -including an .sql-file, code in the above returns the following exception :

An unhandled exception of type 'System.TypeInitializationException' occurred in OpenStudio.dll

Additional information: The type initializer for 'OpenStudio.OpenStudioUtilitiesCorePINVOKE' threw an exception.

Any idea to fix this exception ?

An unhandled exception of type 'System.TypeInitializationException' occurred in OpenStudio.dll

2016-09-21 08:54:18 -0500 answered a question **FATAL:IP: Errors occurred on processing IDF file. Preceding condition(s) cause termination.

This solution worked for me. Better to re-check FATAL error.

2016-08-29 13:11:59 -0500 commented answer How to set up Visual Studio to use C# bindings

None of above suggestions worked for me. In addition, where can I find API document for OpenStudio to be used from C# ?