PDA

View Full Version : plugin will not run?


fbitonti
11-21-2006, 05:54 AM
I have been working on this plugin using the api it hasn't given me trouble in the past but I recently added a frew for loops towards the end. I don't get any errors when I complie the code but when I run the plugin from maya I don't get any of the output i specified and i don't know if the command is even running. I'm new to this api stuff so I thougt maybe some one could take a look and see if they know why it's acting like this. Thank you in a advance for any informaion you can give me.

//
// This will be the function that calculates the stiffness matrix.
//

#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MItSelectionList.h>
#include <maya/MItMeshEdge.h>
#include <maya/MDagPath.h>
#include <stdio.h>
#include <math.h>

DeclareSimpleCommand( stiffnessMatrix, "Francis Bitonti", "1.0" );

MStatus stiffnessMatrix::doIt( const MArgList& args )
{
MStatus stat = MS::kSuccess;

MSelectionList selection;
MGlobal::getActiveSelectionList( selection );

MDagPath dagPath;
MObject component;

//E modulus of elasticity
int e = 200000;

//A area of section
float a = 4000;


float edgeCount, v0Index, v1Index, edgeIndex;
MPoint v0, v1;

//edgeNodes[edgenumber] followed by [vertexIndes0][vertexIndex1]
//for zero and one is second value
//you will use these values for the assembly process.

float edgeNodes[10000][2];
float freedomDeg[10000][2][2];

float vertexPos[10000][2][3];

float length[10000];
float ls[10000];
float ms[10000];

float stiffMatrix[10000][4][4];
float globalMatrix[10000][10000];

int count;
count = 0;

MString txt;
MItSelectionList iter( selection );
for ( ; !iter.isDone(); iter.next() )
{
iter.getDagPath( dagPath, component );

MItMeshEdge edgeIter( dagPath, component, &stat );
if( stat == MS::kSuccess )
{
txt += dagPath.fullPathName() + "\n";

edgeCount = edgeIter.count();
txt += MString("# Edges: ") + edgeCount + "\n";

//sort vertext positions
for( ; !edgeIter.isDone(); edgeIter.next() )
{
edgeIndex = edgeIter.index();

v0Index = edgeIter.index(0);
v1Index = edgeIter.index(1);

v0 = edgeIter.point( 0, MSpace::kWorld );
v1 = edgeIter.point( 1, MSpace::kWorld );

//store edges and the nodes they are connected to
edgeNodes[count][0] = v0Index;
edgeNodes[count][1] = v1Index;
//establish degress of freedom for each memeber
freedomDeg[count][0][0] = 2*(edgeNodes[count][0])-1;
freedomDeg[count][0][1] = 2*(edgeNodes[count][0]);
freedomDeg[count][1][0] = 2*(edgeNodes[count][1])-1;
freedomDeg[count][1][1] = 2*(edgeNodes[count][1]);

vertexPos[count][0][1] = (v0.x)*(1000);
vertexPos[count][0][2] = (v0.y)*(1000);
vertexPos[count][0][3] = (v0.z)*(1000);

vertexPos[count][1][1] = (v1.x)*(1000);
vertexPos[count][1][2] = (v1.y)*(1000);
vertexPos[count][1][3] = (v1.z)*(1000);

txt = txt + "Edge " + edgeIndex + ": " +
v0Index + " (" + v0.x + ", " + v0.y + ", " + v0.z + ") " +
v1Index + " (" + v1.x + ", " + v1.y + ", " + v1.z + ")\n\n";

txt = txt + "count =" + count + "\n\n";

txt = txt + "Edge zero " + edgeIndex + "\n " +
"vertex1: x, " + vertexPos[count][0][1] + "y, " + vertexPos[count][0][2] + "z, " + vertexPos[count][0][3] + ") " +
"vertex2: x, " + vertexPos[count][1][1] + "y, " + vertexPos[count][1][2] + "z, " + vertexPos[count][1][3] + ")\n\n";

length[count] = sqrt(pow(vertexPos[count][0][3] - vertexPos[count][1][3],2)+pow(vertexPos[count][0][1] - vertexPos[count][1][1],2));
ls[count] = (vertexPos[count][0][3] - vertexPos[count][1][3])/length[count];
ms[count] = (vertexPos[count][0][1] - vertexPos[count][1][1])/length[count];

count = count+1;
}

}
}

//set global matrix to zero
int z;
int q;
for(z=0; z < count; z++){
for(q=0; q < count; q++){
//calculate row one
globalMatrix[z][q]= 0;
}
}

int i;
for(i=0; i < count + 1; i++){

//calculate stiffness matrix for each element and store in three dimensional array.
//int node1 = edgeNodes[i][0];
int freeVector1 = freedomDeg[i][0][0];
int freeVector2 = freedomDeg[i][0][1];
int freeVector3 = freedomDeg[i][1][0];
int freeVector4 = freedomDeg[i][1][1];

//calculate row one u1
stiffMatrix[i][0][0] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][1][0] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][2][0] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][3][0] = ((e*a)/length[i])*(-ls[i]*ms[i]);
//gloabl matrix for u1
globalMatrix[freeVector1][freeVector1] = stiffMatrix[i][0][0] + globalMatrix[freeVector1][freeVector1];
globalMatrix[freeVector1][freeVector2] = stiffMatrix[i][1][0] + globalMatrix[freeVector1][freeVector2];
globalMatrix[freeVector1][freeVector3] = stiffMatrix[i][2][0] + globalMatrix[freeVector1][freeVector3];
globalMatrix[freeVector1][freeVector4] = stiffMatrix[i][3][0] + globalMatrix[freeVector1][freeVector4];
//calculate row two v1
stiffMatrix[i][0][1] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][1][1] = ((e*a)/length[i])*(pow(ms[i],2));
stiffMatrix[i][2][1] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][3][1] = ((e*a)/length[i])*(-pow(ms[i],2));
//gloabl matrix for v1
globalMatrix[freeVector2][freeVector1] = stiffMatrix[i][0][1] + globalMatrix[freeVector2][freeVector1];
globalMatrix[freeVector2][freeVector2] = stiffMatrix[i][1][1] + globalMatrix[freeVector2][freeVector2];
globalMatrix[freeVector2][freeVector3] = stiffMatrix[i][2][1] + globalMatrix[freeVector2][freeVector3];
globalMatrix[freeVector2][freeVector4] = stiffMatrix[i][3][1] + globalMatrix[freeVector2][freeVector4];
//calculate row three u2
stiffMatrix[i][0][2] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][1][2] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][2][2] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][3][2] = ((e*a)/length[i])*(ls[i]*ms[i]);
//gloabl matrix for u2
globalMatrix[freeVector3][freeVector1] = stiffMatrix[i][0][2] + globalMatrix[freeVector3][freeVector1];
globalMatrix[freeVector3][freeVector2] = stiffMatrix[i][1][2] + globalMatrix[freeVector3][freeVector2];
globalMatrix[freeVector3][freeVector3] = stiffMatrix[i][2][2] + globalMatrix[freeVector3][freeVector3];
globalMatrix[freeVector3][freeVector4] = stiffMatrix[i][3][2] + globalMatrix[freeVector3][freeVector4];
//calculate row four v2
stiffMatrix[i][0][3] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][1][3] = ((e*a)/length[i])*(-pow(ms[i],2));
stiffMatrix[i][2][3] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][3][3] = ((e*a)/length[i])*(pow(ms[i],2));
//gloabl matrix for v2
globalMatrix[freeVector4][freeVector1] = stiffMatrix[i][0][3] + globalMatrix[freeVector4][freeVector1];
globalMatrix[freeVector4][freeVector2] = stiffMatrix[i][1][3] + globalMatrix[freeVector4][freeVector2];
globalMatrix[freeVector4][freeVector3] = stiffMatrix[i][2][3] + globalMatrix[freeVector4][freeVector3];
globalMatrix[freeVector4][freeVector4] = stiffMatrix[i][3][3] + globalMatrix[freeVector4][freeVector4];

}

