简体   繁体   中英

Differentiate current and new items in outliner

Is it possible to store the current Items in the Outliner as well as the new Items too?

def main():
    setupRenderGlobals()
    importItems()
    frameViewport()

    global app
    app=QtGui.qApp  

    global form
    form = MainWindow()
    form.show()

Eg. Current Items in Outliner (except the default items, eg. camera): ['pCube1', 'pCube2', 'pSphere1']

Then importing.adding in of new items: ['pCube1', 'pCube2', 'pSphere1', 'Man_Rig01', 'pShere2']

Could someone guide me how to write out a way that I can differentiate the new Items? Currently my import window (using of an in-house module which is the importItems() ) keeps popping up the prefix window (MainWindow()) when I hit close/ whether or not I import in any items. Thus I wanted to write it in a way where the prefix window will only pop up when new items are added.


Message to close voters: This question is not unclear to Maya users. There are answers waiting to be posted, but the question needs to be re-opened first.

Maya stores objects in a list. So every time you import stuff it goes to the end of said list so if you do,

coutBefore = len(cmds.ls())

before your import. You can then proceed with:

nodesImported = cmds.ls()[coutBefore:]

after import. It is possible to wrap this into import directly. But that's best done in MEL. Observe: I do not think this is a good approach. Since you dont get any namespace to protect any possible import issues from badly done scenes. So a alternate solution would be to import with namespace then strip the namespace if user asks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM