hexagon logo

MIN(array) and MAX(array) not working for me

version 2021.2 in case that matters.

I have a short arc, and I measured it as a cylinder (it's long even though the arc length is short) and I had to use Fixed Radius so I could get a reporting of the X and Y.

I need the radius.

So I aligned the cylinder, and then want the polar radius of each of 15 points.

I did a do/until and stuffed all the PR's into an array.

I then asked for the MAX and MIN value.

No joy.

I went to this thread: https://www.pcdmisforum.com/forum/pc-dmis-enterprise-metrology-software/pc-dmis-for-cmms/523659-help-with-min-and-max
and I copied the examples from people doing the same thing as me, just simple X and Y rather than PR, and no joy.

By "no joy" I mean that it is stuffing the ENTIRE array into the variable that is to get just the MAX or MIN.

I'm including a screen shot during run-time so you can see my mouse over the SECOND assignment (I think it should be ok at one, but I copied the example of the last helper when the first one failed).

I changed from variable names I could read and identify later to V1 and such.

VCNT is the counter to create the array and set indices in it.
V1 the array with all the PR's in it (evaluated as X^2 + Y^2, quantity square root) and the answers I get match what I would get doing the output manually. (Side note, it says .hits[vcnt] because .hit[vcnt] was giving me the nominal PR for all 15 indices)
V2 is supposed to be the MAX of V1.
VLRG is just putting the value of V2 in there, which should be JUST the Max value from V1.
The mouse is on VLRG, and you can see it has 15 values.

What am I doing stupid? I'm sure it is me, but I just don't see the logic error I'm making. Especially since I did it on my own and failed multiple ways for a long time before I found that thread and copied it. I was already doing it, for all intents and purposes, but I tried to copy it as verbatim as I could get.

(I can paste code, but I'm thinking the pic below of the code should be enough to see where I'm screwing up)

TIA


  • try using CYL7.HIT[VCNT] instead of HITS[VCNT].
  • I originally had this, but my array contained 15 1.67's with no variation for actual measurement.

    I don't understand the why behind that, but it resolved by using .hits so I'm overlooking it for now.

    Thank you though
  • IMNSHO the FIXED_RAD is what is stopping this from working but I could be wrong.

    Me personally, I would have measured this with a scan (or multiple scans for a cylinder), constructed a circle (or cylinder) then ask for MAX / MIN using the array for the scanned points
  • version 2021.2 in case that matters.

    I have a short arc, and I measured it as a cylinder (it's long even though the arc length is short) and I had to use Fixed Radius so I could get a reporting of the X and Y.

    I need the radius.

    So I aligned the cylinder, and then want the polar radius of each of 15 points.

    I did a do/until and stuffed all the PR's into an array.

    I then asked for the MAX and MIN value.

    No joy.

    I went to this thread: https://www.pcdmisforum.com/forum/pc-dmis-enterprise-metrology-software/pc-dmis-for-cmms/523659-help-with-min-and-max
    and I copied the examples from people doing the same thing as me, just simple X and Y rather than PR, and no joy.

    By "no joy" I mean that it is stuffing the ENTIRE array into the variable that is to get just the MAX or MIN.

    I'm including a screen shot during run-time so you can see my mouse over the SECOND assignment (I think it should be ok at one, but I copied the example of the last helper when the first one failed).

    I changed from variable names I could read and identify later to V1 and such.

    VCNT is the counter to create the array and set indices in it.
    V1 the array with all the PR's in it (evaluated as X^2 + Y^2, quantity square root) and the answers I get match what I would get doing the output manually. (Side note, it says .hits[vcnt] because .hit[vcnt] was giving me the nominal PR for all 15 indices)
    V2 is supposed to be the MAX of V1.
    VLRG is just putting the value of V2 in there, which should be JUST the Max value from V1.
    The mouse is on VLRG, and you can see it has 15 values.

    What am I doing stupid? I'm sure it is me, but I just don't see the logic error I'm making. Especially since I did it on my own and failed multiple ways for a long time before I found that thread and copied it. I was already doing it, for all intents and purposes, but I tried to copy it as verbatim as I could get.

    (I can paste code, but I'm thinking the pic below of the code should be enough to see where I'm screwing up)

    TIA

    {"alt":"Click image for larger version Name:\tmin_max.png Views:\t71 Size:\t7.8 KB ID:\t533866","data-align":"none","data-attachmentid":"533866","data-size":"full"}


    This method below may help you out....

    RECALL/ALIGNMENT,INTERNAL,ALN_AB
    MOVE/CLEARPLANE
    CYL4 =FEAT/CONTACT/CYLINDER/DEFAULT,CARTESIAN,IN,FIXED_RAD
    THEO/<-21.794,15.016,0>,<0,0,1>,16,4
    ACTL/<-21.791,14.98,-0.002>,<-0.0031664,-0.00858,0.9999582>,16,4
    TARG/<-21.793,15.017,0>,<0,0,1>
    START ANG=-67.705,END ANG=-37.405
    ANGLE VEC=<1,-0.0000022,0>
    DIRECTION=CCW
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=13,NUMLEVELS=3,DEPTH=0.5,END OFFSET=1.25,PITCH=0
    SAMPLE METHOD=SAMPLE_HITS
    SAMPLE HITS=1,SPACER=1
    AVOIDANCE MOVE=NO,DISTANCE=20
    FIND HOLE=DISABLED,ONERROR=NO,READ POS=NO
    SHOW HITS=NO
    A12 =ALIGNMENT/START,RECALL:ALN_AB,LIST=YES
    ALIGNMENT/TRANS,XAXIS,CYL4
    ALIGNMENT/TRANS,YAXIS,CYL4
    ALIGNMENT/END
    PNT23 =FEAT/CONTACT/VECTOR POINT/DEFAULT,CARTESIAN
    THEO/<6.066,-5.216,-2>,<-0.7582322,0.6519847,0>
    ACTL/<6.062,-5.21,-2.004>,<-0.7582322,0.6519847,0>
    TARG/<6.066,-5.216,-2>,<-0.7582322,0.6519847,0>
    SNAP=NO
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    AVOIDANCE MOVE=NO,DISTANCE=10
    SHOW HITS=NO
    PNT24 =FEAT/CONTACT/VECTOR POINT/DEFAULT,CARTESIAN
    THEO/<4.935,-6.296,-2>,<-0.6169047,0.7870379,0>
    ACTL/<4.929,-6.285,-1.999>,<-0.6169047,0.7870379,0>
    TARG/<4.935,-6.296,-2>,<-0.6169047,0.7870379,0>
    SNAP=NO
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    AVOIDANCE MOVE=NO,DISTANCE=10
    SHOW HITS=NO
    PNT25 =FEAT/CONTACT/VECTOR POINT/DEFAULT,CARTESIAN
    THEO/<3.491,-7.198,-2>,<-0.4363808,0.8997621,0>
    ACTL/<3.485,-7.187,-1.999>,<-0.4363808,0.8997621,0>
    TARG/<3.491,-7.198,-2>,<-0.4363808,0.8997621,0>
    SNAP=NO
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    AVOIDANCE MOVE=NO,DISTANCE=10
    SHOW HITS=NO
    ASSIGN/NOM4=8
    ASSIGN/V29=ARRAY(PNT23.PR,PNT24.PR.PNT25.PR)
    ASSIGN/V30=ABS(NOM4-V29)
    ASSIGN/V31=MAXINDEX(V30)
    ASSIGN/V32=V29[V31]
    F14 =GENERIC/POINT,DEPENDENT,CARTESIAN,$
    NOM/XYZ,<NOM4,ZERO,ZERO>,$
    MEAS/XYZ,<V32,ZERO,ZERO>,$
    NOM/IJK,<ZERO,ZERO,ONE>,$
    MEAS/IJK,<ZERO,ZERO,ONE>
    COMMENT/REPT,
    
    DIM LOC7= LOCATION OF POINT F14 UNITS=MM ,$
    GRAPH=OFF TEXT=OFF MULT=10.00 OUTPUT=BOTH HALF ANGLE=NO
    AX NOMINAL +TOL -TOL MEAS DEV OUTTOL
    X 8.000 0.500 0.500 7.987 -0.013 0.000
    END OF DIMENSION LOC7
  • I did not try Liambo's suggestion, as I'd already bypassed. Next time I make a program I will try to keep it in mind and give it a go.
    This is a 1500 feature manifold and I already collected all the data, I'm not making a report in the balloon blue print order, so changing measurement strategy and remeasuring too many things will get messy.

    I did the snippit below, abandoning arrays altogether and getting what I need.
    I will say, the line that does the math, I originally pulled just the array index [vcnt] off the end of the assignment, and PcDmis decided it was still an array and kept stuffing 15 values in it, making what I'm posting not work.
    I retyped the line as a new assignment, and it works flawlessly.

    DWade could be right about the fixed radius.
    Maybe something I typed in was taking as an array and even though I removed the array portion from the edit window was still an array behind the scenes.
    This worked, and I'm behind, so I didn't dig too deep there.
    I probably have a saved build with the broken code still in it, but, again, I'm behind, so I'm not worrying about it since it now functions as needed.
    Thank you guys, and as long as I remember, I will try Liambo's suggestion at some point, and probably DWade's also if there is enough to get a good scan on. This one is 2 inches long, but only about 15° of arc length, I think. Not sure how much would be left after filtering.


    in case someone else has same problem and Liambo's and DWade's options also don't work, this is:

    setting a counter at 1, since hit counts in features start at 1
    It sets an output variable to nominal (1.67 in this case).
    Then it pulls the hits two axes out and does Pythagorean to them for the radial distance.
    Get an absolute (no negatives) distance difference between that current radius and perfect.
    Get an absolute distance difference between the output value and perfect.
    Compare them.
    If the current radius is a bigger error from perfect, replace the output variable with the current radius.
    If the output radius has the bigger error compared to the current, no action taken.
    advance the counter.
    Do it until no points left (this was a static count of 15 hits).