Select objects after import

312 views
Skip to first unread message

DGFA DAG's GRAPHIC & FOTO ART

unread,
Jul 31, 2022, 6:14:48 AM7/31/22
to Python Programming for Autodesk Maya
Hi,

how can I select imported objects and just this that are imported? 
Whan would import objects such as obj, fbx abc and so on I have the solution, but when importing a maya scene containing some or just one object I do not have any clue how to master it.

Do anybody have an advice for me?

Thanks 
D.

Marcus Ottosson

unread,
Jul 31, 2022, 7:03:45 AM7/31/22
to python_in...@googlegroups.com

Unsure whether this’ll work with all file formats, but for native Maya files there’s the returnNewNodes argument for cmds.file(), you can pass that to cmds.select().


--
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/f04f5e39-35e7-47de-aab5-60ab9bc2b14bn%40googlegroups.com.

Juan Moraga

unread,
Jul 31, 2022, 7:10:03 AM7/31/22
to python_in...@googlegroups.com
I'd go with Marcus' solution too as it seems a  very clean solution; you can also try to import the files under a namespace and then query the objects in that namespace, atho this one is not as neat!

vince touache

unread,
Jul 31, 2022, 8:32:10 AM7/31/22
to Python Programming for Autodesk Maya
I think what the author is looking for is a way to pick the objets to import prior to actually importing everything in the scene.
Marcus's option is valid (or any similar option, using namespaces, comparing two sets of ls -sl, etc...), but it forces to "do/undo", as in import then delete, which can possibly be heavy for huge scenes.

I may be wrong, but this is how I understood the request

Marcus Ottosson

unread,
Jul 31, 2022, 8:50:56 AM7/31/22
to python_in...@googlegroups.com
Ahaa, yes that is a possible interpretation of the question.

In that case, you can't. :) This is USD/Alembic/Katana behaviour that Maya has not implemented.

One way you can work around it, if you know ahead of time this is what you want, is that you can:

1. Start a new scene
2. Create 1 reference for every object you would like to control the import of, such as 10 barrels and 5 cats.
3. Unload all references
4. Save this scene

This is now your "asset", something you can selectively import things from.

Next, when you import or reference this file, your Reference Editor can now be used to selectively import (well, reference) things from this file.

That process could potentially be automated and wrapped into a nice UI, similar to how more fancy tools let you selectively import things. But, it is very limited to the things you explicitly do this for.. There's an option to create a reference without loading any sub-references, which can make it more able.

image.png

But I think that's it?

Hope it helps!

DGFA DAG's GRAPHIC & FOTO ART

unread,
Jul 31, 2022, 9:38:27 AM7/31/22
to Python Programming for Autodesk Maya

Thank you very much!

DGFA DAG's GRAPHIC & FOTO ART

unread,
Jul 31, 2022, 10:48:25 AM7/31/22
to Python Programming for Autodesk Maya
Hi Marcus,

one question how to pass the argumented list from returnNewNodes to select() without store it in a variable between?

Thanks!!!!
Marcus Ottosson schrieb am Sonntag, 31. Juli 2022 um 13:03:45 UTC+2:
Reply all
Reply to author
Forward
0 new messages