PDA

View Full Version : selpoint problems



spaniard
02-24-2004, 01:09 PM
I'm having difficulty with a portion of my code. I have tried different things, but can't come up with a process that works.

What's happening is, after the pathextrude() is performed I cannot find a way to select any of the points on the motion path. It is the only object in the current layer and I would like to be able to select all of the points along the curve. I'm assuming I need to have the points selected in order to perform the freezecurves() correctly because the freezecurves() does nothing with the points not selected.

selmode(user);
selpoint(SET,POINTID,point[1]);

//extrude motion path
pathextrude(file);

selpoint(set, pointndx,1);

//convert points to polygons
freezecurves();

Thanks for any help.

evenflcw
02-24-2004, 10:14 PM
First of all, lscript is very picky when it comes to case sensitivity, so be sure to check twice how the inputs should be written. selpoint(set, pointndx,1); should simply be selpoint(SET, POINTNDX, 1);

Second, I don't know if this is your full script or not, but to be able to refer to the "points"-array and pointIDs you first have to run a session of meshedit ( editbegin(); editend(); ), because thats when that array is created. You are however free to refer to indexes at any time when in CommandSequence mode (default).

When using POINTID/POLYID as input for the selection commands you are refering to unique 8-digit codes assigned to each point/polygon at the time of their creation. These are placed into a usable array ("points" or "polygons" depending on what was selected last) only after entering MeshDataEdit atleast once. These arrays are either sorted in order of selection or creation (if nothing was explicitly selected).

POINTNDX/POLYNDX however are not connected to any array, but simply correspond to the order of selection OR creation (if nothing was selected).


Since pathextrude won't create a curve you need to create one yourself within meshdataedit mode and addcurve();

come ca:

main
{
selmode(USER);

//extrude motion path
pathextrude("test.mot");

//Create new curve.
editbegin();
addcurve(points); //refers to all points, from first created to last, in order.
editend();

freezecurves(); //be prepared for unwanted results. ;)
}

If this isn't what you want, please explain further in more detail. Be aware that there are already some free scripts available (www.FLAY.com) that'll make motionspaths into splines, polychains or whatnot.

spaniard
02-26-2004, 10:33 AM
What I'm wanting to do is read in a group of motion paths and convert the points to polygons so that the path is visible in Layout. Now, my motion file data is very dense (sometimes 2000 points) and I have up to several hundred files. I can make the paths less dense if there is a limitation in the number points that the freezecurve() process can handle. The freezecurve() method is the only method I've seen that "should" do what I'm needing. I was unsuccessful using the last suggestion. The script bombed and closed at the addcurve statement.

main
{

text1 = "C:/LightWave_3D_7.0/path#";
text2 = ".mot";
text3 = "path#";

num_paths = 1; //set to one for testing
for(cnt=1;cnt<=num_paths;cnt++)
{
//select the current layer
lyrsetfg(cnt);

file = text1 + cnt + text2;
layername = text3 + cnt + text2;

//open the file
rfile = File(file,"r") || error("Couldn't open file");

//name the current layer
setlayername(layername);

//add a point at (0,0,0) and extrude motion
editbegin();
point[1] = addpoint(0,0,0);
editend();

selmode(user);
selpoint(SET,POINTID,point[1]);

pathextrude(file);

editbegin();
addcurve(points); //script crashed here
editend();

//convert points to polygons
freezecurves();


I then tried a different method, plotting the data using addpoint, converting the points to a curve and then using the freecurve().
This method worked up to the point of the freezecurve() statement.

main
{

text1 = "C:/LightWave_3D_7.0/path#";
text2 = ".txt";
text3 = "path#";

num_paths = 1; //set to one for testing
for(cnt=1;cnt<=num_paths;cnt++)
{
//select the current layer
lyrsetfg(cnt);

file = text1 + cnt + text2;
layername = text3 + cnt + text2;

//open the file
rfile = File(file,"r") || error("Couldn't open file");

//name the current layer
setlayername(layername);

editbegin();

i=1;
while(!rfile.eof())
{
pos = rfile.readVector();

if(pos)
{
i++;
point1[i] = addpoint(pos);
}

}

addcurve(point1); //curve appears to be successfully built
editend();

freezecurves(); // modeler bombs here
}
}


Thanks for the help.

Panikos
02-28-2004, 10:04 AM
Spartacus ! ;)