PDA

View Full Version : Select edge loop through scripting.


Sbowling
04-28-2007, 02:05 AM
Is there a way to select edge loops through scripting? I'm working on cleaning up a model with a ton of edges, and I'd like to script the process of selecting the loop and deleting the edges, to speed things up and save the wear and tear on my fingers, but I can't find anything in the SDK or searches. You would think something like this would be easy.

MiGa
04-28-2007, 11:03 AM
Haven't found a solution but have a look at:
/Softimage/XSI_6.01/Application/DSScripts/selection.vbs

This script is called from the internal Select Edge loop menu point!

Sbowling
04-28-2007, 08:23 PM
That looked promising, but I can't figure out how to get it to do anything useful. Everything seems to be dependent on everything else, and the only usable function I found was EdgeLoopTest(), and it's not really that useful. Maybe when I have time to go throught the 2000 lines of the script, I wil be able to get something useful out of it, but that's not likely to be any time soon. :shrug:

Thanks anyway.

tachy0n
04-28-2007, 10:37 PM
Yeh this is one of those 'WTF were they thinking' issues. It would have been real easy to expose the looping and selecting stuff in the form of usable commands, but they haven't so your only choices are:

1. Use a 3rd party plugin that does expose the commands, like RCTools.

2. Write your own edge loop script (not that hard for simple looping, look in the commented section of the edge looping funcs of selection.vbs file for the method to use)

3. Try the selection.vbs hack rork posted at XSIBase :

http://www.xsibase.com/forum/index.php?board=10;action=display;threadid=28489

Sbowling
04-29-2007, 01:58 AM
Thanks tachy0n,

Any chance you have a link to that thread? I can't seem to find it (I hate the XSIbase search engine!).

Thanks again.

tachy0n
04-29-2007, 02:39 AM
It's in the link i posted above, a few posts down. Or here's the direct link:

http://www.claus-figuren.de/rt/RCtools_light.vbs

Sbowling
04-29-2007, 04:25 AM
It's in the link i posted above, a few posts down. Or here's the direct link:

http://www.claus-figuren.de/rt/RCtools_light.vbs

Oh, OK. I didn't realize you were talking abut RCtools. I was looking for a post by rork, not rray. :D

huskerdude
04-29-2007, 07:27 AM
Sam - I'm currently writing a script which selects polygons/edge loops (but multiple times) and I went down the routes you're going but decided to roll my own select loop. I've only done polygons at the moment. The script's here but it's in Python and is probably not so useful for you:

http://www.exch.demon.co.uk/jj_loopstep.htm

But, the basic process for getting an edge loop is quite simple and goes like this.

Select an edge
Find the two neighbour polygons to that edge and record their indices
Select the neighbour edges of the original edge
Iterate through each neighbour edge and get its own neighbour polygons
Iterate through each neighbour polygon of each neigbour edge until you find the neighbour edges who do not share a polygon with the original poly
Do this in both directions from the original edge, repeating for each new edge you find.

There are a few more wrinkles, but that's the basic process.

Julian

tachy0n
04-29-2007, 10:46 AM
Oh, OK. I didn't realize you were talking abut RCtools. I was looking for a post by rork, not rray. :D

Woops my bad :) I didnt realise rray himself had posted the scripts till i went back and saw the thread again. I definitely need more sleep !

MiGa
04-29-2007, 01:36 PM
Should work with one edge selected:

if (Selection(0).SubComponent.ComponentCollection.count==1){
// start with first edge
go_loop(Selection(0).SubComponent.ComponentCollection.item(0));
} else {
LogMessage("Select one edge");
}


function go_loop(edge){
var edge_index = edge.index; // get edge index
var n_poly= edge.NeighborPolygons(); // get edge neighbour polygons
var n_edges=edge.NeighborEdges(); // get edge neighbour edges

for (var i=0;i<n_edges.count;i++){ // loop over all neighbour edges
e=n_edges(i); // get the edge
if (n_poly.count==2) {
// inside object
ne=check_new_edge(n_poly(0),n_poly(1),e); // check if loop
} else {
// on the corner/edge of the object
ne=check_new_edge(n_poly(0),-1,e); // check if loop
}
if (ne.index>-1) {
// found loop!
if (check_selection(ne)>0){ // check if new edge and not already in our selection
AddToSelection(Selection(0).name+".edge["+ne.index+"]", null, true);
go_loop(ne); // go on with the new edge
}


}
}
}

function check_new_edge(inA,inB, edge){
//
// check if the edge doesn't share a polygone
//
np=edge.NeighborPolygons(); // get the new edge neighbour polygons
if (np.count>=2) {
// inside
if (np(0).index != inA.index && np(1).index !=inB.index && np(0).index!=inB.index && np(1).index!=inA.index) {
return edge;
}
} else {
// edge/corner
if (np(0).index != inA.index && np(0).index != inB.index ) {
return edge;
}
}

return -1;

}

function check_selection(ne) {
//
// check if edge is already selected
//
for (var j=0;j<Selection(0).SubComponent.ComponentCollection.Count;j++){
if (Selection(0).SubComponent.ComponentCollection.item(j).index==ne.index) return -1;
}
return 1;
}

CGTalk Moderation
04-29-2007, 01:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.