Attribute equivalent for reference.isLoaded()

Hey all,

I’m trying to solve an issue around constraints and references.

Basically, the issue is when you constrain to a referenced object, then unload the reference, the constrained object freezes. Makes sense because there’s no more input since it’s now just hooked up to the reference node with the last value rather than the target until the target is loaded again.

My rough idea to try and get around it is to have the script that sets up that constraint also constrain to the destination object’s parent and set that weight to zero. Then through some connection (I was hoping for a “loaded” attribute somewhere on the reference node, but no dice) set that to 1 and the target to 0 when the reference is unloaded.

Basically something along the lines of this:

The fallback is to make some sort of callback to do that attribute change, but I’d prefer to avoid that if possible and just do some sort of node network since that seems a little more bullet-proof, but I’m not finding any node/attribute combo that’ll let me do it that way. Not sure if anyone’s dealt with this sort of thing or has any bright ideas, but I figured I’d ask around before throwing in the towel.

Any ideas?

P.S. - We’re on Maya 2018

I think I understand the problem but what is the result you’re looking for? What exactly do you want the constrained object to do when the referenced target is not loaded?

Sorry if the image explains that, it’s not loading for me atm.

oh, hah. It isn’t showing for me either. It was displaying fine on my work computer. I’ll give it another shot when I get back in to the office.

Basically, I’m trying to find a way to set the weights to a constraint based on whether a reference is loaded. So the picture was in the node editor of a reference node with a theoretical “isLoaded” bool attribute. That attribute was connected directly to a target weight in a parent constraint, and then to the other target weight with a remap value in-between. So then if isLoaded is True (or 1), the weight values are 1, 0, and then reversed if unloaded.

So basically:
refNode.isLoaded>>remapValue.inputValue (remap turns the 1 in to 0, 0 in to 1)

Hope that makes sense.

I was trying to find some sort of attribute, or condition I could seize on to get a True/False value, but I’m hitting dead ends. Another thing I was trying to find was some node that could count connections to an attribute, I could use the placeholder attributes that are made on the reference node when unloading, but I can’t find a stock maya node that does that sort of thing. Basically a lot of things that are simple commands that I’m trying to find a node equivalent for.

To my knowledge, there is no such connectable attribute. If this is how you’re set on doing it, you could use a one-line expression:

locator1.translateX = referenceQuery -isLoaded "refNodeRN";

It evaluates on time changes (not immediately on load/unload).

Yeah, I was figuring expressions might be the only pseudo-connection way of doing it, but yeah, probably too heavy for such an edge-case. I was experimenting with script nodes, hoping the open/close one would run when in a reference when unloading, but unfortunately not. OK. looks like a lightweight callback might be the only option.