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

Revision history [back]

This is my bad. I had tried with an array doing plant_loops_tokeep = [] and then 'plant_loops_tokeep += plant_loop` but it didn't work. This is a very basic Ruby mistake.

Here's code that works:

plant_loops = model.getPlantLoops
plant_loops_tokeep =[]

#Initial loop to store air loops
plant_loops.each do |plant_loop|
  #Criteria...
  if ....
    # Correct way to assign to an array
    plant_loops_tokeep << plant_loop
  end #end if
end #end do

# Loop to retrieve air loop objects
plant_loops_tokeep.each do |plant_loop|
   #Do stuff with the plant_loop, such as returning its name
   runner.registerInfo("Plant loop name: #{plant_loop.name}")
end #end do

I'm still interested in knowing how one can return the object from its handle (especially without knowing the type of object it is).

This is my bad. I had tried with an array doing plant_loops_tokeep = [] and then 'plant_loops_tokeep += plant_loop` but it didn't work. This is a very basic Ruby mistake.

Here's code that works:

plant_loops = model.getPlantLoops
plant_loops_tokeep =[]

#Initial loop to store air loops
plant_loops.each do |plant_loop|
  #Criteria...
  if ....
    # Correct way to assign to an array
    plant_loops_tokeep << plant_loop
  end #end if
end #end do

# Loop to retrieve air loop objects
plant_loops_tokeep.each do |plant_loop|
   #Do stuff with the plant_loop, such as returning its name
   runner.registerInfo("Plant loop name: #{plant_loop.name}")
end #end do

I'm still interested in knowing how one can return the object from its handle handle (especially without knowing the type of object it is).

This is my bad. I had tried with an array doing plant_loops_tokeep = [] and then 'plant_loops_tokeep plant_loops_tokeep += plant_loop` plant_loop but it didn't work. This is a very basic Ruby mistake.

I'm still interested in knowing how one can return the object from its handle (especially without knowing the type of object it is).

Here's code that works:

plant_loops = model.getPlantLoops
plant_loops_tokeep =[]

#Initial loop to store air loops
plant_loops.each do |plant_loop|
  #Criteria...
  if ....
    # Correct way to assign to an array
    plant_loops_tokeep << plant_loop
  end #end if
end #end do

# Loop to retrieve air loop objects
plant_loops_tokeep.each do |plant_loop|
   #Do stuff with the plant_loop, such as returning its name
   runner.registerInfo("Plant loop name: #{plant_loop.name}")
end #end do

I'm still interested in knowing how one can return the object from its handle (especially without knowing the type of object it is).