MOGRT Parameters in UXP availabilty

Hello!

I have a small suite of plugins currently using CEP.
A core feature of these plugins is manipulating MOGRT properties (changing dropdown selections, text field contents, etc).

Is there any info on when this functionality will be available in UXP? At the moment I can see the properties, but their values not readable nor able to be set, which is essential to what I need to do.

Thank you for reading!

I have already seen this doing my own research. Given that the last official response is from March, I was hoping for more of an update, especially after the recent addition of MOGRT inserting into the API. Thank you for trying to help though!

When Adobe team says there’s no date or timeline, I’m already used to assume it might be a year or more. If the subject in question becomes available earlier, well.. - a pleasant surprise :slightly_smiling_face: And it actually happens sometimes if the feature (or bug) is critical :man_shrugging:

A .mogrt’s editable parameters are component param streams, and those have been in the UXP API for a while now; see keyframe.ts, in the 3p sample.

I’ve spent a good chunk of time today experimenting, including looking at that sample.I’ve been able to read some MOGRT properties, like drop downs, sliders and checkboxes (though their names never show) pretty well. But the main one I need, Text fields, I just cannot get a value out of. It’s definitely something I can do in CEP and extendscript so it’s fine for now, was just hoping to plan ahead for the future and this is pretty essential to the plug-ins my team use in their workflow.

I haven’t tried setting text yet, which is another important part for us but there’s no point doing that for me if I can’t read what it currently is.

This is an exciting discovery, can you provide some reference code? Thank you very, very much

It’s in the sample:

1 Like

@bbb_999 I know this thread is about three months old, but is it possible with the current PremierePro UXP API to set values for Mogrts that exist in a video track? You mentioned that it would be ready for the first official release — has it made it in as of today? Following your sample, I am able to get the Essential Properties from a Mogrt video track item, but I’m not entire sure how to update or set them. Any tips?

I’m told that all the component-related stuff we’ve exposed already is sufficient to access the param streams of imported .mogrts; I’m still struggling to cobble together useful sample code, demonstrating [same].

Off to audit some Component params, in the debugger…

Yes, examples would be very helpful here, thank you.

Assuming all component-related class objects have sufficient exposure for setting parameter values, would we update a mogrt param only by first creating a keyframe using createKeyframe found in the ComponentParam class? Then, use createSetValueAction or createSetTimeVaryingActionto actually set it?

An example would definitely help. Thanks @bbb_999

Would be great to get this example @bbb_999 as this would be really helpful for my work too!

Hi again. I just wanted to follow up on this as it has been a while. I’ve revisited porting my app from CEP to UXP now that it is generally available, and I still cannot get any data out of editable text parameters in my MOGRTs. I’ve tried those examples, and the same sample panel stuff, but still nothing. Is there any code that I’m missing that could help with this? Getting to my wits’ end. I appreciate all your assistance.

As I needed this capability as well, I created a test graphic and set the text to “Hello world !!!“ in Premier to test this ( then exported it as mogrt).

Dumping all parameters for all components (see the UDP sandbox on screenshot below), one can retrieve many parameter indeed.
… However it does not seem like the Caption of the text itself is exposed, neither for reading nor writing (if it is exposed somehow, it’s not not obvious how to get that).
I was able to move the text, rotate, scale, etc… but no way to change the data/text itself :frowning:

