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

Revision history [back]

To answer the second part most internal loads instances in OpenStudio have a method '.schedule' that returns an optional schedule. Below is a link to the SDK and how you would test if there is a schedule assigned, and get it if it exists. https://openstudio-sdk-documentation.s3.amazonaws.com/cpp/OpenStudio-1.10.0-doc/model/html/classopenstudio_1_1model_1_1_lights.html

if.lights_instance.schedule.is_initialized
  schedule = lights_instance.schedule.get
else
  puts "#{lights_instance.name} does not have a schedule assigned"
end

To answer the second part most internal loads instances in OpenStudio have a method '.schedule' that returns an optional schedule. Below is a link to the SDK and how you would test if there is a schedule assigned, and get it if it exists. https://openstudio-sdk-documentation.s3.amazonaws.com/cpp/OpenStudio-1.10.0-doc/model/html/classopenstudio_1_1model_1_1_lights.html

if.lights_instance.schedule.is_initialized
  schedule = lights_instance.schedule.get
else
  puts "#{lights_instance.name} does not have a schedule assigned"
end

Updated: Below I added some guidance for using the API documentation.

The Developers section of the OpenStudio website links to the SDK Documentation. When you get to that page you will generally click on "model" for the current release. You can also look at last iteration. This is not specifically the "model object" but rather the API for all model objects (which just happens to have an object called "model" that has some methods).

image description

Once you are on the page for the model API you can start to type a class name in the search dialog near the top right. It auto completes as shown below where I'm search for Space.

image description

The screenshot below shows you all methods available directly to the space object.

image description

But the space is a sub-class so there are many methods from parent classes. The screenshot below shows you how to see a tree of parent classes.

image description

You can click on a parent to specifically see methods for the parent class, or you can click on "List of all members" to see a flat view of all methods (included inherited methods from parent classes like object.name). This is shown in the screenshot below.

image description

In the documentation you can see if a method that gets something out of the model returns an optional value or not. If it does have an optional value you want to use 'if value.is_initialized" or "if not value.empty?" first to see if the optional has anything or not. If it passes that test then to actually get the value you need to do "value.get". If you try to do "value.get" on an object that doesn't have a value you get a ruby error. That is why you first check if it has a value before you get it.

To answer the second part most internal loads instances in OpenStudio have a method '.schedule' that returns an optional schedule. Below is a link to the SDK and how you would test if there is a schedule assigned, and get it if it exists. https://openstudio-sdk-documentation.s3.amazonaws.com/cpp/OpenStudio-1.10.0-doc/model/html/classopenstudio_1_1model_1_1_lights.html

if.lights_instance.schedule.is_initialized
  schedule = lights_instance.schedule.get
else
  puts "#{lights_instance.name} does not have a schedule assigned"
end

Updated: Below I added some guidance for using the API documentation.

The Developers section of the OpenStudio website links to the SDK Documentation. When you get to that page you will generally click on "model" for the current release. You can also look at last iteration. This is not specifically the "model object" but rather the API for all model objects (which just happens to have an object called "model" that has some methods).

image description

Once you are on the page for the model API you can start to type a class name in the search dialog near the top right. It auto completes as shown below where I'm search for Space.

image description

The screenshot below shows you all methods available directly to the space object.

image description

But the space is a sub-class so there are many methods from parent classes. The screenshot below shows you how to see a tree of parent classes.

image description

You can click on a parent to specifically see methods for the parent class, or you can click on "List of all members" to see a flat view of all methods (included inherited methods from parent classes like object.name). This is shown in the screenshot below.

image description

In the documentation you can see if a method that gets something out of the model returns an optional value or not. If it does have an optional value you want to use 'if value.is_initialized" or "if not value.empty?" first to see if the optional has anything or not. If it passes that test then to actually get the value you need to do "value.get". If you try to do "value.get" on an object that doesn't have a value you get a ruby error. That is why you first check if it has a value before you get it.

Few bonus items. You can click "Object Index" under "Objects" to view list of all objects. You can click an object to go to its SDK documentation. image description

