Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from waapi import WaapiClient, CannotConnectToWaapiException
- import sys, re, os, argparse
- import statistics
- #TODO: fix up the argument parser
- # Define arguments for the script
- parser = argparse.ArgumentParser(description='Creates a random container.')
- parser.add_argument('id', metavar='GUID', nargs='?', help='One guid of the form {01234567-89ab-cdef-0123-4567890abcde}. The script retrieves the current selected if no GUID specified.')
- args = parser.parse_args()
- try:
- # Connecting to Waapi using default URL
- with WaapiClient() as client:
- #starts undo group
- client.call("ak.wwise.core.undo.beginGroup")
- #getting info on selected objects
- if args.id is None:
- #TODO: Clean this up, I don't think I need to get this much information
- options = {
- 'return': ['id', 'name', 'childrenCount', 'path']
- }
- selected = client.call("ak.wwise.ui.getSelectedObjects", args, options=options)['objects']
- if len(selected) != 1:
- raise Exception('Only works with one Selection')
- if selected[0]['childrenCount'] <1:
- raise Exception('Select object does not have child objects')
- # # #getting ID's for inputing into WAQL queries
- selectedPath = selected[0]['path']
- #setting query arguments to get selected paths children
- query = {
- "waql": '$'+ ' "'+ selectedPath + '"' + " select children"
- }
- #setting return arguments
- options = {
- "return": [
- "id",
- "name",
- "path"
- ]
- }
- #getting childrens property including make up gain
- parentSelected = client.call("ak.wwise.core.object.get", query, options=options)
- listChildID = []
- for x in parentSelected['return']:
- listChildID.append(x['id'])
- args_selectChildObjects = {
- "command": "FindInProjectExplorerSyncGroup1",
- "objects": listChildID
- }
- client.call("ak.wwise.ui.commands.execute", args_selectChildObjects)
- #stops the undo group
- new_undoGroup = {
- "displayName": "Undo Select all child objects"
- }
- client.call("ak.wwise.core.undo.endGroup", new_undoGroup)
- # print(new_undoGroup)
- except CannotConnectToWaapiException:
- print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")
- except Exception as e:
- print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement