macro "Add Segment Tool (or press alt key remove segment) -C000De8C000C111D07D08D09D0aD0bD0cD0dD1dD28D2dD38D3dD43D48D4dD53D56D57D58D59D5aD5dD63D68D6dD73D78D7dD83D8dD93D9dDa3Da8Da9DadDb3DbdDc3DcdDd3DdcDddDe3De4C111C222D16D25D34Db7DbaDc6DcbDd5C222C333C444C555C666C777C888C999CaaaD17D26D35D44D69D6aDb8Db9Dc7DcaDd6Dd8DdbDe5De7De9Df6Df8CaaaD06D15D24D33Da7DaaDb6DbbDc5DccDd4CaaaCbbbCcccCdddD42D65D66D67D98D99DecDf4Cddd"{ // This macro tool is an image tool for adding a segment to Polygon or Segmented Line selections. // // //Check Polygon or Segmented Line Selections if(!(selectionType == 6 || selectionType == 2))exit("Segmented line selections required"); leftButton=16; rightButton=4; shift=1; ctrl=2; alt=8; x2=-1; y2=-1; z2=-1; flags2=-1; //Get the cursor location in pixels and the mouse event modifier flags. getCursorLoc(x, y, z, flags); // print("Sample: "+x+" "+y); //XY coordinates of the nodes of the ROI goes into each of the array of x1 and y1. getSelectionCoordinates(x1, y1); //An array of node ID closest to the position clicked nmin=0; //An array of node ID closest to the second position clicked nmin2=0; //ID and ask the nearest distance from the position that was clicked Min=sqrt((x-x1[0])*(x-x1[0])+(y-y1[0])*(y-y1[0])); for(i=1;ils) { nmin=i; Min=ls; } } //Check both sides of the closest position if(nmin+1> x1.length-1)i=0; else{i=nmin+1;} ls2=sqrt((x-x1[i])*(x-x1[i])+(y-y1[i])*(y-y1[i])); if(nmin-1<0){ im=x1.length-1; }else{ im=nmin-1; } ls0=sqrt((x-x1[im])*(x-x1[im])+(y-y1[im])*(y-y1[im])); //Adding to the near side if(ls2