import maya.cmds as cm
if cm.file(path, q=True, ex=True ) == True:
cm.file(path, i=True ) #i=import, r=reference
Have been doing some searching but not having much luck with the keywords I’ve been using. With the above snippet I’m able to import an object from a file such as .obj, it may consider several objects in the file. I’ve tried to assign the command to a variable but in my test I get a string like “mat_str_01”, there are two materials named “mat_str_02” in hypershade, 2 objects with material each. Imports of the same asset would be bad duplicating the materials, yet with references I’m getting errors when it tries to reference the same asset again? If I assign the command to a variable but instead of importing the object, reference it, I get the file path to the asset returned.
I’d like to be able to reference an external asset file, instance it and then reposition that asset instance(and all the objects that belong to that instance). I’m not sure how to select the imported/referenced instance as a whole, at first I thought it was assigned to the variable and tried to alter var.tx = value which of course returned ‘unicode’ object has no attribute ‘tx’.
Is there a good Maya/Python resource/site that anyone here recommends?
Cheers.