//print global matrix
int g;
int h;
for(g=0; g < count; g++){
for(h=0; h < count; h++){

txt = txt + globalMatrix[g][h] + "\n";
}
}

//print local matrix

int w;
for(w=0; w < count; w++){
//this text is for testing against the book example.
txt = txt + " x2 " + vertexPos[w][0][3] + " x1 " + vertexPos[w][1][3] + " y2 " + vertexPos[w][0][1] + " y1 " + vertexPos[w][1][1] + "\n\n";
txt = txt + "length of member zero is" + length[w] + "\n\n";
txt = txt + "ls of member zero is" + ls[w] + "\n\n";
txt = txt + "ms of member zero is" + ms[w] + "\n\n";


txt = txt + "stiffness matrix for element three" + "\n";
txt = txt + stiffMatrix[w][0][0] + "\n";
txt = txt + stiffMatrix[w][1][0] + "\n";
txt = txt + stiffMatrix[w][2][0] + "\n";
txt = txt + stiffMatrix[w][3][0] + "\n";
txt = txt + stiffMatrix[w][0][1] + "\n";
txt = txt + stiffMatrix[w][1][1] + "\n";
txt = txt + stiffMatrix[w][2][1] + "\n";
txt = txt + stiffMatrix[w][3][1] + "\n";
txt = txt + stiffMatrix[w][0][2] + "\n";
txt = txt + stiffMatrix[w][1][2] + "\n";
txt = txt + stiffMatrix[w][2][2] + "\n";
txt = txt + stiffMatrix[w][3][2] + "\n";
txt = txt + stiffMatrix[w][0][3] + "\n";
txt = txt + stiffMatrix[w][1][3] + "\n";
txt = txt + stiffMatrix[w][2][3] + "\n";
txt = txt + stiffMatrix[w][3][3] + "\n";
}


MGlobal::displayInfo( txt );

return MS::kSuccess;
}


This is the one that works

//
// This will be the function that calculates the stiffness matrix.
//

#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MItSelectionList.h>
#include <maya/MItMeshEdge.h>
#include <maya/MDagPath.h>
#include <stdio.h>
#include <math.h>

DeclareSimpleCommand( stiffnessMatrix, "Francis Bitonti", "1.0" );

MStatus stiffnessMatrix::doIt( const MArgList& args )
{
MStatus stat = MS::kSuccess;

MSelectionList selection;
MGlobal::getActiveSelectionList( selection );

MDagPath dagPath;
MObject component;

//E modulus of elasticity
int e = 200000;

//A area of section
float a = 4000;


float edgeCount, v0Index, v1Index, edgeIndex;
MPoint v0, v1;

//edgeNodes[edgenumber] followed by [vertexIndes0][vertexIndex1]
//for zero and one is second value
//you will use these values for the assembly process.
float edgeNodes[10000][2];

float vertexPos[10000][2][3];

float length[10000];
float ls[10000];
float ms[10000];

float stiffMatrix[10000][4][4];

int count;
count = 0;

MString txt;
MItSelectionList iter( selection );
for ( ; !iter.isDone(); iter.next() )
{
iter.getDagPath( dagPath, component );

MItMeshEdge edgeIter( dagPath, component, &stat );
if( stat == MS::kSuccess )
{
txt += dagPath.fullPathName() + "\n";

edgeCount = edgeIter.count();
txt += MString("# Edges: ") + edgeCount + "\n";

//sort vertext positions
for( ; !edgeIter.isDone(); edgeIter.next() )
{
edgeIndex = edgeIter.index();

v0Index = edgeIter.index(0);
v1Index = edgeIter.index(1);

v0 = edgeIter.point( 0, MSpace::kWorld );
v1 = edgeIter.point( 1, MSpace::kWorld );

//store edges and the nodes they are connected to
edgeNodes[count][0] = v0Index;
edgeNodes[count][1] = v1Index;

vertexPos[count][0][1] = (v0.x)*(1000);
vertexPos[count][0][2] = (v0.y)*(1000);
vertexPos[count][0][3] = (v0.z)*(1000);

vertexPos[count][1][1] = (v1.x)*(1000);
vertexPos[count][1][2] = (v1.y)*(1000);
vertexPos[count][1][3] = (v1.z)*(1000);

txt = txt + "Edge " + edgeIndex + ": " +
v0Index + " (" + v0.x + ", " + v0.y + ", " + v0.z + ") " +
v1Index + " (" + v1.x + ", " + v1.y + ", " + v1.z + ")\n\n";

txt = txt + "count =" + count + "\n\n";

txt = txt + "Edge zero " + edgeIndex + "\n " +
"vertex1: x, " + vertexPos[count][0][1] + "y, " + vertexPos[count][0][2] + "z, " + vertexPos[count][0][3] + ") " +
"vertex2: x, " + vertexPos[count][1][1] + "y, " + vertexPos[count][1][2] + "z, " + vertexPos[count][1][3] + ")\n\n";

length[count] = sqrt(pow(vertexPos[count][0][3] - vertexPos[count][1][3],2)+pow(vertexPos[count][0][1] - vertexPos[count][1][1],2));
ls[count] = (vertexPos[count][0][3] - vertexPos[count][1][3])/length[count];
ms[count] = (vertexPos[count][0][1] - vertexPos[count][1][1])/length[count];

count = count+1;
}

}
}

//this text is for testing against the book example.
txt = txt + " x2 " + vertexPos[3][0][3] + " x1 " + vertexPos[3][1][3] + " y2 " + vertexPos[3][0][1] + " y1 " + vertexPos[3][1][1] + "\n\n";
txt = txt + "length of member zero is" + length[3] + "\n\n";
txt = txt + "ls of member zero is" + ls[3] + "\n\n";
txt = txt + "ms of member zero is" + ms[3] + "\n\n";

//calculate stiffness matrix for each element and store in three dimensional array.
int i;
for(i=0; i < count; i++){
//calculate row one u1
stiffMatrix[i][0][0] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][1][0] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][2][0] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][3][0] = ((e*a)/length[i])*(-ls[i]*ms[i]);
//calculate row two v1
stiffMatrix[i][0][1] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][1][1] = ((e*a)/length[i])*(pow(ms[i],2));
stiffMatrix[i][2][1] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][3][1] = ((e*a)/length[i])*(-pow(ms[i],2));
//calculate row three u2
stiffMatrix[i][0][2] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][1][2] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][2][2] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][3][2] = ((e*a)/length[i])*(ls[i]*ms[i]);
//calculate row four v2
stiffMatrix[i][0][3] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][1][3] = ((e*a)/length[i])*(-pow(ms[i],2));
stiffMatrix[i][2][3] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][3][3] = ((e*a)/length[i])*(pow(ms[i],2));
}

//this text is for testing against the book example.
txt = txt + "stiffness matrix for element three" + "\n";
txt = txt + stiffMatrix[3][0][0] + "\n";
txt = txt + stiffMatrix[3][1][0] + "\n";
txt = txt + stiffMatrix[3][2][0] + "\n";
txt = txt + stiffMatrix[3][3][0] + "\n";
txt = txt + stiffMatrix[3][0][1] + "\n";
txt = txt + stiffMatrix[3][1][1] + "\n";
txt = txt + stiffMatrix[3][2][1] + "\n";
txt = txt + stiffMatrix[3][3][1] + "\n";
txt = txt + stiffMatrix[3][0][2] + "\n";
txt = txt + stiffMatrix[3][1][2] + "\n";
txt = txt + stiffMatrix[3][2][2] + "\n";
txt = txt + stiffMatrix[3][3][2] + "\n";
txt = txt + stiffMatrix[3][0][3] + "\n";
txt = txt + stiffMatrix[3][1][3] + "\n";
txt = txt + stiffMatrix[3][2][3] + "\n";
txt = txt + stiffMatrix[3][3][3] + "\n";

MGlobal::displayInfo( txt );

return MS::kSuccess;
}

fbitonti
11-21-2006, 09:12 PM
ok I found the problem the problem seems to start on this line

globalMatrix[freeVector1][freeVector1] = stiffMatrix[i][0][0] + globalMatrix[freeVector1][freeVector1];

I don't understand why this would cause a problem. If anyone has any insite please let me know.



//
// This will be the function that calculates the stiffness matrix.
//

#include <maya/MSimple.h>
#include <maya/MGlobal.h>
#include <maya/MItSelectionList.h>
#include <maya/MItMeshEdge.h>
#include <maya/MDagPath.h>
#include <stdio.h>
#include <math.h>

DeclareSimpleCommand( mayaFem, "Francis Bitonti", "1.0" );

MStatus mayaFem::doIt( const MArgList& args )
{
MStatus stat = MS::kSuccess;

MSelectionList selection;
MGlobal::getActiveSelectionList( selection );

MDagPath dagPath;
MObject component;

//E modulus of elasticity
int e = 200000;

//A area of section
float a = 4000;


float edgeCount, v0Index, v1Index, edgeIndex;
MPoint v0, v1;

//edgeNodes[edgenumber] followed by [vertexIndes0][vertexIndex1]
//for zero and one is second value
//you will use these values for the assembly process.

float edgeNodes[10000][2];
float freedomDeg[10000][2][2];

float vertexPos[10000][2][3];

float length[10000];
float ls[10000];
float ms[10000];

float stiffMatrix[10000][4][4];
float globalMatrix[10][10];

int count;
count = 0;

MString txt;
MItSelectionList iter( selection );
for ( ; !iter.isDone(); iter.next() )
{
iter.getDagPath( dagPath, component );

MItMeshEdge edgeIter( dagPath, component, &stat );
if( stat == MS::kSuccess )
{
txt += dagPath.fullPathName() + "\n";

edgeCount = edgeIter.count();
txt += MString("# Edges: ") + edgeCount + "\n";

//sort vertext positions
for( ; !edgeIter.isDone(); edgeIter.next() )
{
edgeIndex = edgeIter.index();

v0Index = edgeIter.index(0);
v1Index = edgeIter.index(1);

v0 = edgeIter.point( 0, MSpace::kWorld );
v1 = edgeIter.point( 1, MSpace::kWorld );

//store edges and the nodes they are connected to
edgeNodes[count][0] = v0Index;
edgeNodes[count][1] = v1Index;
//establish degress of freedom for each memeber
freedomDeg[count][0][0] = 2*(edgeNodes[count][0])-1;
freedomDeg[count][0][1] = 2*(edgeNodes[count][0]);
freedomDeg[count][1][0] = 2*(edgeNodes[count][1])-1;
freedomDeg[count][1][1] = 2*(edgeNodes[count][1]);

vertexPos[count][0][1] = (v0.x)*(1000);
vertexPos[count][0][2] = (v0.y)*(1000);
vertexPos[count][0][3] = (v0.z)*(1000);

vertexPos[count][1][1] = (v1.x)*(1000);
vertexPos[count][1][2] = (v1.y)*(1000);
vertexPos[count][1][3] = (v1.z)*(1000);

txt = txt + "Edge " + edgeIndex + ": " +
v0Index + " (" + v0.x + ", " + v0.y + ", " + v0.z + ") " +
v1Index + " (" + v1.x + ", " + v1.y + ", " + v1.z + ")\n\n";

txt = txt + "count =" + count + "\n\n";

txt = txt + "Edge zero " + edgeIndex + "\n " +
"vertex1: x, " + vertexPos[count][0][1] + "y, " + vertexPos[count][0][2] + "z, " + vertexPos[count][0][3] + ") " +
"vertex2: x, " + vertexPos[count][1][1] + "y, " + vertexPos[count][1][2] + "z, " + vertexPos[count][1][3] + ")\n\n";

length[count] = sqrt(pow(vertexPos[count][0][3] - vertexPos[count][1][3],2)+pow(vertexPos[count][0][1] - vertexPos[count][1][1],2));
ls[count] = (vertexPos[count][0][3] - vertexPos[count][1][3])/length[count];
ms[count] = (vertexPos[count][0][1] - vertexPos[count][1][1])/length[count];

count = count+1;
}

}
}

//set global matrix to zero
int z;
int q;
for(z=0; z < count; z++){
for(q=0; q < count; q++){
globalMatrix[z][q]= 0;
}
}

int i;
for(i=0; i < count + 1; i++){

//calculate stiffness matrix for each element and store in three dimensional array.
//int node1 = edgeNodes[i][0];
int freeVector1 = freedomDeg[i][0][0];
int freeVector2 = freedomDeg[i][0][1];
int freeVector3 = freedomDeg[i][1][0];
int freeVector4 = freedomDeg[i][1][1];

//calculate row one u1
stiffMatrix[i][0][0] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][1][0] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][2][0] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][3][0] = ((e*a)/length[i])*(-ls[i]*ms[i]);
//gloabl matrix for u1

