CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   ANSYS (http://www.cfd-online.com/Forums/ansys/)
-   -   Ansys - AddToSelection By Body Name. (http://www.cfd-online.com/Forums/ansys/106275-ansys-addtoselection-body-name.html)

eexak17 August 23, 2012 12:21

Ansys - AddToSelection By Body Name.
 
I am trying to make a function that will select all bodies with the predefined name. Unfortunately I am novice in Ansys and eventually have made a mistake which I can't identify. Could you please assist me with that? Do you know a good debugger to advice?


function main2(name){
var target_name=name;
SM.Clear();
// Select all entities
SC.doEditSelectAll();
// Number of selected bodies

var num_selected_bodies = SM.Parts;
var num_selected_entities = SM.SelectedCount;

// Arrays to save IDs
var PartID = new Array();
var TopoID=new Array();
var j=0;

// Loop through selection and store IDs
for (i=1;i=num_selected_entities;i++) {
var entityTopoId = SM.SelectedEntityTopoID(i);
if (entityTopoId >=3221225473) {//For bodies only
TopoID[j]=SM.SelectedEntityTopoID(i);
PartID[j]=SM.SelectedPartID(i);
j++;
}}

var array_length=PartID.length;
SM.Clear();

// Loop through parts by IDs
for (i=0;i=array_length;i++)
{
var part = SM.PartMgr.PartById(PartID[i]);
if (part.Name.toLowerCase()==target_name.toLowerCase( )) {
part_id=PartID[i];
topo_id=TopoID[i];
SM.AddToSelection(part_id, topo_id, true);
}}}


All times are GMT -4. The time now is 05:23.