If you are really daring you can view this as a tree by going to "Object Hierarchy". Make sure you scroll down to see the content as shown below. You can use a search with your browse to find specific objects.

image description

To answer the second part most internal loads instances in OpenStudio have a method '.schedule' that returns an optional schedule. Below is a link to the SDK and how you would test if there is a schedule assigned, and get it if it exists. https://openstudio-sdk-documentation.s3.amazonaws.com/cpp/OpenStudio-1.10.0-doc/model/html/classopenstudio_1_1model_1_1_lights.html

if.lights_instance.schedule.is_initialized
  schedule = lights_instance.schedule.get
else
  puts "#{lights_instance.name} does not have a schedule assigned"
end

Updated: Below I added some guidance for using the API documentation.

The Developers section of the OpenStudio website links to the SDK Documentation. When you get to that page you will generally click on "model" for the current release. You can also look at last iteration. This is not specifically the "model object" but rather the API for all model objects (which just happens to have an object called "model" that has some methods).

image description

Once you are on the page for the model API you can start to type a class name in the search dialog near the top right. It auto completes as shown below where I'm search for Space.

image description

The screenshot below shows you all methods available directly to the space object.

image description

But the space is a sub-class so there are many methods from parent classes. The screenshot below shows you how to see a tree of parent classes.

image description

You can click on a parent to specifically see methods for the parent class, or you can click on "List of all members" to see a flat view of all methods (included inherited methods from parent classes like object.name). This is shown in the screenshot below.

image description

In the documentation you can see if a method that gets something out of the model returns an optional value or not. If it does have an optional value you want to use 'if value.is_initialized" or "if not value.empty?" first to see if the optional has anything or not. If it passes that test then to actually get the value you need to do "value.get". If you try to do "value.get" on an object that doesn't have a value you get a ruby error. That is why you first check if it has a value before you get it.

Few bonus items. You can click "Object Index" under "Objects" to view list of all objects. You can click an object to go to its SDK documentation. image description

If you are really daring you can view this as a tree by going to "Object Hierarchy". Make sure you scroll down to see the content as shown below. You can use a search with your browse browser to find specific objects.

image description

To answer the second part most internal loads instances in OpenStudio have a method '.schedule' that returns an optional schedule. Below is a link to the SDK and how you would test if there is a schedule assigned, and get it if it exists. https://openstudio-sdk-documentation.s3.amazonaws.com/cpp/OpenStudio-1.10.0-doc/model/html/classopenstudio_1_1model_1_1_lights.html

if.lights_instance.schedule.is_initialized
  schedule = lights_instance.schedule.get
else
  puts "#{lights_instance.name} does not have a schedule assigned"
end

Updated: Below I added some guidance for using the API documentation.

The Developers section of the OpenStudio website links to the SDK Documentation. When you get to that page you will generally click on "model" for the current release. You can also look at last iteration. This is not specifically the "model object" but rather the API for all model objects (which just happens to have an object called "model" that has some methods).

image description

Once you are on the page for the model API you can start to type a class name in the search dialog near the top right. It auto completes as shown below where I'm search for Space.

image description

The screenshot below shows you all methods available directly to the space object.

image description

But the space is a sub-class so there are many methods from parent classes. The screenshot below shows you how to see a tree of parent classes.

image description

You can click on a parent to specifically see methods for the parent class, or you can click on "List of all members" to see a flat view of all methods (included inherited methods from parent classes like object.name). This is shown in the screenshot below.

image description

In the documentation you can see if a method that gets something out of the model returns an optional value or not. If it does have an optional value you want to use 'if value.is_initialized" or "if not value.empty?" first to see if the optional has anything or not. If it passes that test then to actually get the value you need to do "value.get". If you try to do "value.get" on an object that doesn't have a value you get a ruby error. That is why you first check if it has a value before you get it.

Few bonus items. You can click "Object Index" under "Objects" to view list of all objects. You can click an object to go to its SDK documentation. image description

If you are really daring you can view this as a tree by going to "Object Hierarchy". Make sure you scroll down to see the content as shown below. You can use a search with your browser to find specific objects.

image description

And here is a look at OS:Material and all the its sub-classes.

image description