Command Reference

Here is the commands that you can use to use the things Cosmos have under the hood.

Preferences

tempate_item

Update a existing list item with a new name

Parameters Description
list_name Name of the list to update
old_name Existing name
name New Name
info New info text
command New command
tags New tags
iconPath New iconPath
category New category
RETURN NONE
cosmos.prefs.update_list(list_name="Favorites", old_name=**None**, name=None, info=None, command=None, tags=None, iconPath=None,category=None)

write_category

Takes a input path and create a '.category' file in it to be recognized as a category

Parameters Description
folder Full folder path to add the category label too
RETURN Path to category file
cosmos.prefs.write_category(folder)

get_prefs_folder

Return the path of the cosmos preference folder.If none is specified in variables.py, use System home folder

Parameters Description
RETURN Preference path
cosmos.prefs.get_prefs_folder()

zipContent

Take the Cosmos preferences folder and zip it into a archive and save it next to it. Good for backup or sending information.

Parameters Description
RETURN Path to zip archive
cosmos.prefs.zipContent(folder)

file_exist_in_preferences

Check if the input preference file exists in the prefs folder

Parameters Description
file Name of the file (Ex`
RETURN Valid State [Bool]
cosmos.prefs.file_exist_in_preferences(file)

copy_icon_to_path

Take a icon from a given directory and copy it to a new one. If it exist before skip it.

Parameters Description
iconPath Full path to the old icon
newPath Full path to the new directory
RETURN New icon name [Str]
cosmos.prefs.copy_icon_to_path(iconPath,newPath)

convert_xml_to_json

Takes the existing XML file and convert it into the updated json format

Parameters Description
keepBackup Keep the old files in a /backup folder in the same directory
RETURN NONE
cosmos.prefs.convert_xml_to_json(keepBackup=True)

get_default_script_paths

Generate a list of the default script paths

Parameters Description
RETURN List of all the paths [List of dicts]
cosmos.prefs.get_default_script_paths()

get_settings_path

Return the full path to the main cosmos settings file

Parameters Description
RETURN Full path [Str]
cosmos.prefs.get_settings_path()

create_settings_file

Create a fresh preference file in the cosmos home directory, if a input is already defined, use it

Parameters Description
settings_dict Input settings dictionary, leave blank if unsure
RETURN True or false if the file was created [Bool]
cosmos.prefs.create_settings_file(settings_dict=None)

create_searches_file

Create a default file of the search history

Parameters Description
searches_dict Input search dict, leave blank if unsure
RETURN True or false if the file was created [Bool]
cosmos.prefs.create_searches_file(searches_dict=None)

save_generic_settings

'Takes a settings name and assign a value in the generic settings dict

Parameters Description
settings_name Name of the generic setting to save. If not found it will create a new one
new_value Value of the setting to save
RETURN NONE
cosmos.prefs.save_generic_settings(settings_name, new_value)

load_settings

Load the settings file, if no file is found, create default

Parameters Description
RETURN Settings file if valid, otherwise False
cosmos.prefs.load_settings()

get_script_path_names

Return only the name/prefix of the paths found in prefs

Parameters Description
RETURN Name/prefixes of all the paths
cosmos.prefs.get_script_path_names()

get_script_path_list

Return a list of all script-paths in settings. By default only returning the ones that are enabled

Parameters Description
onlyEnabled If True, return one the ones that are enabled
RETURN List of script paths
cosmos.prefs.get_script_path_list(onlyEnabled=True)

get_generic_settings

Get a specific settings from the settings file

Parameters Description
input Input setting name to look for
RETURN Setting value if found, otherwise None

save_generic_settings

Takes a settings name and assign a value in the generic settings dict

Parameters Description
settings_name Name of the generic setting to save. If not found it will create a new one
new_value Value of the setting to save
RETURN NONE
cosmos.prefs.save_generic_settings(settings_name, new_value)

Remove the recommended search file on disk to reset its history. "cosmos_searches.json"

Parameters Description
RETURN NONE
cosmos.prefs.reset_recommended_search()

Save a recommender search item based on its query and time

Parameters Description
search_query What was the search query used when searched
name_query Whats the name of the action executed
RETURN True or false if the file was created [Bool]
cosmos.prefs.save_recommended_search(search_query, name_query)

Get the recommended searches results as a ordered list by its query

Parameters Description
search_query Search query to look for [Str]
result_all When True, give all result and ignore search-query [Bool]
RETURN List of dicts sorted after relevance
cosmos.prefs.get_recommended_search(search_query)

get_list

Return a list of the blacklist, favorites and other lists by its name

Parameters Description
list_name Name of the list to look for [Str]
RETURN List of dictionaries including action data [Tuple]
cosmos.prefs.get_list(list_name="list_name")

update_list

Update a existing list item with a new name

Parameters Description
list_name Name of the list to update
old_name Existing name
name New Name
info New info text
command New command
tags New tags
iconPath New iconPath
category New category
RETURN Status is successful [Bool]
cosmos.prefs.update_list(list_name="Favorites", old_name=None, name=None, info=None, command=None, tags=None, iconPath=None,category=None)

get_list_names

Get the names of all the lists available

Parameters Description
filterDefault If enabled, only return the names of the custom user-facing lists
RETURN List of Strings [Tuple]
cosmos.prefs.get_list_names(filterDefault=True)

remove_list_item

Add a new item based on a dictionary item

Parameters Description
list_name Name of the list to remove from
name Name of the Action
category Category of the Action
info Info for the action
RETURN Status is successful [Bool]
cosmos.prefs.remove_list_item(list_name, name, category, info)

add_list_item

Add a new item based on a dictionary item

Parameters Description
card Action card from the cosmos UI
list_name Name of the list to add to
RETURN Status is successful [Bool]
cosmos.prefs.add_list_item(card, list_name)

Library

get_favorite_actions

Return the favorites actions as a list

Parameters Description
RETURN List of actions [Tuple]
cosmos.library.get_favorite_actions()

get_blacklisted_actions

Return the blacklisted actions as a list

Parameters Description
RETURN List of actions [Tuple]
cosmos.library.get_blacklisted_actions()

get_tags

Get all the tags from loaded cosmos actions

Parameters Description
RETURN List of tags [Tuple]
cosmos.library.get_tags()

get_categories_from_path

Get a list of categories from the current path

Parameters Description
path Path to check categories in
RETURN List of categories names
cosmos.library.get_categories_from_path(path)

clean_category_name

Takes a input category name and clean out its full folder name just to give the end category

Parameters Description
category Full category path
RETURN Matched path against existing paths cleaned [Str]
cosmos.library.clean_category_name(category)

write_action_to_file

Takes a list of variables and save it out as a action file in the desired location/path

Parameters Description
name Action Name
info Action Description [Str, Short description of the action]
tags Actin Tags [Str, Example`
icon Icon-name [Str, Example`
`command:
syntax Action Script syntax, 'Mel' or 'Python' [Str]
location Folder path where to save the action [Str]
RETURN Pickled content
cosmos.library.write_action_to_file(name=None,info="",tags="",icon="",command="",syntax=None,location=None)

edit_action_on_file

Edit an existing action-file and save it with new attributes

Parameters Description
file Path to the action-file
name Action Name
info Action Description [Str, Short description of the action]
tags Actin Tags [Str, Example`
icon Icon-name [Str, Example`
command The command to execute [Str]
syntax Action Script syntax, 'Mel' or 'Python' [Str]
RETURN NONE
cosmos.library.edit_action_on_file(file=None,name=None,info=None,tags=None,icon=None,command=None,syntax=None)

read_action_file

Read a action file from a full path and return a dictionary of its content

Parameters Description
file Full file path [Str]
RETURN Action content [Dict]
cosmos.library.read_action_file(file)

get_action_path_by_id

Takes a ID and find the action-path from the current loaded actions

Parameters Description
id ID to look for [Str]
RETURN Action (if found, if not return None)
cosmos.library.get_action_path_by_id(id)

get_action_by_id

Takes a ID and return a loaded action-file dictionary

Parameters Description
id ID to look for [Str]
RETURN Action [Dict] if found, if not return None)
cosmos.library.get_action_by_id(id)

ask_delete_action

Takes a action and throw up a dialog for if it should be deleted or not

Parameters Description
action Action dict
RETURN Reply of dialog
cosmos.library.ask_delete_action(action)

remove_action_file

Takes a path to a action file and delete it after user confirmation

Parameters Description
actionFile Path to the file
RETURN True or false if the file was deleted or not
cosmos.library.remove_action_file(actionFile)

remove_action

Takes a action file and remove it from the filesystem

Parameters Description
action Action-dict
RETURN Succes stage [Bool]
cosmos.library.remove_action(action)

duplicate_action

Duplicate a action and assigns a new name from its input

Parameters Description
action Action [Dict]
new_name New name of the action [Str] This will be used when creating the name of the action
RETURN New Action [Dict]
cosmos.library.duplicate_action(action, new_name)

Startup

rescan

Scan the cosmos library and show the search dialog.

Parameters Description
RETURN NONE
cosmos.startup.rescan()

start

Show the cosmos window, if no preferences found, create some and show the tutorial.

Parameters Description
RETURN NONE
cosmos.startup.start()

close

Close the cosmos search window

Parameters Description
RETURN NONE
cosmos.startup.close()

load_maya_commands

Traverse Maya menues and load all actions

Parameters Description
RETURN List of Maya commands
cosmos.startup.

filter_blacklisted

Remove blacklisted item from list

Parameters Description
command_list List of action dicts
RETURN Filtered list
cosmos.startup.

sortActions

Takes a list of actions and sort them based on different methods

Parameters Description
actions List of actions [List of dicts]
sortingMethod Method of sorting [Options: 'score', 'alphabetical', 'category', 'path', 'tags'] [Str]
:return`
cosmos.startup.sortActions(actions=[], sortingMethod="score")

display_window

Display a Cosmos window. Check below for options what to show

Parameters Description
window Window name to show: "setup" = Settings window, "tutorial" = Tutorial window, "actions" = Action list, "actionInfo" = Add new action window [Or edit if a action is attached], "search" = Search window
RETURN NONE
cosmos.startup.display_window(window)

execute_python

Execute a python command. A undo chunk is created before the command is executed.

Parameters Description
command Command to execute
RETURN Status [Str]
cosmos.startup.execute_python(command)

execute_mel

Execute a mel command. A undo chunk is created before the command is executed.

Parameters Description
command Command to execute [Str]
RETURN Status [Str]
cosmos.startup.execute_mel(command)

execute_action

Take a action-id, find the relevant command to execute and trigger it.

Parameters Description
actionID Action-id [Str]
RETURN Status [Str]
cosmos.startup.execute_action(actionID)

execute_maya_action

Takes a name, category and info and find the corresponding menu-action relevant to it and trigger the pointer.

Parameters Description
name Name of the action [Str]
category Category of the action [Str]
info Info for the acion [Str]
RETURN Status [Str]
cosmos.startup.execute_maya_action(name, category, info)

execute_card

Take a input action-card from the UI and trigger its command

Parameters Description
card Action card to trigger [cardUI]
forceAlt Force to trigger the alt command if it exist for the action
RETURN Status [Str]
cosmos.startup.execute_card(card, forceAlt=False)

update_score

Update the score from the scoring engine based on search results, favorites etc

Parameters Description
RETURN NONE
cosmos.startup.update_score()

run_shotcut_install

Installs the shortcut by default when Maya is loaded. This is run if loadOnMayaLaunch is Enabled

Parameters Description
RETURN NONE
cosmos.startup.run_shotcut_install()

Maya Portal

search_menu_items

Search a specific menu of the interface and return its items

Parameters Description
menu Input menu [Qt.QMenu]
RETURN List of dicts
cosmos.mayaPortal.search_menu_items(menu)

mayaWindow

Get the main Maya Window Instance

Parameters Description
RETURN Maya window instance
cosmos.mayaPortal.mayaWindow()

gather_maya_commands

Takes the current Maya instance and scan its menues for Maya Actions

Parameters Description
RETURN List of commands, if no window instance found, return None
cosmos.mayaPortal.gather_maya_commands()

install_hotkey

Install the main Maya hotkey for launching Cosmos. If existing hotkeys exist, remove them

Parameters Description
RETURN Hotkey
cosmos.mayaPortal.install_hotkey()

displayViewMessage

Display a popup window with relevant info

Parameters Description
text The text to display
mode Mode to define color ["good" = Green, "error" = Red]
header Prefix before the message to build context [Str]
RETURN NONE
cosmos.mayaPortal.displayViewMessage(text, mode, header)