Materials Erased by Paint Gun

Hi all,


I’m having a problem that’s stopping up my whole project. I asked before, but I think the post was buried on the last page of an old thread. Does anybody recognize this behavior?

When my robot goes to paint a surface, parts of the paint gun and the robot itself randomly turn orange. The materials are set to “NULL”. They come back to normal when the affected components are rebuilt or the scene is reloaded. Here are some visuals:

Painting the pallet has affected the robot’s base, even though the spray zone is not touching it.

Hitting the robot directly also erases the material.

The weird thing is, this behavior isn’t even consistent! When running a single program multiple times, sometimes nothing gets turned orange, and sometimes everything does.


Thanks very much for any advice,

P. Poog

Update: The issue seems to be less common right after loading the scene. It normally starts to occur after the model rebuilds - either I update a property or save the scene. When the model rebuilds this way, the materials return but the material-removal problem never ceases.

Update: It turns out that the “prepare for paint” command needs to be run to fix behavior. I don’t think I can save the model I’m trying to paint in a way that preserves the tesselation, and each time the model rebuilds it re-loads its original geometry. This is really annoying; anybody know a way to make the paint target model stay prepared?


Hi all,

I figured out how to fix this issue. There’s a line in the paint script, aptly dubbed “PaintScript”, which calls for a default paint material:

base_paint = app.findMaterial("_PaintBlueGradient")

The material didn’t exist in the local libraries and couldn’t be added because of the leading underscore, so the script could only set “base_paint” to “null”. Then, it uses the “base_paint” material in certain edge cases when painting. I turned this behavior off by commenting out one line:

Whole thing works now; we only paint items prepared for painting and leave everything else alone.