Difference between pages "GenerateRealParametersFromDblArray" and "GetClosestIndex MEL"

From scripting
(Difference between pages)
Jump to: navigation, search
(Created page with " Function GenerateRealParametersFromDblArray(ParmList As Parameters, DblArr As Variant) As Variant Dim ParmArr() ReDim ParmArr(UBound(DblArr)) For X = 0 To UBound(DblArr)...")
 
(Created page with " global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) { //0001D LLC 2015 Nick Pisca float $WinDist = 1000000.0; int $WinInt =...")
 
Line 1: Line 1:
  Function GenerateRealParametersFromDblArray(ParmList As Parameters, DblArr As Variant) As Variant
+
  global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) {
Dim ParmArr()
+
//0001D LLC 2015 Nick Pisca
ReDim ParmArr(UBound(DblArr))
+
float $WinDist = 1000000.0;
For X = 0 To UBound(DblArr)
+
int $WinInt = -1;
    Set ParmArr(X) = ParmList.CreateReal("STD_Rad" & Format(X, "00"),  DblArr(X))
+
for ($x=0;$x<size($LocArr);$x++) {
Next X
+
if ([[IsInIntArray_MEL|IsInIntArray]]($Skip, $x) == 0) {
GenerateRealParametersFromDblArray = ParmArr
+
vector $Diff = $XYZArr[$x] - $CurVec;
  End Function
+
float $Dmag = mag($Diff);
 +
if ($Dmag < $WinDist) {
 +
$WinDist = $Dmag;
 +
$WinInt = $x;
 +
}
 +
}
 +
}
 +
return $x;
 +
  }
  
  
[[Category:CATIA DP VB]]
+
 
 +
''More information on strings and arrays, read pages 28-37 in [http://stores.lulu.com/nickpisca YSYT]. 
 +
 
 +
[[Category:MEL]]

Latest revision as of 05:41, 22 April 2017

global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) {
	//0001D LLC 2015 Nick Pisca
	float $WinDist = 1000000.0;
	int $WinInt = -1;
	for ($x=0;$x<size($LocArr);$x++) {
		if (IsInIntArray($Skip, $x) == 0) {
			vector $Diff = $XYZArr[$x] - $CurVec;
			float $Dmag = mag($Diff);
			if ($Dmag < $WinDist) {
				$WinDist = $Dmag;
				$WinInt = $x;	
			}
		}	
	}
	return $x;
}


More information on strings and arrays, read pages 28-37 in YSYT.