Advertisement
Guest User

Untitled

a guest
Jan 28th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. from waapi import WaapiClient, CannotConnectToWaapiException
  2. import sys, re, os, argparse
  3.  
  4. #TODO: fix up the argument parser
  5.  
  6. # Define arguments for the script
  7. parser = argparse.ArgumentParser(description='Creates a random container.')
  8. 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.')
  9.  
  10. args = parser.parse_args()
  11. try:
  12. # Connecting to Waapi using default URL
  13. with WaapiClient() as client:
  14.  
  15. new_undoGroup = {
  16. "displayName": "Undo Create Multiple Random Containers"
  17. }
  18.  
  19. client.call("ak.wwise.core.undo.beginGroup")
  20.  
  21. if args.id is None:
  22. options = {
  23. 'return': ['id', 'name', 'parent']
  24. }
  25.  
  26. selected = client.call("ak.wwise.ui.getSelectedObjects", args, options=options)['objects']
  27.  
  28. if len(selected) <= 1:
  29. raise Exception('Only works with multiple selections')
  30.  
  31. parentID = selected[0]['parent']['id']
  32.  
  33. RandomContainerName = ''
  34. currentName = ''
  35. lastName = ''
  36.  
  37. #for loop takes "selected" and moves the selected into the newly created random container
  38. for x in selected:
  39.  
  40. currentName = x['name']
  41. currentName = currentName[:-3]
  42. #print(currentName)
  43.  
  44.  
  45. if currentName != lastName:
  46. RandomContainerName = currentName
  47.  
  48. args_new_randomContainer = {
  49. "parent": parentID,
  50. "type":"RandomSequenceContainer",
  51. "name": RandomContainerName,
  52. "onNameConflict": "merge"
  53. }
  54.  
  55. #creating a random container and getting id
  56. newRandomContainer = client.call("ak.wwise.core.object.create", args_new_randomContainer)
  57. newRandomContainerID = newRandomContainer['id']
  58.  
  59.  
  60. lastName = currentName
  61.  
  62. args_objectToMove = {
  63. "object": x['id'],
  64. "parent": newRandomContainerID
  65. }
  66. client.call("ak.wwise.core.object.move", args_objectToMove)
  67.  
  68. client.call("ak.wwise.core.undo.endGroup", new_undoGroup)
  69.  
  70. except CannotConnectToWaapiException:
  71. print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")
  72.  
  73. except Exception as e:
  74. print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement