[MAYA MEL PYTHON] simple variable question

119 views
Skip to first unread message

gnn

unread,
Apr 23, 2017, 8:42:17 AM4/23/17
to Python Programming for Autodesk Maya

Hello,

I'm trying to replace by a string variable a part of a mel command...and use this inside of a python script...

thank a lot for helping me

 

string $SceneName = "100";
lookThroughModelPanel PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model modelPanel4;

Andres Weber

unread,
Apr 23, 2017, 3:27:19 PM4/23/17
to Python Programming for Autodesk Maya
Is PL_ also supposed to be a string?  Seems like you just missed your quotation marks at the beginning and post string that surround the arguments.  Also...I'd recommend not hard baking these sorts of things in, but passing as an argument...

Aka:
lookThroughModelPanel ("PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model") "modelPanel4";

Have a look at this guy's post about this and a good tip in the future is to google the function name since there's tons of posts online about these these days:

You should also look at a refresher of variables/string concatenation just so you can learn a little bit more about how to use them in MEL:

Justin Israel

unread,
Apr 23, 2017, 4:10:27 PM4/23/17
to Python Programming for Autodesk Maya


On Mon, Apr 24, 2017, 7:27 AM Andres Weber <andres...@gmail.com> wrote:
Is PL_ also supposed to be a string?  Seems like you just missed your quotation marks at the beginning and post string that surround the arguments.  Also...I'd recommend not hard baking these sorts of things in, but passing as an argument...

Aka:
lookThroughModelPanel ("PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model") "modelPanel4";

Have a look at this guy's post about this and a good tip in the future is to google the function name since there's tons of posts online about these these days:

You should also look at a refresher of variables/string concatenation just so you can learn a little bit more about how to use them in MEL:

On Sunday, April 23, 2017 at 8:42:17 AM UTC-4, gnn wrote:

Hello,

I'm trying to replace by a string variable a part of a mel command...and use this inside of a python script...

If this is being called from a Python script, you could also just make use of Python string formatting:

import maya.mel as mm

sceneName = '100'
panelName = 'PL_%s_CAM:Cam_Rig:camera_Model' % sceneName
cmd =  'lookThroughModelPanel %s' % panelName
mm.eval(cmd)


thank a lot for helping me

 

string $SceneName = "100";
lookThroughModelPanel PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model modelPanel4;

--
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/82b6c3ae-a0b8-439d-a5d1-06018e7a9362%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gnn

unread,
Apr 27, 2017, 2:11:25 PM4/27/17
to Python Programming for Autodesk Maya
thanks a lot for the advice !

gnn

unread,
Apr 27, 2017, 2:12:37 PM4/27/17
to Python Programming for Autodesk Maya
yes, this is for a python script, so thanks for your precious advive too


Le dimanche 23 avril 2017 22:10:27 UTC+2, Justin Israel a écrit :


On Mon, Apr 24, 2017, 7:27 AM Andres Weber <andres...@gmail.com> wrote:
Is PL_ also supposed to be a string?  Seems like you just missed your quotation marks at the beginning and post string that surround the arguments.  Also...I'd recommend not hard baking these sorts of things in, but passing as an argument...

Aka:
lookThroughModelPanel ("PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model") "modelPanel4";

Have a look at this guy's post about this and a good tip in the future is to google the function name since there's tons of posts online about these these days:

You should also look at a refresher of variables/string concatenation just so you can learn a little bit more about how to use them in MEL:

On Sunday, April 23, 2017 at 8:42:17 AM UTC-4, gnn wrote:

Hello,

I'm trying to replace by a string variable a part of a mel command...and use this inside of a python script...

If this is being called from a Python script, you could also just make use of Python string formatting:

import maya.mel as mm

sceneName = '100'
panelName = 'PL_%s_CAM:Cam_Rig:camera_Model' % sceneName
cmd =  'lookThroughModelPanel %s' % panelName
mm.eval(cmd)


thank a lot for helping me

 

string $SceneName = "100";
lookThroughModelPanel PL_" + $SceneName + "_CAM:Cam_Rig:camera_Model modelPanel4;

--
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_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages