dave
dave

Reputation: 93

Maya Python Using "cmds.file" to export

I am still a newbie when it comes to python in general so bear with me.

I am trying to make a little export script for maya and cant seem to set the options flag for the "file" command.

I want to specify the options for the "file" command with radio buttons.

I have a radio control like this:

Material = ""

MaterialRadio = cmds.radioButton("Material")

def MaterialFunc ():
   MaterialCheck = cmds.radioButton(MaterialRadio, q=True, sl=True)
   return MaterialCheck

if MaterialCheck == True:
    Material = "1"   
                
if MaterialCheck == False:
    Material  = "0"   

The options Flag for the file command takes only strings, so something like this doenst seem to work:

To test, i force Material = "0"

Material = "0"
cmds.file (exportPath, type=OBJexport, op=Material )

Using strings, op="material=0") also doenst seem to work though.

Also keep in mind, i want to set multiple flags with radio controls. So it should look something like this in the end:

cmds.file (exportPath, type=OBJexport, op=[material, groups, ptgroups, smoothing, normals] )

Any ideas anyone ?

Upvotes: 0

Views: 2730

Answers (1)

haggi krey
haggi krey

Reputation: 1978

Options can be easily set by following this pattern:

import maya.cmds as cmds
doMaterial = 0
doNormals = 1
options = "groups=0;ptgroups=0;materials={0};smoothing=1;normals={1}".format(doMaterial, doNormals)
cmds.file("somepath/tst.obj", force=True, op=options, typ="OBJexport", pr=True, es=True)

Upvotes: 1

Related Questions