Hi!

It should be:

dgModifier.removeAttribute(setObj, depFn.findPlug('Start').attribute())

Because
MObject<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_object.html>
  
node<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_plug.html#ad1aa507eb8e63e89e8d46a0abc18aa8c>(
MStatus<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_status.html>*ReturnStatus=NULL)
const
  Returns the dependency node that this plug belongs to.
You need MObject associated with attribute
MObject<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_object.html>
  
attribute<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_plug.html#a18baf7e7504bc90d54dea49a7d2d924b>(
MStatus<http://download.autodesk.com/global/docs/mayasdk2012/en_us/cpp_ref/class_m_status.html>*ReturnStatus=NULL)
const
  This method returns the attribute that this plug refers to.
Should works

Best regards!
Kamil



2013/2/20 Dimitry Kachkovski <[email protected]>

> Hey guys,
>
> Perhaps someone might be able to help me out: I have a piece of code that
> creates a bunch of attributes, and afterwards I want to remove them, all
> using the api. Here is the test code I wrote to do the same on a small set
> (this is in Maya 2012):
>
> import maya.OpenMaya as om
> import maya.OpenMayaAnim as oma
>
> depFn = om.MFnDependencyNode()
> setObj = depFn.create("objectSet", "SaveLoadAnim")
> uAttr = om.MFnUnitAttribute()
>
> startAttr = uAttr.create("Start", "s", om.MFnUnitAttribute.kTime)
> uAttr.setStorable(True)
> uAttr.setKeyable(False)
>
> endAttr = uAttr.create("End", "e", om.MFnUnitAttribute.kTime)
> uAttr.setStorable(True)
> uAttr.setKeyable(False)
>
> dgModifier = om.MDGModifier()
>
> dgModifier.addAttribute(setObj, startAttr)
> dgModifier.addAttribute(setObj, endAttr)
>
> dgModifier.doIt()
>
> startPlug = depFn.findPlug(startAttr)
> endPlug = depFn.findPlug(endAttr)
>
> startPlug.setMTime(oma.MAnimControl.minTime())
> endPlug.setMTime(oma.MAnimControl.maxTime())
>
> dgModifier.removeAttribute(setObj, depFn.findPlug('Start').node())
>
> As I run this in Maya, I get a crash, with a rather unhelpful crash
> stack...
>
> Any ideas?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to