i need your help!! it's about maya api..

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2005   #1
i need your help!! it's about maya api..

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();
}
 
Old 07 July 2005   #2
Well, you have not mentioned what's wrong or what are the messages you get, but...
at first glance, I can see a bunch of problems:

a)
 
if (objDagPath.apiType() != MFn::kNurbsCurve)
{
transformFn.setObject(objDagPath);
}


is useless, as you are already filtering using MFn::Transform in the iterator. Thus, all objects will be transforms (if there are any selected). If not, transformFn will remain unitialized and all operations on it will fail.

b) You are using transformFn.name() for selection later on. This will fail if you have several nodes with the same name. Use fullPathName() instead and enclose names in quotes.

c) You never call doit() on dgMod, so all mel commands remain unexecuted.

d) You are missing a space between select -r and name, leading to an invalid string.
dgMod.commandToExecute(MString("select -r")+name+";");


e) You are calling redoIt() at the end of the code for no reason. Part of the code you are showing should probably be part of the redoIt() method to support undo properly. Also, see Brian Ewert's web page about undo issues with MDgModifier.

f)
for (i=0,t=cStart; i<nPoint;i++,t+=cIncr)


You are incorrectly resetting i to 0 on each iteration. This will lead to objects with repeated names if multiple curves are selected.

g) Other general problems include the fact that you are not using stat (your error check variable) on any function, so if any function fails, you will not find out about it. Use a macro like MCHECK() in the maya demo examples.
__________________
Gonzalo Garramuño
 
Old 07 July 2005   #3
Smile thank you

gga:


wow! i don't know how to express my feeling when i looked around your reply ! i will check every sentence one by one as carefully as i can ... there are seven points showed by you ... yeah ! they are so valuable for me ...a fresh man in maya api! thank you for spending time on my questions ... i will take your suggestion with me ... and do my best ... please wait for my good news! thank you so much ! friend...
 
Old 07 July 2005   #4
For future reference there's a section especially for Mel and Maya API discussions in the Alias Maya forum
__________________
Carina

Contribute to the CGWiki!

Any views expressed are my personal opinions and do not represent those of my employer.
 
Old 07 July 2005   #5
Smile hi carina

Originally Posted by Carina: For future reference there's a section especially for Mel and Maya API discussions in the Alias Maya forum


Carina: That's very kind of you ! Thank you for your reply !
 
Old 08 August 2005   #6
my old lecture notes and a couple of source code samples can be found here http://robthebloke.org/mayaapi.html
 
Old 08 August 2005   #7
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:38 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.