//THIS IS WHERE THE PROBLEM STARTS!!

globalMatrix[freeVector1][freeVector1] = stiffMatrix[i][0][0] + globalMatrix[freeVector1][freeVector1);
// globalMatrix[freeVector1][freeVector2] = stiffMatrix[i][1][0] + globalMatrix[freeVector1][freeVector2];
// globalMatrix[freeVector1][freeVector3] = stiffMatrix[i][2][0] + globalMatrix[freeVector1][freeVector3];
// globalMatrix[freeVector1][freeVector4] = stiffMatrix[i][3][0] + globalMatrix[freeVector1][freeVector4];
//calculate row two v1
stiffMatrix[i][0][1] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][1][1] = ((e*a)/length[i])*(pow(ms[i],2));
stiffMatrix[i][2][1] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][3][1] = ((e*a)/length[i])*(-pow(ms[i],2));
//gloabl matrix for v1
// globalMatrix[freeVector2][freeVector1] = stiffMatrix[i][0][1] + globalMatrix[freeVector2][freeVector1];
// globalMatrix[freeVector2][freeVector2] = stiffMatrix[i][1][1] + globalMatrix[freeVector2][freeVector2];
// globalMatrix[freeVector2][freeVector3] = stiffMatrix[i][2][1] + globalMatrix[freeVector2][freeVector3];
// globalMatrix[freeVector2][freeVector4] = stiffMatrix[i][3][1] + globalMatrix[freeVector2][freeVector4];
//calculate row three u2
stiffMatrix[i][0][2] = ((e*a)/length[i])*(-pow(ls[i],2));
stiffMatrix[i][1][2] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][2][2] = ((e*a)/length[i])*(pow(ls[i],2));
stiffMatrix[i][3][2] = ((e*a)/length[i])*(ls[i]*ms[i]);
//gloabl matrix for u2
// globalMatrix[freeVector3][freeVector1] = stiffMatrix[i][0][2] + globalMatrix[freeVector3][freeVector1];
// globalMatrix[freeVector3][freeVector2] = stiffMatrix[i][1][2] + globalMatrix[freeVector3][freeVector2];
// globalMatrix[freeVector3][freeVector3] = stiffMatrix[i][2][2] + globalMatrix[freeVector3][freeVector3];
// globalMatrix[freeVector3][freeVector4] = stiffMatrix[i][3][2] + globalMatrix[freeVector3][freeVector4];
//calculate row four v2
stiffMatrix[i][0][3] = ((e*a)/length[i])*(-ls[i]*ms[i]);
stiffMatrix[i][1][3] = ((e*a)/length[i])*(-pow(ms[i],2));
stiffMatrix[i][2][3] = ((e*a)/length[i])*(ls[i]*ms[i]);
stiffMatrix[i][3][3] = ((e*a)/length[i])*(pow(ms[i],2));
//gloabl matrix for v2
// globalMatrix[freeVector4][freeVector1] = stiffMatrix[i][0][3] + globalMatrix[freeVector4][freeVector1];
// globalMatrix[freeVector4][freeVector2] = stiffMatrix[i][1][3] + globalMatrix[freeVector4][freeVector2];
// globalMatrix[freeVector4][freeVector3] = stiffMatrix[i][2][3] + globalMatrix[freeVector4][freeVector3];
// globalMatrix[freeVector4][freeVector4] = stiffMatrix[i][3][3] + globalMatrix[freeVector4][freeVector4];

}

