Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from waapi import WaapiClient, CannotConnectToWaapiException
- import sys, re, os, argparse
- #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:
- new_undoGroup = {
- "displayName": "Undo Create Multiple Random Containers"
- }
- client.call("ak.wwise.core.undo.beginGroup")
- if args.id is None:
- options = {
- 'return': ['id', 'name', 'parent']
- }
- selected = client.call("ak.wwise.ui.getSelectedObjects", args, options=options)['objects']
- if len(selected) <= 1:
- raise Exception('Only works with multiple selections')
- parentID = selected[0]['parent']['id']
- RandomContainerName = ''
- currentName = ''
- lastName = ''
- #for loop takes "selected" and moves the selected into the newly created random container
- for x in selected:
- currentName = x['name']
- currentName = currentName[:-3]
- #print(currentName)
- if currentName != lastName:
- RandomContainerName = currentName
- args_new_randomContainer = {
- "parent": parentID,
- "type":"RandomSequenceContainer",
- "name": RandomContainerName,
- "onNameConflict": "merge"
- }
- #creating a random container and getting id
- newRandomContainer = client.call("ak.wwise.core.object.create", args_new_randomContainer)
- newRandomContainerID = newRandomContainer['id']
- lastName = currentName
- args_objectToMove = {
- "object": x['id'],
- "parent": newRandomContainerID
- }
- client.call("ak.wwise.core.object.move", args_objectToMove)
- client.call("ak.wwise.core.undo.endGroup", 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