Python scripting question


#1

Hi, i am new at maya python scripting,

So, i am writing a little script for my experiences, the script is has two buttons;

Button 1 doing: deleteHistory, Freeze Transformation and resetPivot at the same time (I can write this)

BUT

Button 2 i want to do: Create a Control Curves (like " CreateNURBSCircle") avarage from selected object in python sciprt but i can’t do that :frowning:

This is my Script

import maya.cmds as cmds
import maya.mel as mel

def cleanObject(*args):
cmds.DeleteHistory()
cmds.CenterPivot()
cmds.FreezeTransformations()
print “Cleaned”

def crtCv(*args):
cmds.CreateNURBSCircle()
print “Control Was Created”

cmds.window(title=“Fatih’s ShortCuts”, w = 300, h = 500,)
cmds.columnLayout(adj=1)
cmds.button (label=“Clean Selected Object(s)”, )
cmds.button (label=“Make a Control”, command=crtCV)
cmds.showWindow()

When i call key-words from the google, i find this (the mel script)

string $currentTool = currentCtx;
setToolTo moveSuperContext;
vector $pos = manipMoveContext -q -p Move;
string $loc[] = spaceLocator -n "average#";
move -ws -a ($pos.x) ($pos.y) ($pos.z) $loc;
setToolTo $currentTool;

Please help me!

Thanx.


#2

Please use the ‘#’ sign in the message composer to enclose your code in code tags. Especially python code becomes unreadable if the indetation is missing. What do you exactly mean by “avarage from selected object”? Do you want to draw your own curve or do you want to create a nurbs circle as you already do it and only place it at the correct position?