PDA

View Full Version : i need your HELP: maya_api


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();
}

zhang
07-17-2005, 09:56 AM
When selecting an object in Maya's openGL viewport, typically you will get the transform node. If you set the type filter to kNurbsCurve and only transform nodes are in the list, the Iter will be empty. No loops will be performed. So select shape node instead.

And I feel your code to be too complex for such a task. You can ignore type filter when creating iter. And use MDagPath.extendToShape() to add the shape node.

If hasFn kNurbsCurve && !hasFn kTransform, do your operations.

Hope make sense.

EGGer
07-17-2005, 12:42 PM
When selecting an object in Maya's openGL viewport, typically you will get the transform node. If you set the type filter to kNurbsCurve and only transform nodes are in the list, the Iter will be empty. No loops will be performed. So select shape node instead.

And I feel your code to be too complex for such a task. You can ignore type filter when creating iter. And use MDagPath.extendToShape() to add the shape node.

If hasFn kNurbsCurve && !hasFn kTransform, do your operations.

Hope make sense.

thank you so much zhang jian... i will hold your information ...and think around .... you know .. i have less tutorial about maya api ! ... i am in a cg company of shen zhen ! to be devout appreciation for your aid...

zhang
07-17-2005, 04:19 PM
Where are some notes and source code on my homepage. A good start point for a beginner, i think.

EGGer
07-18-2005, 11:04 AM
Where are some notes and source code on my homepage. A good start point for a beginner, i think.


yeah ... I visited your website yesterday .... There are so valuable for me ... Some articles are difficult for me to comprehend ... I will pick up simple one first....I think that it must cost you a lot of time to pack up your expression ... I hope that people to be learning maya api could get valuable experience in your website . I have to research your articles in your web one by one ... Thank you zhang jian! You are a good man ! Good luck

CGTalk Moderation
07-18-2005, 11:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.