Delete Scale Tracks Only? (Python)

Become a member of the CGSociety

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

Thread Tools Display Modes
  06 June 2013
Delete Scale Tracks Only? (Python)

I'm trying to write a script to help with clean up on some files, I can delete ALL tracks on selected objects, but I'm trying to make it conditional so that say it will delete only Scale tracks. I can get the name of the track but when I use that in a condition to delete the scale tracks it's not working.
Might be a simple error as my Python is a little rusty. Any ideas appreciated.

 import c4d
 def main():
 	cycleObjects(doc.GetActiveObjects(c4d.GETACTIVEOBJ  ECTFLAGS_0))
 def cycleObjects(objects):
 	for obj in objects:
 		if (obj.GetChildren()!= None):
 def cleanTracks(object):
 	for track in object.GetCTracks():
 		print trackName # this seems to work...
 		if (trackName=="Scale.Y"):## this part not working yet!
 if __name__=='__main__':

As usual the forum here is eating the code but the part I'm having trouble is the last bit, which is commented..

  06 June 2013
Hi Brian!

A CTrack instance (which represents animation tracks in Cinema 4D) has a method called GetDescriptionID(). You can identify a track using the return value of this method.

descid = track.GetDescriptionID()
if descid[0].id == c4d.ID_BASEOBJECT_REL_SCALE:

The description ID of a Scale-Track has two components: The base ID (which is ID_BASEOBJECT_REL_SCALE) and the vector component (VECTOR_X, VECTOR_Y, VECTOR_Z). You can be more precise by checking these components as well, or, if you're aiming for a very specific track, compare description IDs directly.

scale_y = c4d.DescID(

descid = track.GetDescriptionID()
if descid == scale_y:


Edit: Fixed typo in first code snippet.
Cinema 4D Plugin Developer | Freebies | Plugins

Last edited by NiklasR : 06 June 2013 at 03:39 PM.
  06 June 2013
Ok, figured it out the actual string name of the track has two spaces in it, one before the decimal point, one after it. That's not really obvious when reading the print in the Console and there's no way to copy paste from the console.. (and it's kinda silly IMO to have those spaces in there to begin with)..

anyhoo.. if you compare the track name to "Scale . X"
it works

  06 June 2013
Originally Posted by Horganovski: anyhoo.. if you compare the track name to "Scale . X"

Change the interface language, and whoops.
Cinema 4D Plugin Developer | Freebies | Plugins
  06 June 2013
Many thanks again Niklas, those examples and clarification are very helpful, appreciated.

  06 June 2013
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
Society of Digital Artists

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

All times are GMT. The time now is 03:38 AM.

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