Description
Import all aliases from a .txt file.
Warning
A known bug produces on the last alias, it must be corrected after running the script.
See also
PurgeAllAliases script.
Author and license
Script by MLAV.LAND, licensed under the GNU GPL 3 License.
Code
import rhinoscriptsyntax as rs
def create_aliases_from_file(file_path):
try:
with open(file_path, 'r') as file:
alias_lines = file.readlines()
for line in alias_lines:
parts = line.strip().split(' ', 1)
if len(parts) != 2:
print("Invalid line in the file: " + line)
continue
alias_name, alias_command = parts
rs.AddAlias(alias_name, alias_command)
print("Created alias: " + alias_name)
except FileNotFoundError:
print("File not found: " + file_path)
def main():
file_path = "R-Aliases.txt"
create_aliases_from_file(file_path)
if __name__ == "__main__":
main()