SOLVED Get MM pair with script?
cj last edited by frederik
Hi! I'm trying to get the current MM pair so I can display related words in SpaceCenter.
and I was able to get the current selection from the pair list using:
This will work most of the time, except if I edit the pair manually and the pair is not in the list. Is there a method to
getCurrentPair()or something? I wasn't able to find it. Thanks so much!
Here's what I've got so far:
def getMetricsMachineController(): # Iterate through ALL OBJECTS IN PYTHON! import gc for obj in gc.get_objects(): if hasattr(obj, "__class__"): # Does this one have a familiar name? Cool. Assume that we have what we are looking for. if obj.__class__.__name__ == "MetricsMachineController": return obj # Get the current font. font = CurrentFont() # Get the MM main controller. metricsMachineController = getMetricsMachineController() # Get the document controller for the current font. documentController = metricsMachineController._openControllers[font.naked()] # private attribute! selection = documentController.pairList.getSelection() print (selection)
(Thanks @jackson for inspiring me to actually dig into this tonight)
tal last edited by
That may (or may not work). The scripting API that will be in version 1.1 will handle all of this for you. I'm getting close to releasing that.
cj last edited by
@tal This works, thank you so much! I just tried using the scripting API and the new metricsMachine.GetCurrentPair() works perfectly, thank you! I'm very excited about the scripting API, such a great addition to MetricsMachine.