Python – Getting rules from a connection mapping template


This snippet shows how to read a connection (or value) mapping template into a Python dictionary.

t = Application.Dictionary.GetObject( "Model1.Mixer.MappingTemplate1" )

n = Application.GetNumMappingRules( t )

d = {}
for i in range(1,n+1):
        r = Application.GetMappingRule( t, i )
        d[r.Value("From")] = r.Value("To")
        
for k, v in d.iteritems():
     Application.LogMessage( k + " > " +  v )

Line 8 GetMappingRule uses output arguments, so we have to take the returned ISIVTCollection and extract the From and To output arguments. We use From as the dictionary key.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s