TP scripting - getting a list of all dynamic sets' names

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2013
TP scripting - getting a list of all dynamic sets' names

Hello guys,

I'm making a tool to set/cache dynamic sets. My problem is scanning the dynamic set tree. From what I understand it has to be done recoursively? When I use this:

DynSetRef = <some dynamic set reference target here>
DynSet = (DynSetRef.GetObject())
count = DynSet.NumDynSets()
for i = 1 to count do
(
childref = (DynSet.GetDynSet i)
ChildName = (childref.GetName())
format "NAME IS % \n" ChildName
)

I only get the child names when I use it on the Master Dynamic, and with any other dynset that has children, it gives me back the first child, no matter what index I give to the GetDynSet method. Any ideas?

Thanks!
 
  09 September 2013
Well, this was harder than expected Anyways, here's the code, assuming only a TP node is selected:


fn GetDSNames DynSetRef =
(
	format "NAME IS % \n" (DynSetRef.GetName())
	if dynsetref.operators.count >0 then 
		for i = 1 to dynsetref.operators.count do GetDSNames dynsetref.operators[i]
)


for i = 1 to ($.MasterDynamic.NumDynSets()) do
	GetDSNames $.MasterDynamic.DynamicSets[i]
 
  09 September 2013
Glad you got it! Yeah I was messing around with this a little bit last night, I got blurry eyed and sleepy before I came to a good clean solution. What I noticed is you have to add to a new name array from the operators that have greater than 0 operators to consider it a nested dynSet, of which you can index against.

Interesting little project, thanks for posting, I wish I could have gotten to spend a little more time on it.
__________________
poof ~>Vimeo<~
 
  09 September 2013
Cool thing is, you can then use the .masterdynamic.cacherecordname method, to cache a selected dynset
 
  09 September 2013
There should be an easier way, It would be great if there were a:

tp.masterDynamic.isDynSet <boolean>

check function to easily identify dynsets, nested dynsets, and nested nested dynsets, instead of relying on count and naming conventions.
__________________
poof ~>Vimeo<~
 
  09 September 2013
So eventually what worked is this:

fn GetDSNames DynSetRef =
(
if classof (DynSetRef.GetObject()) == DynamicSet then
(
LBDynSets.items = append LBDynSets.items (DynSetRef.GetName())
if dynsetref.operators.count >0 then
for i = 1 to dynsetref.operators.count do
GetDSNames dynsetref.operators[i]
)
)

for i = 1 to ($.MasterDynamic.NumDynSets()) do GetDSNames $.MasterDynamic.DynamicSets[i]
 
  09 September 2013
Oh cool, testing for class. duh, guess I should have known that I do it all the time
__________________
poof ~>Vimeo<~
 
  09 September 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
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 03:54 AM.


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