Help!: How do I select points I generated in a script?

I'm generating some points in a script and somewhere else in the script I want to use them to create polygons with them. The problem is when I use cmdseq("Sel Points"); the current selection seems to get lost. If I don't use it an press space the selection I want to use shows up, but obviously the script finished running so it's basically useless.
How do I store the newly generated points so I can generate some 2 point polys from them?

I simplified the script:

@version 2.8
@warnings
@name "selectxxtestbla"
@script modeler

SelectionLoop;
Selection;


main
{
cmdseq("Sel Polys");
selmode(USER);

pc = pointcount();
info(pc);
editbegin();
stuff = addpoint( center( boundingbox()) );
editend();
selpolygon(CLEAR);
selpoint(SET,POINTID,stuff);


cmdseq("Sel Points");

}
 

iain_r

New member
Point selection

Quick code, I created a box and selected the points, then looped through the points and added them to an array pointnumber[1]. Created a new point which is not selected but added its values to the array and then just got the info. In modeler you can see that the point is added but not selected. If your running with debug you can use "Add Watch F3" on pointnumber to see the values get incremented.

Regards

Iain

Code:
@warnings
@version 2.3
@script modeler

var pointnumber[1];

main
{
    selmode(USER);
    pc = pointcount();
    if(pc == 0)
    {
        error("No points to select!");
        return;
    }

    center = <0,0,0>;
    
    editbegin();
    
    for(i=1; i <= pc; i++)
        pointnumber[i] = pointinfo(points[i]);

    addpoint(center);
    pc1 = pc + 1;
    pointnumber[pc1] = center;
    
    editend();
    
    for(i=1; i<= pc1; i++)
        info("Points position", pointnumber[i]);
}
 

Matt

Valiant NewTeKnight
Change to point selection mode before selecting the points you created. Add them to a point array ( point_array += ) ensure the array is global, then reselect with selpoint().

Code:
@version 2.8
@warnings
@name "selectxxtestbla"
@script modeler

SelectionLoop;
Selection;

var stuff;

main
{
    cmdseq("Sel Polys");
    selmode(USER);

    pc = pointcount();
    info(pc);

    editbegin();
    stuff = addpoint( center( boundingbox()) );
    editend();

    selpolygon(CLEAR);

    cmdseq("Sel Points");
    selpoint(SET,POINTID,stuff);
}
 
Last edited:
I've now managed to make an array of polygons, like this:

for(i=1; i <= polc[1]; i++){
pointnumber = polyinfo(polygons);
}

But how do I assign this array back to the selection?
Is is better to use points for this?
 

Kryslin

Active member
The first element of the array returned by polyinfo() will be the surface name of the polygon. The rest of the array is point IDs.

1) So, start with an empty variable (or a variable containing already selected points)
2) Loop through each polygon, and grab it's info.
3) For each point ID in the arrray: If there are no point IDs, or the point ID doesn't exist in the array, add it.
4) Repeat for each polygon.
5) use the array (now populated) in the selpoint() command.
 
Top Bottom