Advertisement
Guest User

Untitled

a guest
Jan 28th, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. from waapi import WaapiClient, CannotConnectToWaapiException
  2. import sys, re, os, argparse
  3. import statistics
  4.  
  5. #TODO: fix up the argument parser
  6.  
  7. # Define arguments for the script
  8. parser = argparse.ArgumentParser(description='Creates a random container.')
  9. 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.')
  10.  
  11. args = parser.parse_args()
  12. try:
  13.  
  14. # Connecting to Waapi using default URL
  15. with WaapiClient() as client:
  16.  
  17.  
  18. #starts undo group
  19. client.call("ak.wwise.core.undo.beginGroup")
  20.  
  21. #getting info on selected objects
  22. if args.id is None:
  23.  
  24. #TODO: Clean this up, I don't think I need to get this much information
  25. options = {
  26. 'return': ['id', 'name', 'childrenCount', 'path']
  27. }
  28.  
  29. selected = client.call("ak.wwise.ui.getSelectedObjects", args, options=options)['objects']
  30. if len(selected) != 1:
  31. raise Exception('Only works with one Selection')
  32.  
  33. if selected[0]['childrenCount'] <1:
  34. raise Exception('Select object does not have child objects')
  35.  
  36. # # #getting ID's for inputing into WAQL queries
  37. selectedPath = selected[0]['path']
  38.  
  39. #setting query arguments to get selected paths children
  40. query = {
  41. "waql": '$'+ ' "'+ selectedPath + '"' + " select children"
  42. }
  43.  
  44. #setting return arguments
  45. options = {
  46. "return": [
  47. "id",
  48. "name",
  49. "path"
  50. ]
  51. }
  52.  
  53. #getting childrens property including make up gain
  54. parentSelected = client.call("ak.wwise.core.object.get", query, options=options)
  55.  
  56. listChildID = []
  57.  
  58. for x in parentSelected['return']:
  59. listChildID.append(x['id'])
  60.  
  61. args_selectChildObjects = {
  62. "command": "FindInProjectExplorerSyncGroup1",
  63. "objects": listChildID
  64. }
  65.  
  66. client.call("ak.wwise.ui.commands.execute", args_selectChildObjects)
  67.  
  68. #stops the undo group
  69. new_undoGroup = {
  70. "displayName": "Undo Select all child objects"
  71. }
  72. client.call("ak.wwise.core.undo.endGroup", new_undoGroup)
  73.  
  74. # print(new_undoGroup)
  75.  
  76.  
  77.  
  78.  
  79. except CannotConnectToWaapiException:
  80. print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")
  81.  
  82. except Exception as e:
  83. print(str(e))
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement