Skip to main content
Participant
May 11, 2022
Question

Reloading a resource material

  • May 11, 2022
  • 1 reply
  • 629 views

Hello,

 

I am trying to reload a material via the python API, and got an error I don't quite understand. For context the material is applied to a texture set in the scene, and it is a sbsar.

 

I am using the url of the applied material to get the old ID, import the new material to get the new resource, and then call

substance_painter.resource.update_layer_stack_resource(old_resource_id, resource)

However, in the python console, it reads out a RuntimeError: 

RuntimeError: Unable to update Resource. Resource type not supported. Only images, particles and substances are supported.

In the API docs, some limitations are called out:

The new resource must be of the same type as the resources it replaces. For example a base material resource cannot be updated with a smart material resource.

Moreover:

  • If the resource is a Substance material, it must have the same number and names of outputs.

  • If the resource is a Substance filter, it must have the same number and names of inputs and outputs.

But to test my code, I have not changed anything about the material to make sure what is being called out couldn't be what is happening.
Long story short, are SBSAR materials not able to reload?

Thank you for any insights.

This topic has been closed for replies.

1 reply

Léna Piquet Froyok
Adobe Employee
Adobe Employee
May 12, 2022

Does it work if you use the resource updater plugin to update your material ?

Part of the limitations when updating resources is that Substance Materials need to have the same amount of inputs/outpus (or at least the same minimum, if the configuration change the update function will fail because of missing information).

hanticAuthor
Participant
May 12, 2022

Yes, the Resource Updater does work.

I get warnings that an output isn't recognized like: [Substance Effect Presenter] Output fresnelior was not recognized
But it is successful in reloading. 

I am not sure what is happening that is different when run programatically. 

Léna Piquet Froyok
Adobe Employee
Adobe Employee
May 13, 2022

If you can share some sample code/plugin or project to investigate this would be helpful at this point.

I gave a try at both the Resource Updater and the Python API to update/replace materials and they seem to be working as ecpected for me.