Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import openstudio
print openstudio.toString(openstudio.runmanager.RunManager().dbPath())
# workspace test
workspace = openstudio.Workspace()
zone = workspace.addObject(openstudio.IdfObject(openstudio.IddObjectType("Zone")))
zone = zone.get()
zone.setName("New Zone")
for obj in workspace.objects():
print obj
# model test
model = openstudio.model.Model()
space = openstudio.model.Space(model)
space.setName("New Space")
for s in openstudio.model.getSpaces(model):
print s
runner.registerError('Empty space name was entered.')
return False
print("Hello x3")
# report initial condition of model
spaces = model.getSpaces()
n_ori = len(spaces)
#n_ori = 0
print("Hello x4")
print(f"The building started with {n_ori} spaces.")
runner.registerInitialCondition(
f"The building started with {n_ori} spaces."
)
print("Hello x5")
# add a new space to the model
new_space = openstudio.model.Space(model)
print("Hello x6")
new_space.setName(space_name)
print("Hello x7")
# echo the new space's name back to the user
runner.registerInfo(f"Space {new_space.nameString()} was added.")
print("Hello x8")
# report final condition of model
#runner.registerFinalCondition(f"The building finished with {len(model.getSpaces())} spaces.")
runner.registerFinalCondition("the measure ended")
print("end of measure")
#print(f"runner.workflow(): {runner.workflow()}")
print(openstudio.openStudioLongVersion())
return True