Home Website Youtube GitHub

Pre custom step geo failing

Hello!
Banging my head against the computer…
I am trying to get the pre script for loading my Geometry working.
I have been looking for any typos but can’t find any.
I set my maya.env path with the following:
MGEAR_SHIFTER_CUSTOMSTEP_PATH = /Users/todd/Rod Dropbox/thor can/maya/projects/grays/custom_steps

The path to my scripts and Geo are:
/Users/todd/Rod Dropbox/thor can/maya/projects/grays/custom_steps/scripts/pre/import_geo.py

/Users/todd/Rod Dropbox/thor can/maya/projects/grays/custom_steps/assets/geo.ma

I add the import_geo.py file to the guide settings and get the following faliure on build:

GEAR version : 4.0.7

= SHIFTER RIG SYSTEM ==============================================

= PRE CUSTOM STEPS ==============================================
// EXEC: Executing custom step: scripts/pre/import_geo.py //
// Error: An exception of type RuntimeError occurred. //
// Error: Traceback (most recent call last):
File “/Users/todd/Library/Preferences/Autodesk/maya/modules/scripts/mgear/shifter/guide.py”, line 1345, in runStep
cs.run(customStepDic)
File “/Users/todd/CalRod Dropbox/todd calvert/maya/projects/grays/custom_steps/scripts/pre/import_geo.py”, line 25, in run
self.import_geometry()
File “/Users/todd/CalRod Dropbox/todd calvert/maya/projects/grays/custom_steps/scripts/pre/import_geo.py”, line 37, in import_geometry
pm.importFile(os.path.join(path, “assets”, “geo.ma”))
File “/Applications/Autodesk/maya2020/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/core/system.py”, line 2058, in importFile
res = cmds.file(filepath, **kwargs)
File “/Applications/Autodesk/maya2020/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/internal/pmcmds.py”, line 130, in file_wrapped
res = new_cmd(*new_args, **new_kwargs)
RuntimeError: File not found.

//

The code for the import_geo.py is unchanged to from the Github file.

‘’’
import os
import mgear.shifter.custom_step as cstp
import pymel.core as pm

class CustomShifterStep(cstp.customShifterMainStep):
def init(self):
self.name = “import_geo”

def run(self, stepDict):
    """Run method.

        i.e:  stepDict["mgearRun"].global_ctl  gets the global_ctl from
                shifter rig on post step
        i.e:  stepDict["otherCustomStepName"].ctlMesh  gets the ctlMesh
                from a previous custom step called "otherCustomStepName"
    Arguments:
        stepDict (dict): Dictionary containing the objects from
            the previous steps

    Returns:
        None: None
    """
    self.import_geometry()

    try:
        pm.select("guide")
    except:
        pass


def import_geometry(self):
    path =  "\\".join(os.path.abspath(
        os.path.dirname(__file__)).split("\\")[:-2])

    pm.importFile(os.path.join(path, "assets", "geo.ma"))

‘’’

the error is RuntimeError: File not found. print the path to check if the path resolved is correct.
print(os.path.join(path, "assets", "geo.ma"))

It might be because of the spaces in the path. (I don’t know if that is supported or not. But worth checking.)

Thanks a ton for the help!

I simplified my path to my User folder. This removed the spaces.
I updated the maya.env and get this when I check it:

getenv "MGEAR_SHIFTER_CUSTOMSTEP_PATH"; // Result: /Users/todd/custom_steps; //

I run
print(os.path.join(path, "assets", "geo.ma"))
which returned:
# Error: NameError: file <maya console> line 1: name 'path' is not defined #

building the rig gives me this now:

= SHIFTER RIG SYSTEM ==============================================

= PRE CUSTOM STEPS ==============================================
// EXEC: Executing custom step: Users/todd/custom_steps/scripts/pre/import_geo.py // 
// Error: An exception of type IOError occurred.  // 
// Error: Traceback (most recent call last):
  File "/Users/todd/Library/Preferences/Autodesk/maya/modules/scripts/mgear/shifter/guide.py", line 1335, in runStep
    customStep = imp.load_source(fileName, runPath)
IOError: [Errno 2] No such file or directory
 // 
# Traceback (most recent call last):
#   File "/Users/todd/Library/Preferences/Autodesk/maya/modules/scripts/mgear/shifter/guide_manager.py", line 64, in build_from_selection
#     rg.buildFromSelection()
#   File "/Users/todd/Library/Preferences/Autodesk/maya/modules/scripts/mgear/shifter/__init__.py", line 233, in buildFromSelection
#     return build_data
# UnboundLocalError: local variable 'build_data' referenced before assignment

`

Well, that “path is undefined” is because you’ll still have to run the first line to declare what path is:

path = "\\".join(os.path.abspath( os.path.dirname(__file__)).split("\\")[:-2])

But you have to run that in your build script. If you just try to run it in Maya script editor, it won’t know what __file__ is.


Try putting that print line in your build script, before the importFile, then you’ll see it in your build log, just before the error:

def import_geometry(self):
    path =  "\\".join(os.path.abspath(
        os.path.dirname(__file__)).split("\\")[:-2])

    print(os.path.join(path, "assets", "geo.ma"))
    pm.importFile(os.path.join(path, "assets", "geo.ma"))

The “build_data” error might be happening because of other errors. So I’d ignore that for now, unless it doesn’t go away once you fix the path problem.

1 Like

Thanks!
Added the print line to the build script and it prints “assets/geo.ma”
Does this mean that the error is not the path problem but something else?

= PRE CUSTOM STEPS ==============================================
// EXEC: Executing custom step: scripts/pre/import_geo.py // 
assets/geo.ma
// Error: An exception of type RuntimeError occurred.  // 
// Error: Traceback (most recent call last):
  File "/Users/todd/Library/Preferences/Autodesk/maya/modules/scripts/mgear/shifter/guide.py", line 1345, in runStep
    cs.run(customStepDic)
  File "/Users/todd/custom_steps/scripts/pre/import_geo.py", line 23, in run
    self.import_geometry()
  File "/Users/todd/custom_steps/scripts/pre/import_geo.py", line 36, in import_geometry
    pm.importFile(os.path.join(path, "assets", "geo.ma"))
  File "/Applications/Autodesk/maya2020/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/core/system.py", line 2058, in importFile
    res = cmds.file(filepath, **kwargs)
  File "/Applications/Autodesk/maya2020/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/internal/pmcmds.py", line 130, in file_wrapped
    res = new_cmd(*new_args, **new_kwargs)
RuntimeError: File not found.

 //

I got the path working! THANKS.
I was also having a problem with the fact that I was running an educational version and it was getting stuck on import when maya asked to ok the educational terms.
Again, THANKS!!

2 Likes