0
$\begingroup$

When appending models to a scene via the API, is there a way to prevent the end users from editing the mesh? The use would only have access to the translation and material setting properties ideally. What I am looking for is similar to Arnold Archive meshes in Maya, if anyone is familiar with how that works.

$\endgroup$
1
$\begingroup$

In general this is possible, but a few conditions must be met to achieve this.

First off, to prevent the end user to accidentally edit the mesh, it has to be linked instead of appended to the file. In order to answer that from a scripting point of view you need to provide more detail on how you handle the appending currently. There are low-level and high level approaches to this, so please add your code to the question. The tricky part is that if you want to edit material assignment, only the mesh data must be linked, but the object must be local. If all tansforms on the incoming object are applied, that would be trivial. You could then create a new mesh object in Python, and use the linked mesh datablock in it. Otherwise, things become more tricky or require end user interaction.

Note that linking the mesh in will also mean that whenever the source mesh in the source file is updated, it will be updated in all files that link it as well on reload.

Second, by default Blender associates the object data datablock with the material. That means, the mesh datablock you have just linked in also defines what materials are assigned to the mesh. Since now the data is linked and unchangeable, you can not change the material any longer. The solution to that is to set the material link to 'Object' instead, like in the answer given here.

$\endgroup$
  • $\begingroup$ Thanks, only stub code at the moment so nothing really to share. I wanted to make sure it was in the realm of possibility as I concept the functions of the add on. $\endgroup$ – Regi Ellis Jun 16 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.