Results 1 to 3 of 3

Thread: [maya][python api 2.0]Deleting nodes

Hybrid View

  1. #1
    float Claudio A's Avatar
    Join Date
    Feb 2012
    Location
    Montreal
    Posts
    65

    Default [maya][python api 2.0]Deleting nodes



    I'm quite new to Maya and it api. I'm currently exploring api 2.0 and haven't figured out how to delete a node through the API. Assuming I have a MDagPath object in a list, how do I go about deleting it from the scene?

    I looked into MDagModifier, but passing the MDagPath to its deleteNode method raises:

    Code:
    # Error: TypeError: MObject expected #
    I never would have thought it would be this complicated to delete a scene node... do I need to disconnect any and all connections first? I thought this convenience method would take care of this...

    Do I need to cast it or get its MObject form?

    Any insight would be appreciated.

  2. #2
    float Claudio A's Avatar
    Join Date
    Feb 2012
    Location
    Montreal
    Posts
    65

    Default

    I needed the node property of the MDagPath.

  3. #3
    undefined
    Join Date
    Sep 2016
    Posts
    5

    Default MDGModifier is BAE

    Code:
    '''I wrote it quickly here so be carefull , but this how it goes for me '''
    
    #bruh : 
    import maya.OpenMaya as om
    sel=om.MSelectionList()
    dag=om.MDagPath()
    om.MGlobal.getActiveSelectionList(sel)
    sel.getDagPath(0,dag)
    dag.extendToShape()
    shapeNode=dag.node()#MObject here I think
    dn=om.MFnDependencyNode(shapeNode)
    inmeshplug=dn.findPlug('inMesh')#so yeah from there you can assume I'm going to disconnect things , and then delete the Node, because this is how it works.
    sourceplug=inmeshplug.source()
    node=sourceplug.node()
    dg=om.MDGModifier()
    dg.disconnect(sourceplug,inmeshplug)
    dg.doIt()
    dg.deleteNode(node)
    dg.doIt()
    
    #USE MDGModifier !!!
    # Someone got numpy and scipy running on Maya 2017 ? Please  I need it :'(

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •