View Single Post
# 4 26-05-2006 , 02:37 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
hey skywola, I have a question about MEL.

I have a final part of a script:

Code:
string $shp[] =`ls -tr`;
for ($obj in $shp) {
	$shape = `listRelatives -shapes $obj`;
	if (`objectType $shape` == "mesh") {
		float $pos[] = `getAttr ($obj +".translate")`;
		$write += "\n\n<model>\n\t<pos>" + $pos[0] + " " + $pos[1] + " " + $pos[2] + "</pos>";
		$write += "\n\t<scale>1</scale>";
		$write += "\n\t<rotation><matrix>1 0 0 0 1 0 0 0 1</matrix></rotation>";
		$write += "\n\t<mesh_name>"+ $shape[0] +"</mesh_name>\n</model>";
	}
}
This part gives me problems:

I get this error:

// Error: No object name specified. //

EDIT- if I do this:

Code:
string $trans[] =`ls -tr`;
for ($one in $trans) {
			string $shape[] = `listRelatives -shapes $one`;
			if (`objectType $one` == "mesh"){
			float $pos[] = `getAttr ($one +".translate")`;
		$write += "\n\n<model>\n\t<pos>" + $pos[0] + " " + $pos[1] + " " + $pos[2] + "</pos>";
		$write += "\n\t<scale>1</scale>";
		$write += "\n\t<rotation><matrix>1 0 0 0 1 0 0 0 1</matrix></rotation>";
		$write += "\n\t<mesh_name>"+$shape[0] +"</mesh_name>\n</model>";
	}
}
$write += "\n</scene>";
print($write);
It works, just nothing comes up since $obj is not a mesh. Instead, if I leave out that condition, all of my cameras apepear! I could just do a conditional

Code:
if (`objectType $one`!="camera")
But then NURBS objects would be dragged in, and so would SUB-D's, animation objects... etc.

Any way to get just the actual polygonal mesh in there?

I have a part in a previous section of the code that does this:
Code:
string $shapes[] = `ls -s`;
for ($one in $shapes){
	if(`objectType $one` == "mesh"){
	int $nV[] = `polyEvaluate -v $one`;
	int $nF[] = `polyEvaluate -f $one`;
	int $x = 0;
	$write += "\n<mesh>\n";
	$write += "\t<name>"+$one+"</name>\n";
	$write += "\t<embedded>\n";
	for($x=0;$x < $nV[0];$x++){
		string $cv = $one+".vtx["+$x+"]";
etc.... more code down here
But, if I use the 'ls -s' tab in the problematic part, it brings up the actual shape of the object (eg PolyPlane1Shape) and therefore I cannot access the translate, scale... etc.
Any suggestions as to how I might fix it?

Also- if I do use the 'ls -s' tag, (I don't need the pos anyway, I already have the triangle position), then the listRelatives turns up an empty string.


Live the life you love, love the life you live

Last edited by MattTheMan; 26-05-2006 at 02:57 PM.