PDA

View Full Version : Maintaining point selections on multiple foreground layers



allankiipli
06-08-2004, 05:07 AM
I need Help with this:
To make the simple idea work.


// User has selection of points on even multiple foreground layers. Script finds last point selected
// and moves the other points to z coordinate of that point cycling through layers.

main
{
obj = Mesh(0); // my modeler selected object

selmode( DIRECT ); // operate on selected components

editbegin();

sizep = pointcount();

pnt = points;

pointlast= pointinfo(points[size]); // it really finds the last point even when multiple fg layers are active

workLayer = lyrfg();

sizel = workLayer.size(); // have the number of active foreground layers

var lypnts[sizel][sizep];

i=1;

foreach ( pntID, pnt){ // iterate trough the layers

if (workLayer[i] != obj.layer( pntID )) i++;

lypnts[i] += pntID;
}

editend();

for(i=1; i<=sizel; i++){ // iterate trough the layers

lyrsetfg(workLayer[i]);

editbegin();

foreach ( pntID, lypnts[i]){

pointmove(pntID,pntID.x,pntID.y,pointlast.z);

}
editend();
}
}

allankiipli
06-08-2004, 06:47 AM
Fixed one error, added more comments

main
{
obj = Mesh(0); // my modeler selected object
selmode( DIRECT ); // operate on selected components
editbegin();
sizep = pointcount();
pnt = points;
pointlast= pointinfo(points[sizep]);// fixed sizep
workLayer = lyrfg();
sizel = workLayer.size(); // have the number of active foreground layers
var lypnts[sizel][sizep]; // this is a two dimensional array.
//First the number of layers that were active, second contains selected points for //current layer.But obviously the selections in layers are not equal.
i=1;
foreach ( pntID, pnt){ // iterate trough all selected points
if (workLayer[i] != obj.layer( pntID )) i++; //to what layer the point belongs?
// again not sure if it is right constructed
lypnts[i] += pntID;
}
editend();
for(i=1; i<=sizel; i++){ // iterate trough the layers
lyrsetfg(workLayer[i]);
editbegin();
foreach ( pntID, lypnts[i]){
pointmove(pntID,pntID.x,pntID.y,pointlast.z);
}
editend();
}
}

GregMalick
07-27-2004, 04:19 PM
No one has replied, so I put in my 2cents.

I believe that selected points only exist in FG layers, so if you are trying to set all the points to the poisition of the very last selected point, you just need to iterate through the set of selected points and use the point move. I don't think you need to check at all which layer it belongs to. And I don't even think you need any extra arrays.

Cutting & pasting:



selmode( DIRECT );
editbegin();
pointlast= pointinfo(points[points.size()]);
foreach (pntID, pnt) pointmove(pntID,pntID.x,pntID.y,pointlast.z);
editend();