Custom Python Menu loading from yaml

91 views
Skip to first unread message

DGFA DAG's GRAPHIC & FOTO ART

unread,
Aug 28, 2022, 4:28:35 AM8/28/22
to Python Programming for Autodesk Maya
Hi,

I got my custom menu in pyton as well in mel but I want to load the menu structure from a yaml file e.g. like this

- command: SetProject
  icon: fileOpen.png
  label: Set Project
  lang: mel
- divider: ''
- command: IncrementAndSave
  icon: saveToShelf.png
  label: Save icremental
  lang: mel
- command: SaveSceneAs
  icon: save.png
  label: Save as
  lang: mel
- divider: ''

How can I achive this?

Thanks!

Justin Israel

unread,
Aug 29, 2022, 1:24:35 AM8/29/22
to python_in...@googlegroups.com
In Python you can use PyYAML to read in your file. https://pypi.org/project/PyYAML/
Then you can iterate over the list of commands and call the appropriate Maya Python menu functions. If you already have this solved in Python then I would say just have your MEL code call this python code and reuse the same logic, since there is no point in trying to write and maintain it in 2 places. 
 

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/67fc3631-dce5-45ae-99cb-32333e7bde12n%40googlegroups.com.

DGFA DAG's GRAPHIC & FOTO ART

unread,
Sep 1, 2022, 5:26:14 AM9/1/22
to Python Programming for Autodesk Maya
Thank you!

I never used yaml or any type of parsing yet.
I hope I get it to work.
Reply all
Reply to author
Forward
0 new messages