//print global matrix
// int g;
// int h;
// for(g=0; g < count; g++){
// for(h=0; h < count; h++){

// txt = txt + globalMatrix[g][h] + "\n";
// }
// }

//print local matrix

// int w;
// for(w=0; w < count; w++){
// //this text is for testing against the example.
// txt = txt + " x2 " + vertexPos[w][0][3] + " x1 " + vertexPos[w][1][3] + " y2 " + vertexPos[w][0][1] + " y1 " + vertexPos[w][1][1] + "\n\n";
// txt = txt + "length of member zero is" + length[w] + "\n\n";
// txt = txt + "ls of member zero is" + ls[w] + "\n\n";
// txt = txt + "ms of member zero is" + ms[w] + "\n\n";
//
//
// txt = txt + "stiffness matrix for element three" + "\n";
// txt = txt + stiffMatrix[w][0][0] + "\n";
// txt = txt + stiffMatrix[w][1][0] + "\n";
// txt = txt + stiffMatrix[w][2][0] + "\n";
// txt = txt + stiffMatrix[w][3][0] + "\n";
// txt = txt + stiffMatrix[w][0][1] + "\n";
// txt = txt + stiffMatrix[w][1][1] + "\n";
// txt = txt + stiffMatrix[w][2][1] + "\n";
// txt = txt + stiffMatrix[w][3][1] + "\n";
// txt = txt + stiffMatrix[w][0][2] + "\n";
// txt = txt + stiffMatrix[w][1][2] + "\n";
// txt = txt + stiffMatrix[w][2][2] + "\n";
// txt = txt + stiffMatrix[w][3][2] + "\n";
// txt = txt + stiffMatrix[w][0][3] + "\n";
// txt = txt + stiffMatrix[w][1][3] + "\n";
// txt = txt + stiffMatrix[w][2][3] + "\n";
// txt = txt + stiffMatrix[w][3][3] + "\n";
// }


MGlobal::displayInfo( txt );

return MS::kSuccess;
}

dbsmith
11-21-2006, 09:22 PM
Try using a temporary float variable to store the result of the addition, then assign it to your matrix. Also, print out a shitload of variable values as you go to check things.

fbitonti
11-21-2006, 10:01 PM
the problem is that it dons't print anything at all so I don't realy know what is going on.

can anyone think of any reason that these variables should have trouble being added together.

fbitonti
11-21-2006, 10:16 PM
Ok i've narrowed it down to the global matrix variable. there must be something wrong with this variable. Can any one see it because I have no idea.

dbsmith
11-22-2006, 12:31 AM
What, exactly, is being printed out then, when you uncomment and run the global matrix printout code?

At a glance, it looks as though when you initialize your global matrix to have all values at 0, you are looping through "count x count" number of times, where count could be a large number, where you want to loop through your global matrix 10x10 times, i.e. its actual size.
Same for when u print it out.

fbitonti
11-22-2006, 12:40 AM
ok this is what happens the plugin compiles fine with no errors. however, when i run the plugin in maya on a mesh it does not out put any thing nor does it give me an error. It's as though I made a function that does nothing. The script works fine when i add in code that adds elements back into the globalMatrix after the loop that sets all elments in the matrix to zero. after that loop if i try and edit the matrix again it freaks out. I hope that clears up what is going on.

fbitonti
11-22-2006, 12:41 AM
for my application at this moment count will never be more than 10 in fact I working at the moment on mesh that only has 5 edges.

dbsmith
11-22-2006, 12:53 AM
globalMatrix[freeVector1][freeVector1] = ...;It looks as though freeVector1 and the like may be too high/low for valid indices?
Try printing out freeVector1's value right before this line of code. Is it between 0 and 9?

The problem you've described sounds just like a matrix trying to access invalid data because its index is too high/low.

fbitonti
11-22-2006, 11:55 PM
Thank you for the help. I finally got it to work your advice was extremely helpful.

CGTalk Moderation
11-22-2006, 11:55 PM
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.