mel script to create runtime expression with variables

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2008   #1
mel script to create runtime expression with variables

Hi,

I have a general question about a problem I am having with a script I am writing.

I am storing user selections etc. inside a variable which I then want to use in a runtime expression to link two attributes and keep them in a specific relationship.

I am having problems accessing the script-variables inside my expression, I get all sorts of error messages.

This is a rough example of the expression I am intending to create (if that is in case the best way to do it), with the variables having been created in the MEL script before the expression creation.

obj01.translateX = $obj_matrix[0];
obj01.translateY = $obj_matrix[1];
obj01.translateZ = $obj_matrix[2];

Any advice is appreciated
 
Old 02 February 2008   #2
Sadly you might need to use Global variables. Sometimes you can just make a Global Array and store stuff in that array so that you can have persistent data with just one or two Global Objects. Other then that you can make EnvVariable, or put data in Attr on some element in your scene, which can be dangerous if someone deletes it.

Last of all, if you need complex data structures you have C++ and the API.

I'm not sure about Perl though...

-h
__________________
Software Engineer
 
Old 02 February 2008   #3
Okay, but using a global variable would not warrant for the expression to work once the scene has been saved and reloaded, as the user would not execute the creation MEL script unless he wanted to change the variable.

I am sure I am missing something here, this cant be that hard, I just want to link to attributes permanently, say you select one objects vtx and want another object to follow that vtx points world space position constantly?
 
Old 02 February 2008   #4
wellllll, to withstand a closing and reopening of the file, you'd need to write the selection to the file. I was thinking originally that the selection wouldn't be big, so you could use enum attributes on objects and pull selections from there, but that wouldn't work too well. You have a bunch of verts selected and you want to remember that between sessions, you're going to need to write a node to the file itself to hold all of the selections.

How ever you could look into the command "sets". It makes a node of just what was selected in the outliner, and I'm like 90% sure it stays between runs of maya. I don't use sets, I don't like having all of that information written to my files, but it would do what you want I believe.



You could also have the script write an expression to add all of the selection to a global when the first frame is came to. That way the expression will run every time you go to the first time, making sure the stuff selected is remembered, but that is such a messed up way of doing it.


I'd say look into sets. (I'm just now starting to learn how to write nodes to have my own history for things, but I haven't exactly looked into it much yet. If I find anything that will help I'll post it up.) Good luck

Last edited by trancor : 02 February 2008 at 08:08 PM.
 
Old 02 February 2008   #5
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:03 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.