Top 10% !
Popularity: 224029th place
Modified Jun 28, 2013

Published on:

No tags for this snippet yet.

A simple script for MODO that reads current channel selection from scene and outputs it to Event Log.

A simple script for MODO that reads current channel selection from scene and outputs it to Event Log.:
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
# python """ Get Channel Selection. There is no utility class for handling channel selection like there is for items and scenes so it has to be done manually. """ import lx selection_service = lx.service.Selection() chan_sel_type = selection_service.LookupType(lx.symbol.sSELTYP_CHANNEL) """ Channel selection is stored in packets, like all other selections. Every packet contains information about one channel. To read channel selection we have to use ChannelPacketTranslation object that will decode selection packet and then we will be able to pull channel information from it. The line below initializes ChannelPacketTranslation object that is used to extract selection information from selection packet. """ chan_transpacket = lx.object.ChannelPacketTranslation(selection_service.Allocate(lx.symbol.sSELTYP_CHANNEL)) """ To see how many elements of a given type are selected in scene we use selection service's Count method. We pass integer selection type code to the method, in our case it's channel selection type code. """ chan_n = selection_service.Count(chan_sel_type) """ Now we're going to loop through all channel packets and read them by index. To do that we're using selection service's ByIndex method passing it channel selection code and an index of a packet we want to get. The method returns a pointer to the packet. We're going to pass this pointer to translaction packet to extract single channel selection. """ for x in xrange(chan_n): packet_pointer = selection_service.ByIndex(chan_sel_type, x) if not packet_pointer: lx.out('Bad selection packet, skipping...') continue """ Channel selection is 2 elements: item object the channel belongs to and a channel index. To pull this information out from packet we use Item and Index methods from ChannelPacketTranslation interface (that we already initialized) and we pass packet pointer to these methods. """ item = lx.object.Item(chan_transpacket.Item(packet_pointer)) chan_idx = chan_transpacket.Index(packet_pointer) """ Show selection info in Event Log """ lx.out('%s : %s' % (item.UniqueName(), item.ChannelName(chan_idx)))
If you want to be updated about similar snippets, Sign in and follow our Channels
Originally posted on