Thanks alot Marcus On Wednesday, June 8, 2022 at 6:37:53 PM UTC+2 Marcus Ottosson wrote:
> Almost got it! > > rig = rig_mod.rig > > That’s because the module was already imported in the line above, but > cannot use the from ... syntax since that would try and import it again. > Your rig_mod is a perfectly fine imported module. > > On Wed, 8 Jun 2022 at 17:28, Anas Elkinawy <[email protected]> wrote: > >> Is there any way to convert string to module name in order to import it >> >> ex: >> >> characterName = mc.textField(character_name, q=1, text=True) >> char_project_folder = mc.textField(project_folder, q=1, text=True) >> rig_python_path = >> r"{0}\{1}\scripts\python\{2}Rig".format(char_project_folder, characterName, >> characterName) >> >> rig_mod = importlib.import_module("{0}Rig".format(characterName)) >> >> from rig_mod import rig >> >> Error: ImportError: file No module named rig_mod # >> >> as you can see it doesn't recognize the module as it deals with it as a >> string >> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/5fbb91c7-1c54-458b-8115-f932a6397404n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/5fbb91c7-1c54-458b-8115-f932a6397404n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1e2154fa-a13c-4820-95c6-2ab9c3f216e4n%40googlegroups.com.
