Drag-and-drop import Python script

This is a script I created after having a discussion with one of my students at The Game Assembly. We came to the conclusion that a simple drag-and-drop import in Maya is a simple and user friendly way to import objects and we wanted to add a custom attribute to newly import objects which would hold the file path of where the objects file is located.

The result of this discussions is dragImportCollada.py for Maya. It works by catching imports through a scriptJob which triggers on readingFile. Then the actual file path is fetched through the log file which is generated and updated by the fbxmaya.mll plugin which we use to import collada files.

Highlight Features

  • Triggers on importing collada files with the fbxmaya.mll plugin (the default Collada importer). Works with drag-and-drop importing files.
  • Adds a custom attribute to the newly imported file where the file path for the object is stored.
  • Has optional flags to format the file path to make it relative, to add a prefix and to add a suffix.
  • Also has an autoType flag which can be defined by the user to trigger on certain parts of file names and add custom formating of the file path attribute string accordingly. I.e. if a file contrains the term “enemy_” you could have this trigger the script to format the file path string in an appropriate manner for a “enemy” type object.

Download

Showcase Video

The asteroid model shown in the video are created by the student group “Seldom Seen Games” for their project “Astro Droids