CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-07-2013, 02:28 PM   #1
Horganovski
Freelance Animator/Rigger
 
Horganovski's Avatar
portfolio
Brian Horgan
Graphite9
Dublin, Ireland
 
Join Date: Apr 2007
Posts: 4,845
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.

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


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

Cheers,
Brian
 
Old 06-07-2013, 03:30 PM   #2
NiklasR
Expert
 
NiklasR's Avatar
portfolio
Niklas Rosenstein
Germany
 
Join Date: Jan 2011
Posts: 436
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.

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


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.

Code:
scale_y = c4d.DescID( c4d.DescLevel(c4d.ID_BASEOBJECT_REL_SCALE), c4d.DescLevel(c4d.VECTOR_Y)) descid = track.GetDescriptionID() if descid == scale_y: track.Remove()


-Niklas

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

Last edited by NiklasR : 06-07-2013 at 03:39 PM.
 
Old 06-07-2013, 03:35 PM   #3
Horganovski
Freelance Animator/Rigger
 
Horganovski's Avatar
portfolio
Brian Horgan
Graphite9
Dublin, Ireland
 
Join Date: Apr 2007
Posts: 4,845
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

Cheers,
Brian
 
Old 06-07-2013, 03:37 PM   #4
NiklasR
Expert
 
NiklasR's Avatar
portfolio
Niklas Rosenstein
Germany
 
Join Date: Jan 2011
Posts: 436
Quote:
Originally Posted by Horganovski
anyhoo.. if you compare the track name to "Scale . X"


Change the interface language, and whoops.
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
Old 06-07-2013, 04:22 PM   #5
Horganovski
Freelance Animator/Rigger
 
Horganovski's Avatar
portfolio
Brian Horgan
Graphite9
Dublin, Ireland
 
Join Date: Apr 2007
Posts: 4,845
Many thanks again Niklas, those examples and clarification are very helpful, appreciated.

Cheers,
Brian
 
Old 06-07-2013, 04:22 PM   #6
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:15 AM.


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