PDA

View Full Version : DeSelect



riki
09-07-2004, 11:58 PM
This page hasn't been updated since 2001. But there's a script there that I like called 'DeSelect.ls' which isn't working in LW8. It basically deselects Polys based on direction.

The error message reads as follows

"Unresolved Function - Line30, Unable to locate function reference addcontrol"

Any ideas on how to fix it?


// DeSelect polygons by their direction. By James G. Jones ([email protected])

// 5/3/96, 7/31/97

// ReWrite by Anthony Ramirez 10/20/98



main

{

var Vt; // temporary vector

var polyInfo[6]; // for results of polycount()

var polyindex; // save selected polygons

var axis = recall("axis",1); // saved values from requester

var name = recall("name","New");

var rename = recall("rename", 0); // make new surface, or not

var buttons[6]; // buttons strings for requester

buttons[1] = "+X";

buttons[2] = "-X";

buttons[3] = "+Y";

buttons[4] = "-Y";

buttons[5] = "+Z";

buttons[6] = "-Z";

var renamebuttons[2];

renamebuttons[1] = "New Surface";

renamebuttons[2] = "Select Only";

var c1, c2, c3; // to hold control handle returned by addcontrol()

var i; // for loops

var ii = 1;



// Put up the requester...

reqbegin("Directional DeSelect");



c1 = addcontrol(axis,"Direction:",buttons);



if(reqpost())

{

axis = getvalue(c1); // see what the user input

store("axis",axis); // keep values for subsequent runs...

}

else return;



reqend();



selmode(USER); // for rest of script



editbegin();

polyInfo = polycount();

switch(axis)

{

case 1: // +X axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.x >= abs(Vt.y) && Vt.x >= abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 2: // -X axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.x <= -abs(Vt.y) && Vt.x <= -abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 3: // +Y axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.y >= abs(Vt.x) && Vt.y >= abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

//info("Normal: ",Vt.x," ",Vt.y," ",Vt.z);

}

break;

case 4: // -Y axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.y <= -abs(Vt.x) && Vt.y <= -abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 5: // +Z axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.z >= abs(Vt.x) && Vt.z >= abs(Vt.y))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 6: // -Z axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.z <= -abs(Vt.x) && Vt.z <= -abs(Vt.y))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

}

editend();



selpolygon(CLEAR,POLYID,polyindex);

}

riki
09-08-2004, 12:00 AM
Almost forgot a link to the script http://www.mindspring.com/~anthonyramirez/LScript/LScript.htm

faulknermano
09-08-2004, 01:20 AM
// DeSelect polygons by their direction. By James G. Jones ([email protected]xelsys.com)

// 5/3/96, 7/31/97

// ReWrite by Anthony Ramirez 10/20/98



main
{
var Vt; // temporary vector
var polyInfo[6]; // for results of polycount()
var polyindex; // save selected polygons
var axis = recall("axis",1); // saved values from requester
var name = recall("name","New");
var rename = recall("rename", 0); // make new surface, or not
var buttons[6]; // buttons strings for requester
buttons[1] = "+X";
buttons[2] = "-X";
buttons[3] = "+Y";
buttons[4] = "-Y";
buttons[5] = "+Z";
buttons[6] = "-Z";
var renamebuttons[2];
renamebuttons[1] = "New Surface";
renamebuttons[2] = "Select Only";
var c1, c2, c3; // to hold control handle returned by addcontrol()
var i; // for loops
var ii = 1;
// Put up the requester...
reqbegin("Directional DeSelect");
// c1 = addcontrol(axis,"Direction:",buttons);
c1 = ctlchoice("Direction:",axis,buttons); // changed this
if(reqpost())
{
axis = getvalue(c1); // see what the user input
store("axis",axis); // keep values for subsequent runs...
}
else return;
reqend();

selmode(USER); // for rest of script
editbegin();
polyInfo = polycount();
switch(axis)
{

case 1: // +X axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.x >= abs(Vt.y) && Vt.x >= abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 2: // -X axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.x <= -abs(Vt.y) && Vt.x <= -abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 3: // +Y axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.y >= abs(Vt.x) && Vt.y >= abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

//info("Normal: ",Vt.x," ",Vt.y," ",Vt.z);

}

break;

case 4: // -Y axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.y <= -abs(Vt.x) && Vt.y <= -abs(Vt.z))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 5: // +Z axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.z >= abs(Vt.x) && Vt.z >= abs(Vt.y))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

case 6: // -Z axis

for(i=1; i<polyInfo[1]+1; i++) // scan each polygon

{

Vt = polynormal(polygons[i]); // get normal vector

if(Vt.z <= -abs(Vt.x) && Vt.z <= -abs(Vt.y))

{

polyindex[ii] = polygons[i];

ii += 1;

}

}

break;

}

editend();



selpolygon(CLEAR,POLYID,polyindex);

}

riki
09-08-2004, 01:46 AM
Hi faulknermano

aah sweet you're a champ, it works perfectly now.

Many thanks :)