This is impacting a few scenario I can think of (and per the # of people chiming in, it seem pretty common).
@bbb_999 Please influence the right people (dev/pm/manager) to have this fixed soon :wink:

1 Like

@ariestav Yes, it seems to be the case.
( In my case I change them “globally”, I do not modify existing keyframes nor try to create animation )

Here is the sample code I used (code & helper function barely tested, just enough so I can start playing with mogrt).

  const ppro = require("premierepro");
  const proj = await ppro.Project.getActiveProject()
  const seq = await proj.getActiveSequence()
  const tt = ppro.TickTime.createWithSeconds(0)
  const seqEdit = await ppro.SequenceEditor.getEditor(seq)
  let videotrackColl  = null
  proj.lockedAccess( () => {
    videotrackColl = seqEdit.insertMogrtFromPath("C:\\Users\\marcc\\OneDrive\\Documents\\Adobe\\Premiere Pro (Beta)\\26.0\\greenRect.mogrt", tt, 2, 2)
//    videotrackColl = seqEdit.insertMogrtFromPath("C:\\Users\\marcc\\OneDrive\\Documents\\Adobe\\Premiere Pro (Beta)\\26.0\\textHelloWorld.mogrt", tt, 2, 2)
  })

  const trackitem =  videotrackColl[0]
  await DEBUG_dumpAllValues(trackitem)
  log("")
  log("====================")
  log("")
  await setComponentValue(trackitem, "Vector Motion", "Scale Width", 50) 
  const pos = ppro.PointF(0,0)
  await setComponentValue(trackitem, "Shape", "Rotation", 45) 
//  await setComponentValue(trackitem, Component.TEXT, Component.Parameters.TEXT.SOURCE_TEXT, "FOOBAR !?!?")  // setting text does not work
  log("")
  log("====================")
  log("")
  await DEBUG_dumpAllValues(trackitem)

with helper functions:

async function setComponentValue(trackItem, componentName, propertyName, newvalue) {
  let target = null
  const componentChain = await trackItem.getComponentChain()
  const component = await _getComponent(componentName, componentChain)
  const propertyCount = await component.getParamCount()
  for(let i = 0; i < propertyCount; i++) {
    const property = await component.getParam(i)
    const itemName = property.displayName
    if (itemName.toLowerCase() != propertyName.trim().toLowerCase()) {
      logDebug(`... property '${itemName}' does not match`)
      continue
    }
    logDebug(`Found matching property ${itemName}`)
    target = property
    break
  }
  if (!target) {
    throw new Error(`Property or component not found, unable to rename`)
  }
  let keyframeAtZero = await target.getStartValue()
  keyframeAtZero = getPropertyOrNull(keyframeAtZero, "value")
  keyframeAtZero = getPropertyOrNull(keyframeAtZero, "value")  // Duplicated on purpose, need obj.value.value
  logDebug(`Previous property value was set to '${keyframeAtZero}' changing to '${newvalue}'`)
  
  const kfEntry = target.createKeyframe(newvalue)
  const currProj = await ppro.Project.getActiveProject()
  let result = null
  await currProj.lockedAccess(async () => {
      result = currProj.executeTransaction((compoundAction) => {
        const action = target.createSetValueAction(kfEntry)  // Note: assuming this is a non time changing value
        compoundAction.addAction(action);
      })
  })
  if (! result) {
    throw new Error(`Unable to change the property value of the morgt`)
  }
}


———————

async function _getComponent(componentName, componentChain) {
  RETRY_SEC = 5
  let retval = null
  const start = Date.now()
  let end = Date.now()
  while (! retval && (end - start) / 1000 < RETRY_SEC ) {  // HACK / workaround for bug
    let count = await componentChain.getComponentCount()  // This seem to be changing over time (Adobe bug ?)
    let component = null
    for(let i = 0; i < count; i++) {
      component = await componentChain.getComponentAtIndex(i)
      const name = await component.getDisplayName()
      if (name.trim().toLowerCase() == componentName.toLowerCase()) {
        retval = component
        break
      }
    }
    if (! retval)
    {
      logWarning("Specified component not found yet, trying again")
      await sleep(250)
      end = Date.now()
    }
  }
  if (!retval) {
    logError(`Unable to find component '${componentName}'`)
    throw new Error(`Unable to find component '${componentName}'`)
  }
  return retval
}

========================

To dump properties:

function getPropertyOrNull(obj, propertyName) {
  let retval = null
  if (obj === null) {
    return retval
  }
  try {
    retval = obj[propertyName]  // for some reason Object.hasOwn(propertyName) does not work
  }
  catch (err) {
//    retval = null
  }
  return retval
}

———————

async function DEBUG_dumpAllValues(trackItem) {
  let target = null
  const componentChain = await trackItem.getComponentChain()
  const componentCount = await componentChain.getComponentCount()
  for(let i = 0; i < componentCount; i++) {
    const component = await componentChain.getComponentAtIndex(i)  
    const compName = await component.getDisplayName()
    logDebug(compName)
    const propertyCount = await component.getParamCount()
    for(let i = 0; i < propertyCount; i++) {
      const property = await component.getParam(i)
      const itemName = property.displayName
      if (!property) {
        logDebug(`... (empty property)`)      
        continue
      }
      let keyframeAtZero = await property.getStartValue()
      keyframeAtZero = getPropertyOrNull(keyframeAtZero, "value")
      keyframeAtZero = getPropertyOrNull(keyframeAtZero, "value")  // Duplicated on purpose, need obj.value.value
      logDebug(`... '${itemName}'  -->  ${keyframeAtZero}`)
    }
  }
}

Before

After:

I’ve been able to get similar results to yourself. I can get property names and the values of some parameters, but text inputs are a no go, seemingly with both Prem and AE (which is where my focus is) MOGRTs. This is something I can do in CEP with relative ease and the manipulation of text and other fields is core to what my tools do. Without that functioning reliably, I can’t port anything. really hope we can get an update on this soon.

Thanks for your updates. I have unfortunately not been able to get back to my UXP project because of other obligations, but am following this thread because I had hit a wall with MOGRT properties and UXP, too.

Mutating strings within MOGRT’s Essential Graphics from UXP code is essential for my project, but it does not quite seem possible given both of your experiments, and mine.

@MarcClown I understand you have refrained from keyframes in your components and you are setting values to them “globally” for the entirety of the clip duration, but my thought was that maybe the setComponentValue method works only on component keyframes. What happens if you first create a keyframe at the first frame of the video component, then use setComponentValue for that keyframe. I’m doubtful it would do anything because the base components don’t seem to need keyframes, but my next attempt was going to do a test like that unless I hear otherwise.

It’s still not immediately obvious to me how one goes about setting MOGRT component params from UXP.

Yeah, I did try with adding a keyframe before exporting to MOGRT as well, did not work either.

BTW, there is another thread on mogrt & setting keyframe; it seem to be even more broken (some property accept the change but the none of the data is reflected back to premiere)

1 Like

@MarcClown Thanks for sharing your results with that — I appreciate it.

@bbb_999 Any chance you were able to cobble up sample code for setting MOGRT component param values via UXP? I think just a bit of direction would go a long way here. If it’s not yet implemented, no problem, but please confirm if that is the case. Many thanks!

2 Likes

I am facing the same issue. Hope they can figure it out soon.

2 Likes