Since this is my first post, I would like to touch on a little content. In fact, there may be a better way, in which case I would be grateful if you could provide information.
This time I want to detect attributes that are constrained or connected. The reason for this content in this topic is that you use listAttr to bring in attribute information. However, even if you apply isConnection to this and check it, constraint and Expression can be detected. If it is connected by connection, it will pass through.
Suppose you then strain the connected attrbute normally. Of course, when you burn the animation back, the connection will be disconnected.
This is a problem.
I'm really in trouble.
The quality of the rig can change. (Sometimes an outsider can destroy the rig with it.)
That's why it is detected properly when constraining somehow or processing collectively with a script etc. If it seems to be connected, please exclude it from the target! I made this content with the intention. It's okay to make it a checker specification and give a warning.
So I will enter the main part.
connection = pm.listConnections(node, connections=True)※1
if connection:
for _c in connection:
if (not isinstance(_c[0], pm.general.Attribute)※2
or isinstance(_c[1], pm.nodetypes.AnimCurveTA)
or not _c[0].isDestination()):
continue
#Attributes that bypass the above conditions are dependent attributes
Yes, I suddenly pasted the script, but for the time being, the above two lines (* 1) don't matter. I'm just looking at getting all the connections in node and seeing if I got them.
It collects only attribute attributes from listAttr, but listConnections is very powerful. If it's really connected, I'll get anything, so let's wash it out from here for the time being.
First of all, the information obtained by listConnection naturally has certain rules.
([nt.Attribute(name), nt.contraint(name)], [hoge, hage]...etc)
It looks like this, I wrote the content appropriately so please do not worry about the details. You can get the list part inside by turning it with the for statement.
This part: [nt.Attribute(name)※A, nt.contraint(name)※B]
In this list
It will be.
Now that you have extracted the information so far, all you have to do is check the status. The condition this time is the conditional expression (* 2) described in if in for.
if (not isinstance(_c[0], pm.general.Attribute)
or isinstance(_c[1], pm.nodetypes.AnimCurveTA)
or not _c[0].isDestination()):
Explain what you are doing
Use + isinstance to check if the information on the node side is an attribute.
It's a little brute force, but that's it.
The content itself is very simple, so I'm wondering if you're doing something similar in some way.
However, if you want to perform destructive processing on the data of other companies, I would be very grateful if you could do a similar process once again.
There are many other ways to check this. This time I used the ones used for strains, connections and rigs as an example, I think there is something similar around the texture.
If you have some experience, I think that you have investigated it properly and made it into a form that does not cause any problems. If you're just starting to study scripting! If so, I would like you to treat it as carefully as possible.
Please let me know if you have any.