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

Revision history [back]

This should be about the same in C# as it is in C++. You will want to get the YearDescription object from the model using the method:

getYearDescription(model) // this method is not in C++, it is added by [this SWIG macro](https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/Model_Common_Include.i#L268)

Then you can call your setDayofWeekforStartDay method on it. It is a little confusing but there is another class named YearDescription which is not part of the OpenStudio model, that class is in the utilities namespace and is likely what you were seeing.

This should be about the same in C# as it is in C++. You will want to get the YearDescription object from the model using the method:

getYearDescription(model) // this method is not in C++, it is added by [this SWIG macro](https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/Model_Common_Include.i#L268)

Then you can call your setDayofWeekforStartDay method on it. It is a little confusing but there is another class named YearDescription which is not part of the OpenStudio model, that class is in the utilities namespace and is likely what you were seeing.

UPDATED ANSWER

It looks like you are hitting a peculiarity of the C# bindings. Because all the classes are in the OpenStudio namespace, there are some naming conflicts in C# that don't occur in C++ or Ruby. Here is some code that should work:

OpenStudio.Model model = new OpenStudio.Model();

// create the year description object, the free function is defined in the namespace
// OpenStudioModelSimulation because it is instantiated in 
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/ModelSimulation.i
OpenStudio.OpenStudioModelSimulation.getYearDescription(model);

// openstudio::model::YearDescription class conflicts with openstudio::YearDescription in C#
// we can use the OpenStudio Model's Workspace accessor methods as a workaround
// get all objects of type "OS:YearDescription", we know there will be once since it was created above
OpenStudio.WorkspaceObjectVector yds = model.getObjectsByType(new OpenStudio.IddObjectType("OS:YearDescription"));

// we can call WorkspaceObject methods to set values on this object, see the OpenStudio.idd for available fields, 
// indexes start at 0
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/resources/model/OpenStudio.idd
yds[0].setString(2, "Monday");

This should be about the same in C# as it is in C++. You will want to get the YearDescription object from the model using the method:

getYearDescription(model) // this method is not in C++, it is added by [this SWIG macro](https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/Model_Common_Include.i#L268)

Then you can call your setDayofWeekforStartDay method on it. It is a little confusing but there is another class named YearDescription which is not part of the OpenStudio model, that class is in the utilities namespace and is likely what you were seeing.

UPDATED ANSWER

It looks like you are hitting a peculiarity of the C# bindings. Because all the classes are in the OpenStudio namespace, there are some naming conflicts in C# that don't occur in C++ or Ruby. Here is some code that should work:

OpenStudio.Model model = new OpenStudio.Model();

// create the year description object, the free function is defined in the namespace
// OpenStudioModelSimulation because it is instantiated in 
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/ModelSimulation.i
OpenStudio.OpenStudioModelSimulation.getYearDescription(model);

// openstudio::model::YearDescription class conflicts with openstudio::YearDescription in C#
// we can use the OpenStudio Model's Workspace accessor methods as a workaround
// get all objects of type "OS:YearDescription", we know there will be once one since it was created above
OpenStudio.WorkspaceObjectVector yds = model.getObjectsByType(new OpenStudio.IddObjectType("OS:YearDescription"));

// we can call WorkspaceObject methods to set values on this object, 
// see the OpenStudio.idd for available fields, 
// indexes start at 0
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/resources/model/OpenStudio.idd
yds[0].setString(2, "Monday");

This should be about the same in C# as it is in C++. You will want to get the YearDescription object from the model using the method:

getYearDescription(model) // this method is not in C++, it is added by [this SWIG macro](https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/Model_Common_Include.i#L268)

Then you can call your setDayofWeekforStartDay method on it. It is a little confusing but there is another class named YearDescription which is not part of the OpenStudio model, that class is in the utilities namespace and is likely what you were seeing.

UPDATED ANSWER

It looks like you are hitting a peculiarity of the C# bindings. Because all the classes are in the OpenStudio namespace, there are some naming conflicts in C# that don't occur in C++ or Ruby. Here is some code that should work:

OpenStudio.Model model = new OpenStudio.Model();

// create the year description object, the free function is defined in the namespace
// OpenStudioModelSimulation because it is instantiated in  ModelSimulation.i
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/ModelSimulation.i
OpenStudio.OpenStudioModelSimulation.getYearDescription(model);

// openstudio::model::YearDescription class conflicts with openstudio::YearDescription in C#
// we can use the OpenStudio Model's Workspace accessor methods as a workaround
// get all objects of type "OS:YearDescription", we know there will be one since it was created above
OpenStudio.WorkspaceObjectVector yds = model.getObjectsByType(new OpenStudio.IddObjectType("OS:YearDescription"));

// we can call WorkspaceObject methods to set values on this object, 
// see the OpenStudio.idd for available fields, indexes start at 0
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/resources/model/OpenStudio.idd
yds[0].setString(2, "Monday");

This should be about the same in C# as it is in C++. You will want to get the YearDescription object from the model using the method:

getYearDescription(model) // this method is not in C++, it is added by [this SWIG macro](https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/Model_Common_Include.i#L268)

Then you can call your setDayofWeekforStartDay method on it. It is a little confusing but there is another class named YearDescription which is not part of the OpenStudio model, that class is in the utilities namespace and is likely what you were seeing.

UPDATED ANSWER

It looks like you are hitting a peculiarity of the C# bindings. Because all the classes are in the OpenStudio namespace, there are some naming conflicts in C# that don't occur in C++ or Ruby. Here is some code that should work:

OpenStudio.Model model = new OpenStudio.Model();

// create the year description object, the free function is defined in the namespace
// OpenStudioModelSimulation because it is instantiated in ModelSimulation.i
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/src/model/ModelSimulation.i
OpenStudio.OpenStudioModelSimulation.getYearDescription(model);

// openstudio::model::YearDescription class conflicts with openstudio::YearDescription in C#
// we can use the OpenStudio Model's Workspace accessor methods as a workaround
// get all objects of type "OS:YearDescription", we know there will be one since it was created above
OpenStudio.WorkspaceObjectVector yds = model.getObjectsByType(new OpenStudio.IddObjectType("OS:YearDescription"));

// we can call WorkspaceObject methods to set values on this object, 
// see the OpenStudio.idd for available fields, indexes start at 0
// https://github.com/NREL/OpenStudio/blob/develop/openstudiocore/resources/model/OpenStudio.idd
yds[0].setString(2, "Monday");
"Sunday");