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



On Thu, Oct 30, 2014 at 11:14 PM, Luke Harris <luk...@gmail.com> wrote:

I was doing this recently with pymel. Maya says that you can now remove ref
> edits while the reference is loaded, but I've noticed this isn't always the
> case, so I still unload it first for safety
>
> 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()
>
> But if you want to remove ALL edits it might be faster to do a clean(),
> which removes failed edits. If the ref is unloaded then all edits are
> failed :)
> for ref in pm.listReferences():
>     ref.unload()
>     ref.clean()
>     ref.load()
>
>
>
>
> On Thursday, October 30, 2014 11:51:12 AM UTC, Fredrik Averpil wrote:
>>
>> And if it makes it easier to somehow solve this ... I'm looking to remove
>> *all* reference edits.
>>
>>
>> ​
>>>
>>
>>  --
> 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_maya+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/2ee0b079-d794-4d84-956e-d465ae245e22%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
​

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPi2QNvFbVDzp-P2v0dim5F-Ewd7Yf0ZK9Y%2Bt5Z4J6P5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to