Hi,
I’m having problems performing this via Python. If using the UI, you would right click the reference and choose to list the reference edits. Then you can select each edit and hit “Remove reference edit”.
I’ve successfully been able to list reference edits in various ways with:
cmds.referenceQuery( "soffaRN", editStrings=True )
Result: [u'parent -s -r "|kuddar:pillows1" "|model2670"',
u'parent -s -r "|kuddarRNfosterParent1|pillow_04" "|model2670|kuddar:pillows1"',
u'setAttr |soffa:model2670.translate -type "double3" -506.529608 65.636552 493.906544',
u'setAttr |soffa:model2670.rotate -type "double3" 212.335372 0 -91.855932'] #
cmds.referenceQuery( "soffaRN", editNodes=True )
Result: [u'|kuddar:pillows1',
u'|model2670',
u'|kuddarRNfosterParent1|pillow_04',
u'|model2670|kuddar:pillows1',
u'|soffa:model2670',
u'|soffa:model2670'] #
cmds.referenceQuery( "soffaRN", editAttrs=True )
Result: [u'translate', u'rotate'] #
But I can’t seem to find a way to take any of those responses and actually remove each edit.
Any ideas?
Regards,
Fredrik
for ref in pm.listReferences(): ref.unload() for edit in ref.getReferenceEdits(): # this way you can selectively remove edits pm.ReferenceEdit(edit, fileReference=ref).remove(force=True) ref.load()
for ref in pm.listReferences(): ref.unload() ref.clean() ref.load()
Hi Luke, this is very useful.
I save out all the edits to an editMB file before cleaning it. And when I save out that file as well as when I re-apply it later down the road, Maya crashes sporadically. Currently, I’m not unloading the reference when performing the edits export and the edits import. Perhaps that could be why it’s crashing on me? (it’s not always crashing)
Your pymel examples looks really clean. I managed to do it without pymel, but it’s a bit more cumbersome. I wonder if pymel is a more stable way of dealing with this?
Here’s what I did to remove all edits (on a loaded reference):
# Remove all edits
ref = 'myrefRN'
nodes = cmds.referenceQuery( ref, editNodes=True )
attr_types = cmds.referenceQuery( ref, editAttrs=True )
for node in nodes:
for attr_type in attr_types:
for edit_command in ['addAttr', 'connectAttr', 'deleteAttr', 'disconnectAttr', 'parent', 'setAttr', 'lock', 'unlock']:
cmds.referenceEdit( node+'.'+attr_type, failedEdits=True, successfulEdits=True, removeEdits=True, editCommand=edit_command)
// Fredrik
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2ee0b079-d794-4d84-956e-d465ae245e22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Whoops … I meant to write that Maya crashes when I export the editMB (sometimes) and later down the road it also crashes (sometimes) when I save down the edits into the actual scene (“Save reference edits”).
By the way, this is how I save down the reference edits on a loaded reference:
filepath = '..............'
cmds.file(filepath, saveReference=True, force=True)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWNj_9tCTkjnmpHvU9CYO4b5iEY-cvA4zK%2BSZDq-51D2jg%40mail.gmail.com.
One stable way I've gone about it in the past is to update the .ma file.
How do you mean, exactly?
Do you mean launching a separate process such as maya -batch -command "[mel code]" -file hello.ma
or do you mean reading in the .ma contents and modifying it with Python?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWP4t8znzmfXR9c-c2O-%3DmqreigKuKsbW%3DHG8K3%3DH8xcPQ%40mail.gmail.com.
removeEdits?
probably is safer, but you have to unload the reference first.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOChbuv2ti4%3DPHD35xnUG%3DXgon7WUjybGV%3D9rjOg6a%2BRvA%40mail.gmail.com.
Yes, however, that just simply does not work at all.
Try this;
for ref in cmds.ls(references=True):
cmds.referenceEdit( ref, removeEdits=True)
Here in my scene, nothing happens. No reference edits was removed.
cleanReference
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWP3ow98GjVjpcArMwg7SbL6ZAuH0AoJhOzG76%2BQoZ6omg%40mail.gmail.com.