Results 1 to 6 of 6

Thread: Return number of servers on a channel

  1. #1

    Return number of servers on a channel

    Is there a way to return the number of servers applied to the envelope of a channel?
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  2. #2
    Here's the simplest way I can think of. This script looks at the items in the user selection, checks their "X.Position" channel, and prints out any plugins they are using, if any. It also prints the number of servers.

    Code:
    import lwsdk
    
    # Get ItemID selection (for script-based functions)
    UserSelection = lwsdk.LWInterfaceInfo().selected_items()
    
    for x in range(0, len(UserSelection)):
    	cGrp = lwsdk.LWItemInfo().chanGroup(UserSelection[x])
    	chan = lwsdk.LWChannelInfo().nextChannel(cGrp, None)
    
    	while chan!= None:
    		chanName = lwsdk.LWChannelInfo().channelName(chan)
    
    		# Insert any channel functions here as desired.
    		if chanName == "Position.X":
    			print "Position X Found!"
    			ServerCount = 1
    
    			while ServerCount != None:
    				Server = lwsdk.LWChannelInfo().server(chan, lwsdk.LWCHANNEL_HCLASS, ServerCount)
    				print Server
    				if Server != None:
    					ServerCount += 1
    				else:
    					NumberOfServers = ServerCount - 1
    					ServerCount = None
    
    		chan = lwsdk.LWChannelInfo().nextChannel(cGrp, chan)
    
    	print NumberOfServers
    Now if you want to check whether or not a channel is controlled via an expression... currently I don't know if its possible as I see no functions that can check for their existence.
    Last edited by Ryan Roye; 11-30-2016 at 10:03 AM.
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  3. #3
    Thanks Ryan. I'm already doing something similar. Was hoping there was a direct way to query the number of servers without having to iterate and check.
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  4. #4
    Quote Originally Posted by ernpchan View Post
    Thanks Ryan. I'm already doing something similar. Was hoping there was a direct way to query the number of servers without having to iterate and check.
    If you ever find a way to find whether or not a channel is driven by an expression, let me know. Sometimes I need rigging scripts that can pick apart which items are constrained and which are not, and this kind of blocks me from making things fully automatic/error free for the user.
    Professional-level 3d training: Ryan's Lightwave Learning
    Plugin Developer: RR Tools for Lightwave

  5. #5
    Quote Originally Posted by Ryan Roye View Post
    If you ever find a way to find whether or not a channel is driven by an expression, let me know. Sometimes I need rigging scripts that can pick apart which items are constrained and which are not, and this kind of blocks me from making things fully automatic/error free for the user.
    Feature request it. I couldn't find anything that let you check that. Just applying and deleting expressions in the lscript dox.
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  6. #6
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,470
    Quote Originally Posted by ernpchan View Post
    Feature request it. I couldn't find anything that let you check that. Just applying and deleting expressions in the lscript dox.
    Did anyone ever file this as a feature request?

    There's a bunch of cases like this in LW Python SDK. PRIS (or whatever) ought to provide proper "Pythonic" iterators/generators for processing such entity/attribute lists/hierarchies.
    John W.
    LW2015.3UB/2018.0.7 on MacPro(12C/24T/10.13.6),32GB RAM, NV 980ti

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •