SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Maya Technical Issues / MEL line SelectToggleMode; not working

Maya Technical Issues Post all your interface and configuration related problems with Maya software here.

Join the conversation. Reply to post
 
Thread Tools
10-04-2017, 05:26 PM   #1
Skalman
Registered User
 
Skalman's Avatar
 
Join Date: Apr 2012
Posts: 293
MEL line SelectToggleMode; not working
So I made a MEL-script, and when I made the script everything worked fine. When I later on switched to another maya scene (after saving the script), and I ran the script on a model, I noticed that it was in vertex-mode (it should end in object-mode), and did some spooky things to the model that it wasnt supposed to do.. I looked at what was going on and basicly every time i had the line "SelectToggleMode;", it'd ignore it (the line works if i run it separately). No wonder it made a mess. So now I've saved out a few diffrent parts of the script, so i'll do the SelectToggleMode; manually, and continue on with the script until it encounters another SelectToggleMode;. Which is annoying. I'd like it to work, but I really have no idea why this particilar line wouldn't work for me. Its kind of annoying. Do any of you know a sulotion to this? A line that does the same function maybe? I dont really have time to investigate more on this, since im going to use this script on all my models for the project im in (the script creates 1 group with a high-poly version, a cage-version and the original model, aswell as another group with the exploded high-poly&cage&LP). Itd be easier to get the script working in 1 click instead of having to go through 6 clicks every time i want to do this operation




You can try it out yourself if you want. Just select an object and run the script

Code:
//1st in group = Low-poly
//2nd in group = High-poly
//3rd in group = Cage

Group;
PickWalkDown;
duplicate -rr;
duplicate -rr;
PolySelectConvert 3;
TransformAlongNormal;
setAttr "polyMoveVertex2.localTranslate" -type double3 0 0 60.975944 ;
SelectToggleMode;
PickWalkLeft;
polySmooth  -mth 0 -sdt 0 -ovb 2 -ofb 0 -ofc 0 -ost 1 -ocr 0 -dv 1 -bnr 0 -c 1 -kb 1 -ksb 1 -khe 1 -kt 1 -kmb 2 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1;
CompleteCurrentTool;
SelectToggleMode;
toggleSelMode;
HideManipulators;
PickWalkUp;
PickWalkDown;
rename Lowpoly;
PickWalkRight;
rename Highpoly;
PickWalkRight;
rename Cage;
PickWalkUp;
PickWalkDown;



Duplicate -rr;
Group;
PickWalkDown;
//NEW GROUP (EXPLODE-GROUP)

SeparatePolygon;

PickWalkUp;
PickWalkDown;
move -r 0 0 -10000 ;
PickWalkRight;
move -r 0 0 -20000 ;
PickWalkRight;
move -r 0 0 -30000 ;
PickWalkRight;
move -r 0 0 -40000 ;
PickWalkRight;
move -r 0 0 -50000 ;
PickWalkRight;
move -r 0 0 -60000 ;
PickWalkRight;
move -r 0 0 -70000 ;
PickWalkRight;
move -r 0 0 -80000 ;
PickWalkRight;
move -r 0 0 -90000 ;
PickWalkRight;
move -r 0 0 -100000 ;
PickWalkRight;
move -r 0 0 -110000 ;
PickWalkRight;
move -r 0 0 -120000 ;
PickWalkRight;
move -r 0 0 -130000 ;
PickWalkRight;
move -r 0 0 -140000 ;
PickWalkRight;
move -r 0 0 -150000 ;
PickWalkRight;
move -r 0 0 -160000 ;
PickWalkRight;
move -r 0 0 -170000 ;
PickWalkRight;
move -r 0 0 -180000 ;
PickWalkRight;
move -r 0 0 -190000 ;
PickWalkRight;
move -r 0 0 -20000 ;
//EXPLODING MESH     


PickWalkUp;
CombinePolygons;
DeleteHistory;
delete -ch;
CompleteCurrentTool;


//Create Exploded cage + HP (copy-pasted)
Group;
PickWalkDown;
duplicate -rr;
duplicate -rr;
PolySelectConvert 3;
TransformAlongNormal;
setAttr "polyMoveVertex2.localTranslate" -type double3 0 0 60.975944 ;
SelectToggleMode;
PickWalkLeft;
polySmooth  -mth 0 -sdt 0 -ovb 2 -ofb 0 -ofc 0 -ost 1 -ocr 0 -dv 1 -bnr 0 -c 1 -kb 1 -ksb 1 -khe 1 -kt 1 -kmb 2 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1;
CompleteCurrentTool;
SelectToggleMode;
toggleSelMode;
HideManipulators;
PickWalkUp;
PickWalkDown;
rename ExplodedLowpoly;
PickWalkRight;
rename ExplodedHighpoly;
PickWalkRight;
rename ExplodedCage;
PickWalkUp;
PickWalkDown;
//Create Exploded cage + HP (copy-pasted)

PickWalkUp;
rename EXPLODED;
PickWalkLeft;
rename NOTEXPLODED;
select -r EXPLODED ;
select -add NOTEXPLODED ;
Group;
rename ModelReadyForExport
__________________
20 year old guy from Sweden



Big Bob Marley fan
Love skateboarding
Maya, Mudbox and Photoshop user

Full name: Marcus Ralman


https://www.facebook.com/MarcusRalman3D

^ My facebook page ^

Last edited by Skalman; 10-04-2017 at 05:31 PM.
  Reply with quote
13-04-2017, 10:26 AM   #2
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,515
I ran into problems sooner than that. "TransformAlongNormal" can't be found and throws an error. Just by looking, I can see some issues. The use of variables would make this a lot easier and flexible. It would basically eliminate the need to constantly pickwalk in order to act on objects.

Then there are lines like these:

Code:
SelectToggleMode;
toggleSelMode;
Those two commands do the same thing, which could lead to your component/object mode issues. Another example of this is these two lines. This probably won't cause any problems but still redundant.
Code:
DeleteHistory;
delete -ch;
And I'm guessing the following lines is where all the verts are pulled out to make the cage.

Code:
PolySelectConvert 3;
TransformAlongNormal;
setAttr "polyMoveVertex2.localTranslate" -type double3 0 0 60.975944 ;
The problem with this is that the "polyMoveVertex2" hardcodes names of objects into your script. So if there isn't a transform component node matching that name, the script will fail. This new code would do the same thing, and isn't dependant on specific object names, it simply acts on the selected verts.

Code:
PolySelectConvert 3;
polyMoveVertex  -localTranslate 0 0 60.975944;
I'll poke around a bit more later. The script could be a lot more efficient.
__________________
- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
// Error: line 0: Error reading file. PiroEfekta Programming 13 03-08-2016 05:52 PM
Textures not linking to tutorial maya.... dan003 Maya Basics & Newbie Lounge 2 07-03-2015 11:08 PM
// Warning: line 0: swatches file depend node not found paragsharma Programming 0 14-12-2014 12:44 PM
trouble opening maya scene jooleyinboots Maya Technical Issues 2 03-02-2014 09:11 PM
Maya 5.0.1 Problem: MentalRay won't load neoarcadia Maya Technical Issues 3 30-12-2003 02:05 AM