Author Topic: Accessing and adding to Multi-Pass via Python  (Read 1247 times)

2024-07-11, 19:04:28

JPeters

  • Active Users
  • **
  • Posts: 91
    • View Profile
Hi guys,

Tried searching around a bit but could not find anything on it.

I am trying to access Multi-Pass via Python, add some Masks with Object ID/ Material ID and unique names.

The script log gives me some pointers on how to address the individual properties but not how to initially enable multipass (it's normally disabled by default in a new scene) and add a new mask.

Any pointers?

Cheers!

2024-07-11, 20:01:15
Reply #1

John_Do

  • Active Users
  • **
  • Posts: 171
    • View Profile
I wrote something to do exactly that, do you want to do something like this ?




2024-07-12, 08:39:28
Reply #2

JPeters

  • Active Users
  • **
  • Posts: 91
    • View Profile
Hi John_Do,

Yes, indeed I want to make something very similar :)

Do you mind sharing a bit of the code or giving me a pointer to where I can find documentation?
« Last Edit: 2024-07-12, 08:45:24 by JPeters »

2024-07-12, 09:16:21
Reply #3

John_Do

  • Active Users
  • **
  • Posts: 171
    • View Profile
Hi,

There is no documentation for this stuff, but you can find some hints in the description files stored in the Corona plugin folders ;)

I get back later today with the code and some explanations.

2024-07-12, 10:19:47
Reply #4

m4drid

  • Active Users
  • **
  • Posts: 19
    • View Profile
I hope it was helpful

2024-07-12, 13:40:53
Reply #5

John_Do

  • Active Users
  • **
  • Posts: 171
    • View Profile
I hope it was helpful

Nice !

I wrote a quite similar code on my side.

Get and set multi-pass settings

Code: [Select]
# Access to the corresponding scene hook
mp_settings = doc.FindSceneHook(1037467)

# Enable multipass
if mp_settings[c4d.CORONA_MULTIPASS_ENABLE] == 0:
mp_settings[c4d.CORONA_MULTIPASS_ENABLE] = 1

Get passes list

Code: [Select]
# Passes are stored under a c4d.GeListHead object
# First we get the scene hook that stores multipass settings
# and the branch for passes

hook = c4d.documents.GetActiveDocument().FindSceneHook(1037467)
branch = hook.GetBranchInfo()


# Then we look for the list head

if branch:
head = [b.get('head') for b in branch if b.get('id') == 1037373]
if head:
head = head[0]
                return head

Then you can handle the passes list from the head level or the nodes level depending on your needs.

2024-07-12, 14:18:40
Reply #6

JPeters

  • Active Users
  • **
  • Posts: 91
    • View Profile
Thank you both very much! I will have a look at the code and see how I can implement it into my plugin :)

@m4drid: That is an extensive code! wow.

I've not come across this before, but what is a Scene Hook exactly?

Cheers!
« Last Edit: 2024-07-12, 14:32:39 by JPeters »

2024-07-12, 19:59:14
Reply #7

John_Do

  • Active Users
  • **
  • Posts: 171
    • View Profile

I've not come across this before, but what is a Scene Hook exactly?

Cheers!

Np, let us know what you are cooking ;)

Regarding Scene Hook I don't know ( I'm just hacking my way through Cinema's Python SDK), you have to ask the devs ! But it seems like a way to store specific data at the document level ( multipass, corona nodes ) without parenting / nesting it inside an already existing Cinema 4d object (like c4d.GetWorldContainer() / c4d.SetWorldContainer()). It's specific to C++ plugins.

Some info here :
https://developers.maxon.net/docs/cpp/2024_4_0/class_base_scene_hook.html#af1445d83b18dbfa67d8c663d308dde48

https://developers.maxon.net/docs/cpp/2024_4_0/class_scene_hook_data.html




2024-09-04, 10:09:14
Reply #8

JPeters

  • Active Users
  • **
  • Posts: 91
    • View Profile

I've not come across this before, but what is a Scene Hook exactly?

Cheers!

Np, let us know what you are cooking ;)



Sorry for the late reply, slipped my mind :)

Managed to finish my plugin for our artists.
It's a plugin that makes it possible for you to select objects and shaders in a scene and then automatically populate the multi-pass window with masks carrying the same name as the object/shader.
There is also a button to clear the existings masks.

It's very simple in terms of functionality but it saves a ton of work with things like interior scenes etc.

Cheers for the help guys!