RoomGroups Module limitations

The VE Python API allows users create simple programs using the Python Programming Language, to interact with a VE Model and/or Vista Results File
Post Reply
amarcial
VE Newbie
VE Newbie
Posts: 1
Joined: Tue May 31, 2022 3:21 pm

RoomGroups Module limitations

Post by amarcial »

I am working on a python script to speed up the zoning and zone grouping process and noticed that the RoomGroups module does not allow for specific spaces to be assigned to zones. Instead the assign_rooms_to_zone() method assigns all rooms to one zone. Is there a work around for this or an update with IES VE 2022?
gazzat5
VE Beginner
VE Beginner
Posts: 12
Joined: Tue Jul 09, 2019 9:53 am
Location: London
Contact:

Re: RoomGroups Module limitations

Post by gazzat5 »

It is possible to add specific rooms to a group using the python interface.
I wrote a script to group rooms based on the existing room names.

Have a look through this very hacky script (note that i never could get it to step through the array of room names/group names automatically, so i just hardcoded the current room name (floor) to assign to a group.

Code: Select all

import iesve
project = iesve.VEProject.get_current_project()


# instantiate the room groups interface object
rg = iesve.RoomGroups()

# Get and print the details of all room group schemes
print ("\nRoom Group Schemes:")
schemes = rg.get_grouping_schemes()

models = project.models
realmodel = models[0]
bodies = realmodel.get_bodies(False)
rooms = [body for body in bodies]
#if body.subtype == iesve.VEBody_subtype.room:
roomcount = 0

scheme_handle_correct = 0
group_handle_correct = 0

room_name_search_text = "L10"
group_name_search_text = "Tenth Floor"

list_room_name_search_text = ["L5","L6","L7","L8","L9","L10","L11","L12","L13","L14","L15","L16","L17","L18","L19","L20","L21","L22","L23","L24","L25","L26"]
list_group_name_search_text = ["Fifth Floor","Sixth Floor","Seventh Floor","Eighth Floor","Nineth Floor","Tenth Floor","Eleventh Floor","Twelfth Floor","Thirteenth Floor","Fourteenth Floor","Fifthteenth Floor","Sixteenth Floor","Seventeenth Floor","Eighteenth Floor","Nineteenth Floor","Twentieth Floor","Twenty-First Floor","Twenty-Second Floor","Twenty-Third Floor","Twenty-Fourth Floor","Twenty-Fifth Floor","Twenty-Sixth Floor"]


#for rn in list_room_name_search_text:
#    print(rn)

#roomlist = []
grid = 20
#for grid in range(2, 5):
roomlist = []
roomcount = 0
print("grid:", grid)
#Select matching rooms
for room in rooms:
    if list_room_name_search_text[grid] in room.name:
        print(room.id,room.name)
        roomlist.append(room)
        roomcount+=1

#Pick the correct scheme and group handles
for scheme in schemes:
    scheme_handle = scheme['handle']
    if scheme['name'] == "Storeys": 
        #print("============ Storeys =============")
        #print("  ----------------------------------------------")
        #print("Scheme (name/handle): {} / {}".format(scheme['name'], scheme_handle))
        scheme_handle_correct = scheme_handle
        #print("Groups:")
        # Get and print the room groups for this scheme
        groups = rg.get_room_groups(scheme_handle)
        for group in groups:
            if group['name'] == list_group_name_search_text[grid]:
                print("============ ", list_group_name_search_text[grid], " =============")
                # First get a list of all rooms in the model
                #all_bodies = iesve.VEProject.get_current_project().models[0].get_bodies(False)
                print("Scheme handle: ", scheme_handle," Group handle", group['handle']," room name:", room.name)
                #rg.assign_rooms_to_group(scheme_index, group_index_1, all_bodies[:half_the_bodies])
                #print("List item 0:", roomlist[0].name)
                group_handle_correct = group['handle']
            #print("   Group name / handle / colour:  {} / {} / {}".format(group['name'], group['handle'], group['colour']))
            #print("   Rooms: ", group['rooms'])

#Assign rooms to group
rg.assign_rooms_to_group(scheme_handle_correct, group_handle_correct, roomlist)
print(list_room_name_search_text[grid]," Rooms: " + str(roomcount))



# List rooms to be assigned
#for i in roomlist:
#    print("Room name:", i.name)
HTH
Post Reply