Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AYON event system for 3dsMax Callback #5

Open
2 tasks done
moonyuet opened this issue Sep 6, 2023 · 1 comment
Open
2 tasks done

Use AYON event system for 3dsMax Callback #5

moonyuet opened this issue Sep 6, 2023 · 1 comment

Comments

@moonyuet
Copy link
Member

moonyuet commented Sep 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior:

Why isn't 3dsmax using the OpenPype event system like the other hosts? Let's create an issue to track that and fix that in a separate PR. Each host should try and emit the events in a DCC agnostic way so that global OpenPype tooling could hook into it, like scene saves, etc.

Originally posted by @BigRoy in ynput/OpenPype#5499 (comment)

Expected Behavior:

  1. Using AYON event system for the callbacks in 3dsmax.
  2. Can take references from the Maya hosts.

Version

3.16.5

What platform you are running AYON on?

Windows

Steps To Reproduce:

n/a

Are there any labels you wish to add?

  • I have added the relevant labels to the bug report.

Relevant log output:

No response

Additional context:

No response

[cuID:OP-6769]

@moonyuet moonyuet changed the title Bug: Use OpenPype event system for 3dsMax Callback Use OpenPype event system for 3dsMax Callback Sep 6, 2023
@BigRoy
Copy link
Contributor

BigRoy commented Oct 3, 2023

For more details on Max's event system see these documentation pages:

As such it looks like that on host install we should be able to do this in OpenPype:

pseudocode

from functools import partial
from openpype.lib import (
    register_event_callback,
    emit_event
)

import pymxs
rt = pymxs.runtime


def emit_event_notification_param(event):
    notification = rt.callbacks.notificationParam()
    emit_event(event, {"notificationParam": notification})


def register_callbacks():

    id = rt.Name("openpype_callbacks")

    # init
    rt.callbacks.addScript(
        rt.Name('postSystemStartup'),
        partial(emit_event_notification_param, "init"),
        id=id
    )

    # open
    # todo: we might want filePreOpenProcess and filePostOpenProcess?
    rt.callbacks.addScript(
        rt.Name('filePreOpen'),
        partial(emit_event_notification_param, "before.open"),
        id=id
    )
    rt.callbacks.addScript(
        rt.Name('filePostOpen'),
        partial(emit_event_notification_param, "open"),
        id=id
    )

    # save
    # todo: we might want filePreSaveProcess and filePostSaveProcess?
    rt.callbacks.addScript(
        rt.Name('filePreSave'),
        partial(emit_event_notification_param, "save"),
        id=id
    )
    rt.callbacks.addScript(
        rt.Name('filePostSave'),
        partial(emit_event_notification_param, "after.save"),
        id=id
    )

    # new
    # todo: not entirely sure whether systemPostNew means "new file"
    rt.callbacks.addScript(
        rt.Name('systemPostNew'),
        partial(emit_event_notification_param, "new"),
        id=id
    )

Then that would roughly mimic what Maya does by emitting OpenPype events:

  • "init" dcc startup initialization finished
  • "save" workfile saved
  • "open" workfile opened
  • "new" new workfile started

Which is implemented in Maya here and then install also install callbacks to those here.


Removing all callbacks should then be as easy as:

rt.callbacks.removeScripts(id=rt.name("openpype_callbacks"))

I have never worked in 3DsMax so take this with a grain of salt.

@moonyuet moonyuet transferred this issue from ynput/OpenPype Jul 17, 2024
@moonyuet moonyuet changed the title Use OpenPype event system for 3dsMax Callback Use AYON event system for 3dsMax Callback Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants