CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-04-2012, 01:16 PM   #1
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 898
group -command not working

If I remove the combine, and the node cleaning for-loop and just use the first strings and the last group -name $root; -command then everything works.

Code:
// Get last and first selected string $lastName[] = `ls -sl -tail 1`; string $firstName[] = `ls -sl -head 1`; string $allMeshes[] = `ls -sl`; int $meshCount = `size($allMeshes)`; // Get group name string $root = rootOf($firstName[0]); // Combine polyUnite -ch 0 -mergeUVSets 1 -name $lastName; // Delete old crap nodes for ($obj in $allMeshes) { string $selected = $obj; if ($selected != $lastName[0]) { select $selected; doDelete; } } // Move back to group group -name $root;
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 10-04-2012, 01:27 PM   #2
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
Thumbs down

not sure what this script is supposed to do... why are you calling polyUnite on only 1 object?

as a side note, i would encourage using the raw MEL commands instead of relying on higher level MEL functions. for example:

Code:
for ($obj in $allMeshes) { if ($obj != $lastName[0]) { delete $obj; } }


Also, always pass to commands what you want to operate on - don't rely on the active selection list!

Code:
group -name $root $objectsToGroup;

Last edited by rgkovach123 : 10-04-2012 at 01:31 PM.
 
Old 10-04-2012, 02:00 PM   #3
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 898
Oh yea, sorry for not explaining the script before I rushed to explaining the problem

The script is supposed to be a "smart" combine.
It combines the meshes the user has selected, deletes the old "trash nodes" that always gets left behind. It also renames the combined mesh into the name of the last selected item - and it's also supposed to move the mesh back to the group it originally were in (there will be an if-else statement to check if there is a group or not).

The result should be a combine that does not leave trash nodes, does not move the mesh to world, does not "ungroup" anything, etc.

So at the start it just stores the names of the group and the last selected object, combines them with polyUnite and renames it to the last selected item. The for-loop then takes care of all the trash nodes.

Everything works with it except that last part: It does NOT re-create the original group.

Current code:
Code:
// Get last and first selected string $lastName[] = `ls -sl -tail 1`; string $allMeshes[] = `ls -sl`; int $meshCount = `size($allMeshes)`; // Get group name string $root = rootOf($firstName[0]); // Combine polyUnite -ch 0 -mergeUVSets 1 -name $lastName; // Delete old crap nodes for ($obj in $allMeshes) { string $selected = $obj; if ($selected != $lastName[0]) { delete $selected; } } // save combined mesh into a var string $selected = `ls -sl`; // Recreate the group group -name $root $selected;

...same problem though. Group is not created.
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.

Last edited by DeadlyNightshade : 10-04-2012 at 02:04 PM.
 
Old 10-04-2012, 02:19 PM   #4
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
what if the objects you are combining are not grouped, but parented to the world?
what if the objects are scattered through the scene, each under a different parent?

if a group already exists with the name $root, then you need to use the "parent" command - the "group" command is only for creating new groups.

if the objects are parented to the world, then $root will be "". you can't create a group node with no name.

if objects are parented to something, then $root will already exist and should use "parent".

for example:

Code:
sphere; group -name "group1"; string $root = rootOf "pSphere1"; group -name $root; // result: "group2"

Last edited by rgkovach123 : 10-04-2012 at 02:39 PM.
 
Old 10-04-2012, 02:19 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:40 AM.


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