That is awesome !!!

On 29/07/2012 5:32 PM, Alan Fregtman wrote:
Hey guys,

You're all forgetting the ConnectionStack. It tells you what's connected under the hood. No need to scan through all expressions in the scene!


import xml.etree.ElementTree as ET

def getExpressionsDrivenByParameter( param ):
    stack = XSIUtils.DataRepository.GetConnectionStackInfo(param)

    expressions = XSIFactory.CreateObject('XSI.Collection')
    xml = ET.fromstring(stack)
    for conn in xml.findall('connection'):
        if conn.find('type').text == 'out':
            item = conn.find('object').text
            if item.endswith('._expression_'):
                expressions.AddItems(item)

    return expressions


It took 4.5s on my laptop to find 10,752 expressions that were pointing to one single parameter. Fast enough for ya? :) -- In a less ludicrous use case, it's pretty much instant.

   -- Alan


On Sat, Jul 28, 2012 at 11:51 AM, Alok Gandhi <[email protected]> wrote:
Hi Jeremy,

I missed this first time but to make it more elegant you (not a speed up) you can even do:
def getExpressionsDrivenByParameter( param ):
    return PARAM_EXPR_DICT.get(param.FullName)

which is exactly the same as before but cleaner code,

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2197 / Virus Database: 2437/5162 - Release Date: 07/29/12


Reply via email to