SimplyMaya Forums

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


SM Forums / Lounges / Maya Basics & Newbie Lounge / MEL for delete by history of an object.

Maya Basics & Newbie Lounge Please post in this section ONLY if your question doesn't fit in anywhere else on the forum, or if you're not sure which section it's relevant to. We also have Free streaming trial available.

Join the conversation. Reply to post
 
Thread Tools
10-08-2013, 05:24 AM   #1
Aaron263
Registered User
 
Join Date: Aug 2013
Posts: 3
MEL for delete by history of an object.
hey there.
I wanted to know if it is possible to write a MEL or Python script, to delete any selected objects history(and not the script editors history), and freeze tranformation.

This will help me when i make GUI controllers and i do not have to select each object and go into the menues and do a lengthy set of procedure each and every time.

If anyone could help, please do.

Aaron
  Reply with quote
10-08-2013, 10:09 AM   #2
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,518
If you turn on History>Echo All Commands in the Script Editor you'll see the MEL commands for those actions whenever you run them.


Code:
DeleteHistory;
CenterPivot;
If you want to do this for the objects you have selected, it's easy.
Code:
//Store list of the selected objects in a string array
string $selection[] = `ls -sl`;


//For every item in that list...
for($obj in $selection){

//Delete history and center pivot
DeleteHistory;
CenterPivot;


}
__________________
- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
  Reply with quote
13-08-2013, 12:11 PM   #3
Aaron263
Registered User
 
Join Date: Aug 2013
Posts: 3
Thanks!
Thank you so much!
It worked!

Thanks,
Aaron.
  Reply with quote
15-10-2014, 10:38 PM   #4
MrYeti
Lifetime Member
 
MrYeti's Avatar
 
Join Date: Feb 2013
Location: Down Under
Posts: 245
Bumping an old thread here, I'm wondering if there's a way to delete an objects history in Python.
__________________
Cheers, the Yeti.
  Reply with quote
16-10-2014, 01:32 AM   #5
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,518
Yep! Using the "delete" command. This code deletes the construction history on all selected objects.

Code:
import maya.cmds as mc

selection = mc.ls(sl = 1)
for obj in selection:
	mc.delete(obj , ch = 1)
I just realized in the previous MEL I posted that I added center pivot instead of freeze transformations lol. I just don't know anymore, smh.
__________________
- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
  Reply with quote
16-10-2014, 02:18 AM   #6
MrYeti
Lifetime Member
 
MrYeti's Avatar
 
Join Date: Feb 2013
Location: Down Under
Posts: 245
Thanks Gen, I found a way to do it using the command (constructionHistory = False) at the creation of the object but I don't know if this is a good way to do it.
__________________
Cheers, the Yeti.
  Reply with quote
16-10-2014, 12:58 PM   #7
stwert
EduSciVis-er
 
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
You probably want to keep construction history on, as it will allow you to modify various operations after the fact. I would then delete construction history at certain points in the process once you're sure you don't want to dig into the history.
  Reply with quote
16-10-2014, 08:50 PM   #8
MrYeti
Lifetime Member
 
MrYeti's Avatar
 
Join Date: Feb 2013
Location: Down Under
Posts: 245
Thanks for that tip Stwert, it was okay for what I was doing (creating a control for a rig) but I thought it might not be best practice to do it for other things.
__________________
Cheers, the Yeti.
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Camera Translation to Object rotation? jimvfx Animation 0 28-01-2015 10:06 PM
trouble opening maya scene jooleyinboots Maya Technical Issues 2 03-02-2014 09:11 PM
Normal Map definitions djwaterman Lighting & Rendering 2 25-05-2012 12:50 PM
object history A_A_68 Maya Basics & Newbie Lounge 4 02-01-2006 11:17 AM
Construction history... what is it and how does it effect objects? junkyBob Maya Basics & Newbie Lounge 1 03-03-2005 03:38 PM