Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya 2020 MEL global script error?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1118 Views, 5 Replies

Maya 2020 MEL global script error?

Anonymous
Not applicable

Hi all,

 

I'm in the process of learning some MEL scripting for Maya and am following a youtube tutorial series by Dhruv Govil.

 

On the video I'm watching, he created a Custom UI window with buttons, some of which are referring to a previously created function in a different script. He mentioned in the earlier video how to save, load, source and scope scripts. To call a function made in another script in the custom UI window, he made the script global in an earlier video.

 

I've followed along but am still lost as to why Maya isn't able to call that function.

 

Here's the playlist I'm following:

https://youtu.be/J35_QnrPQvI

 

 

Please let me know your thoughts on how to proceed.

 

Thanks in advance!

0 Likes

Maya 2020 MEL global script error?

Hi all,

 

I'm in the process of learning some MEL scripting for Maya and am following a youtube tutorial series by Dhruv Govil.

 

On the video I'm watching, he created a Custom UI window with buttons, some of which are referring to a previously created function in a different script. He mentioned in the earlier video how to save, load, source and scope scripts. To call a function made in another script in the custom UI window, he made the script global in an earlier video.

 

I've followed along but am still lost as to why Maya isn't able to call that function.

 

Here's the playlist I'm following:

https://youtu.be/J35_QnrPQvI

 

 

Please let me know your thoughts on how to proceed.

 

Thanks in advance!

5 REPLIES 5
Message 2 of 6
stuzzz
in reply to: Anonymous

stuzzz
Collaborator
Collaborator

Here's the answer I wish I could have you if I were you:

 

Do not create UI with the melscript!! it's old fashionned.

Go with the PyQt or PySide framework, it will save you a lot of time and it is way more powerfull.  Furthermore, if you need to get a job and have no clue of what are the frameworks I'm talking about, you will drastically reduce your change to get hired.

 

If you start learning code in Maya, learn python instead. A good reason for that, it's object oriented. I can quote some other good reasons, but this one is just enough.

0 Likes

Here's the answer I wish I could have you if I were you:

 

Do not create UI with the melscript!! it's old fashionned.

Go with the PyQt or PySide framework, it will save you a lot of time and it is way more powerfull.  Furthermore, if you need to get a job and have no clue of what are the frameworks I'm talking about, you will drastically reduce your change to get hired.

 

If you start learning code in Maya, learn python instead. A good reason for that, it's object oriented. I can quote some other good reasons, but this one is just enough.

Message 3 of 6
stuzzz
in reply to: Anonymous

stuzzz
Collaborator
Collaborator
Accepted solution

But to answer your question.

I don't know what video exactly your talk about but generally speaking, If you don't have access to your mel's function:

make sure that it's a global function "global proc ...". 

make sure that you have sourced it "source mymelfile.mel"

 

then you should be able to use it everywhere since it's global (in the main scope)

0 Likes

But to answer your question.

I don't know what video exactly your talk about but generally speaking, If you don't have access to your mel's function:

make sure that it's a global function "global proc ...". 

make sure that you have sourced it "source mymelfile.mel"

 

then you should be able to use it everywhere since it's global (in the main scope)

Message 4 of 6
Anonymous
in reply to: stuzzz

Anonymous
Not applicable

Thanks for the reply! I'm quite new to Maya scripting so I'm not familiar with those terms. I will look into those though!

 

Sourcing the script did the trick, thanks!

 

0 Likes

Thanks for the reply! I'm quite new to Maya scripting so I'm not familiar with those terms. I will look into those though!

 

Sourcing the script did the trick, thanks!

 

Message 5 of 6
stuzzz
in reply to: Anonymous

stuzzz
Collaborator
Collaborator

awesome!

0 Likes

awesome!

Message 6 of 6
Anonymous
in reply to: stuzzz

Anonymous
Not applicable

Hi, please do let us know more reason why learn Python instead of Mel.  I was trying to learn a script to connect attributes from a 2015 video, and no matter what I do the code does not work. Is there anything in the code below that would not work in Maya 2020 Mel?

 

string $sel[] = 'ls -sl -tr';

string $dis = 'shadingNode -asUtility distanceBetween -n "distance2"';

connectAttr ($sel[0] + ".worldMatrix") ($dis + ".inMatrix1");
connectAttr ($sel[1] + ".worldMatrix") ($dis + ".inMatrix2");
connectAttr ($sel[0] + ".rotatePivotTranslate") ($dis + ".point1");
connectAttr ($sel[1] + ".rotatePivotTranslate") ($dis + ".point2");

Hi, please do let us know more reason why learn Python instead of Mel.  I was trying to learn a script to connect attributes from a 2015 video, and no matter what I do the code does not work. Is there anything in the code below that would not work in Maya 2020 Mel?

 

string $sel[] = 'ls -sl -tr';

string $dis = 'shadingNode -asUtility distanceBetween -n "distance2"';

connectAttr ($sel[0] + ".worldMatrix") ($dis + ".inMatrix1");
connectAttr ($sel[1] + ".worldMatrix") ($dis + ".inMatrix2");
connectAttr ($sel[0] + ".rotatePivotTranslate") ($dis + ".point1");
connectAttr ($sel[1] + ".rotatePivotTranslate") ($dis + ".point2");

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report