I am trying to write a simple ruby script but I keep getting the following error: Undefined local variable for main: Object (NameError)

asked 2021-07-09 05:47:07 -0500

Fatima1991's avatar

updated 2021-07-09 16:36:09 -0500

I am trying to write a simple ruby script but I keep getting the following error: Undefined local variable for main: Object (NameError)

new_lightshelf =subsurfaces[11].addDaylightingDeviceShelf() 
      #<OpenStudio::Model::OptionalDaylightingDeviceShelf:0x0001c817a91b78>
       new_lightshelf.empty
       false
       aa=new_lightshelf.get
       OS=DaylightingDevice=Shelf,
       #{d3e8c95e-9f08-4a5-8acf4-c2b79d7df8c4},   !- Handle
       #Daylighting Device Shelf 1,            !- Name
       #{72f98f0b-6b8a-4ba6-920d-83994f4287e7}; !- Window Name
       #aa.class
       #OpenStudio::Model::DaylightingDeviceShelf
       aa.name
       #Daylighting Device Shelf 1
edit retag flag offensive close merge delete

Comments

@Fatima1991 this seems to be the same as this question. I will close the other question, please make just one post for a question in the future.

Aaron Boranian's avatar Aaron Boranian  ( 2021-07-09 07:41:32 -0500 )edit

The code in your example is a little confusing and it is unclear what line the error is on. Related ot the first line do you have opaque subsurfaces or skylights that would not return a lightshelf. See documentation here. You should check if it is empty and then only use .get if it isn't empty.

David Goldwasser's avatar David Goldwasser  ( 2021-07-10 01:54:43 -0500 )edit