Cheetah3D cannot read its own files

Cheetah3D cannot read its own files

Wrote a script, produced three nice pictures in ten hours, saving the files and then finding, that Cheetah3D could not read the files it wrote.
Can anybody help?
Find attached the script that is the culprit for the disaster.

herbert


//
function buildUI(obj){
obj.setParameter("name","Arrow2D");

obj.addParameterFloat("length",1,0,1000,true,true);
obj.addParameterFloat("L_of_head",.3,0,1000,true,true);
obj.addParameterFloat("diam_of_shaft",.1,0,1000,true,true);
obj.addParameterFloat("diam_of_head",.25,0,1000,true,true);
obj.addParameterInt("axis",0,0,2,true,true);
obj.addParameterBool("rot",false,false,true,true,true);
obj.addParameterBool("double",false,false,true,true,true);
obj.addParameterBool("reverse",false,false,true,true,true);
}

function buildObject(obj){
var arrow=obj.core();
var i;
var x,y,z;

//get current parameter values
Length =obj.getParameter("length");
L_of_head =obj.getParameter("L_of_head");
diam_of_shaft =obj.getParameter("diam_of_shaft");
diam_of_head =obj.getParameter("diam_of_head");
axes =obj.getParameter("axis");
rot =obj.getParameter("rot");
doubl =obj.getParameter("double");
reverse =obj.getParameter("reverse");

var x1=diam_of_shaft/2;
var z1=Length/2-L_of_head;
var x2=diam_of_head/2;
var z2=Length/2;
var NrOfEdge=7
if (doubl) {NrOfEdge=10}

var points = new Array;
if (doubl) { points.push( new Vec3D(x1,0,-z1) ); } else { points.push( new Vec3D(x1,0,-z2) ); }
points.push( new Vec3D(x1,0,z1) );
points.push( new Vec3D(x2,0,z1) );
points.push( new Vec3D(0,0,z2) );
points.push( new Vec3D(-x2, 0,z1) );
points.push( new Vec3D(-x1,0,z1) );
if (doubl) { points.push( new Vec3D(-x1,0,-z1) );} else { points.push( new Vec3D(-x1,0,-z2) );}
points.push( new Vec3D(-x2, 0,-z1) );
points.push( new Vec3D(0,0,-z2) );
points.push( new Vec3D(x2,0,-z1) );

var i;
if (reverse){
for (i=0; i<NrOfEdge; i++) {
reverseP(points);
}
}


if (rot) {
for (i=0; i<NrOfEdge; i++) {
flip(points);
}
}
for (i=0; i<NrOfEdge; i++) {
rotate(points, axes);
}


arrow.move(points[0]);
for(i=1;i<NrOfEdge; i++) {
arrow.line(points);
}

// arrow.close();
arrow.line(points[0]);
}

function rotate(pos, axes){
var posi=new Vec3D();
posi.x=pos.x;
posi.y=pos.y;
posi.z=pos.z;
if (axes==1) {
pos.x=posi.y;
pos.y=posi.z;
pos.z=posi.x;
}
if (axes==2) {
pos.x=posi.z;
pos.y=posi.x;
pos.z=posi.y;
}
}

function flip(pos){
var posi=new Vec3D();
posi.x=pos.x;
posi.y=pos.y;
pos.x=posi.y;
pos.y=posi.x;
}

function reverseP(pos){
var posi=new Vec3D();
posi.z=pos.z;
pos.z=-posi.z;
}
 
Hi,
the problem comes from the fact that you've defined a parameter "rot" which Cheetah3D already uses internally. It therefore overwrote an existing parameter.

The problem is that not all parameters are scriptable. Some are invisible in the script engine and they can therefore not be found with the "Parameter Info.js" script.

I have to think about a solution how you can detect parameter names which are already used.

Problematic for the bug you encountered are only the parameter names "rot" and "pos". Please avoid these parameter names in scripts.

Bye,
Martin

P.S. Herb I've fixed your files and mailed them back so you should be able to open them again. Sorry for the problems.:oops:
 
Back
Top