Scripting – Getting reference model Resolutions



You can get at the Resolutions through scripting (via NestedObjects or Dictionary.GetObject), but you can get the resolution name and file only.

from siutils import si		# Application
from siutils import sidict	# Dictionary
from siutils import sisel	# Selection
from siutils import log		# LogMessage

def getResolutionFileName( m, res ):
	if ( m.Type == "#model" and m.Parameters("referenced_model").Value==True):
		return sidict.GetObject( m.FullName + ".resolutions." + res + ".file" ).Value
		
log( getResolutionFileName( sisel(0), 'res1' ) )
log( getResolutionFileName( sisel(0), 'res2' ) )
log( getResolutionFileName( sisel(0), 'res3' ) )
		
# INFO : Models\Octa-Low.emdl
# INFO : Models\Octa-Med.emdl
# INFO : Models\Octa-High.emdl

Going through NestedObjects is a bit more of a hassle:

from siutils import si		# Application
from siutils import sidict	# Dictionary
from siutils import sisel	# Selection
from siutils import log		# LogMessage

import win32com.client.dynamic

def getResolutions( m ):
	if ( m.Type == "#model" and m.Parameters("referenced_model").Value==True):
		return m.NestedObjects( "Resolutions" ).NestedObjects

resolutions = getResolutions( sisel(0) )

for r in resolutions:
	name = sidict.GetObject( r.FullName + ".name" ).Value
	file = sidict.GetObject( r.FullName + ".file" ).Value
	log( name )
	log( file )

	# This errors out with the dynamic dispatch fix:
	name = r.NestedObjects( "name" )
	log( si.ClassName( name ) )
	log( win32com.client.dynamic.Dispatch(name).Value )

One thought on “Scripting – Getting reference model Resolutions

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 )

Google+ photo

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

Connecting to %s