Hey Morten,

if you change the sync method to components in the texture editor prefs,
then selecting in the TE will give you points or polys in the viewport -
dunno if that's the built in method you were talking about?

matt


On 19 April 2012 13:29, Martin <[email protected]> wrote:

> Try this, it's an script written by Matt Lind I found in the list some
> time ago.
>
> In the last sentence there was a mistake I fixed.
> (it was "grid" when it should been the parent 3d object)
>
> Martin Yara
>
>
> //=======================================================
> // ML_SelectPolygonsFromSamples()
> //
> // Given a selection of polygon nodes (samples) on a mesh,
> // select the polygons which the nodes are attached.
> //=======================================================
>
> function ML_SelectPolygonsFromSamples()
> {
>         if ( Selection.Count <= 0 ) {
>                 LogMessage( "Nothing selected", siError );
>                 return(-1);
>         }
>         // Get selection
>         var oItem = Selection(0);
>         if ( oItem.Type != "sampleSubComponent" ) {
>                 // Selection does not contain polygon nodes
>                 LogMessage( "Invalid selection", siError );
>                 return(-1);
>         }
>         var oPolygonNodes = oItem.SubComponent.ComponentCollection;
>         var oObject       = oItem.SubComponent.Parent3DObject;
>         if ( oObject.Type != "polymsh" ) {
>                 LogMessage( "Not a polygon mesh: " + oObject.FullName,
> siError );
>                 return(-1);
>         }
>         // build hash table of polygon nodes selected by user.
>         // this table will be referenced by the search.
>         var NbComparisons = 0;  // for statistics only
>         var aHash = new Array();
>         for ( var i = 0; i < oPolygonNodes.Count; i++ ) {
>                 var oPolygonNode            = oPolygonNodes(i);
>                 aHash[ oPolygonNode.Index ] = true;
>                 NbComparisons++;        }
>         // Search the mesh for polygon nodes selected by user.
>         // Traverse the nodes collection of each polygon in the mesh.
>         var NbPolygonNodes         = oPolygonNodes.Count;
>         var aPolygonIndices = new Array();
>         var oPolygons       = oObject.ActivePrimitive.Geometry.Polygons;
>         for ( var i = 0; (i < oPolygons.Count) && (NbPolygonNodes > 0);
> i++ ) {
>                 // Get current polygon
>                 var oPolygon = oPolygons(i);
>                 var oNodes   = oPolygon.Nodes;
>                 var found    = false;
>                 for ( var j = 0; (j < oNodes.Count) && (NbPolygonNodes >
> 0); j++ ) {
>                         // Get current polygon node
>                         var oNode = oNodes(j);
>                         NbComparisons++;
>                         // Lookup node to see if user selected it.
>                         if ( aHash[ oNode.Index] == true ) {
>                                 // node is selected by user
>                                 found = true;
>                                 NbPolygonNodes--;
>                         }
>                 }
>                 if ( found ) {
>                         // mark polygon for selection
>                         aPolygonIndices.push( oPolygon.Index );
>                 }
>         }
>         // Select the polygons
>         Selection.SetAsText( oObject + ".poly[" + aPolygonIndices + "]" );
>         LogMessage( "NbComparisons: " + NbComparisons );
>         return;
> }
>



-- 
www.matinai.com

Reply via email to