EGGer
07-17-2005, 06:30 AM
Thank you for paying attention to my first thread here !
i am learning maya_api for two weeks ...
and i determine to write my first simple plugin.. .
feature specifies : when i pick a curve and an object in sence...then run my command...
it will duplicate a few objects picked first ...
when i creat this *.mll... it showed successful
but it can't work as i want in maya .... when i run this command ... it just display "MGlobal:displayInfo " information ...
please help me ... i know that there are huge difficulty waiting for me when i research this
skills ... i really want to get your help ... appreciatie!
here is my doit code:
{
MStatus stat = MS::kSuccess;
MStatus valueCheck;
MGlobal::displayInfo("egger_DUP_curve tool 1.0 + ");
int nPoint=5;
MString name;
unsigned index;
MVector trans;
MStringArray ObjSelection;
index = args.flagIndex("n","number");
if (MArgList::kInvalidArgIndex !=index)
{
args.get( index+1,nPoint);
}
MSelectionList selection;
MGlobal::getActiveSelectionList( selection);
MDagPath dagPath;
MDagPath objDagPath;
MFnNurbsCurve curveFn;
MFnTransform transformFn;
MItSelectionList objIter(selection,MFn::kTransform);
//---------------------------------------------
for ( ; objIter.isDone();objIter.next())
{
objIter.getDagPath(objDagPath);
if (objDagPath.apiType() != MFn::kNurbsCurve)
{
transformFn.setObject(objDagPath);
}
}
name = transformFn.name(&valueCheck);
if (!valueCheck)
{
MGlobal::displayInfo("can't get value of name ");
}
trans = transformFn.translation(MSpace::kWorld);
MGlobal::displayInfo( transformFn.name());
//---------------------------------------
MItSelectionList iter( selection,MFn::kNurbsCurve);
for ( ; iter.isDone();iter.next())
{
iter.getDagPath( dagPath );
curveFn.setObject( dagPath );
double cStart, cEnd;
curveFn.getKnotDomain(cStart,cEnd);
MPoint pt;
int i;
double t;
double cIncr = (cEnd - cStart)/(nPoint - 1);
for (i=0,t=cStart; i<nPoint;i++,t+=cIncr)
{
curveFn.getPointAtParam( t, pt, MSpace::kWorld );
pt.y+= 0.5 * trans.y;
dgMod.commandToExecute(MString("select -r")+name+";");
dgMod.commandToExecute(MString("duplicate -rr -n ")+name+i+";");
dgMod.commandToExecute(MString("move -r ")+pt.x+" "+pt.y+" "+pt.z+";");
}
}
return redoIt();
}
i am learning maya_api for two weeks ...
and i determine to write my first simple plugin.. .
feature specifies : when i pick a curve and an object in sence...then run my command...
it will duplicate a few objects picked first ...
when i creat this *.mll... it showed successful
but it can't work as i want in maya .... when i run this command ... it just display "MGlobal:displayInfo " information ...
please help me ... i know that there are huge difficulty waiting for me when i research this
skills ... i really want to get your help ... appreciatie!
here is my doit code:
{
MStatus stat = MS::kSuccess;
MStatus valueCheck;
MGlobal::displayInfo("egger_DUP_curve tool 1.0 + ");
int nPoint=5;
MString name;
unsigned index;
MVector trans;
MStringArray ObjSelection;
index = args.flagIndex("n","number");
if (MArgList::kInvalidArgIndex !=index)
{
args.get( index+1,nPoint);
}
MSelectionList selection;
MGlobal::getActiveSelectionList( selection);
MDagPath dagPath;
MDagPath objDagPath;
MFnNurbsCurve curveFn;
MFnTransform transformFn;
MItSelectionList objIter(selection,MFn::kTransform);
//---------------------------------------------
for ( ; objIter.isDone();objIter.next())
{
objIter.getDagPath(objDagPath);
if (objDagPath.apiType() != MFn::kNurbsCurve)
{
transformFn.setObject(objDagPath);
}
}
name = transformFn.name(&valueCheck);
if (!valueCheck)
{
MGlobal::displayInfo("can't get value of name ");
}
trans = transformFn.translation(MSpace::kWorld);
MGlobal::displayInfo( transformFn.name());
//---------------------------------------
MItSelectionList iter( selection,MFn::kNurbsCurve);
for ( ; iter.isDone();iter.next())
{
iter.getDagPath( dagPath );
curveFn.setObject( dagPath );
double cStart, cEnd;
curveFn.getKnotDomain(cStart,cEnd);
MPoint pt;
int i;
double t;
double cIncr = (cEnd - cStart)/(nPoint - 1);
for (i=0,t=cStart; i<nPoint;i++,t+=cIncr)
{
curveFn.getPointAtParam( t, pt, MSpace::kWorld );
pt.y+= 0.5 * trans.y;
dgMod.commandToExecute(MString("select -r")+name+";");
dgMod.commandToExecute(MString("duplicate -rr -n ")+name+i+";");
dgMod.commandToExecute(MString("move -r ")+pt.x+" "+pt.y+" "+pt.z+";");
}
}
return redoIt();
}
