hexagon logo

MAX point in a feature set using a user input range of points

How to find the MAX point in a feature set, but between a range of points input by user.

Use as you like. You could also change CODE to find MIN point.



$$ NO,.              
$$ NO,. How To Find the MAX POINT in a feature set of limited size
$$ NO,.
$$ NO,. Input the number of the feature set point you want to start from
$$ NO,.
            ASSIGN/NHITS = SCN1.NUMHITS
L1         =LABEL/
C1         =COMMENT/INPUT,NO,"ENTER START POINT."
                            ,
                            ,"THE FEATURE HAS ===> " +NHITS +" POINTS"
            COMMENT/REPT,"the feature has ===> " +NHITS + " points"
$$ NO,.
$$ NO,. Test value to be sure it is legal
$$ NO,.
            IF/C1.INPUT < 1 OR C1.INPUT+1 > SCN1.NUMHITS
            COMMENT/OPER,NO,you have entered an illegal number. TRY AGAIN!
            GOTO/L1
            END_IF/
$$ NO,.
$$ NO,. Input the number of the feature set point you want to end at
$$ NO,.
L2         =LABEL/
$$ NO,.
C2         =COMMENT/INPUT,NO,"ENTER END POINT."
                            ,
                            ,"MUST BE BETWEEN " +C1.INPUT + " AND " +NHITS 
$$ NO,.
$$ NO,. Test value to be sure it is legal
$$ NO,.
            IF/C2.INPUT <= C1.INPUT 
            COMMENT/OPER,NO,you have entered an illegal number. TRY AGAIN!
            GOTO/L2
            END_IF/
            IF/C2.INPUT  > SCN1.NUMHITS
            COMMENT/OPER,NO,you have entered an illegal number. TRY AGAIN!
            GOTO/L2
            END_IF/
$$ NO,.
$$ NO,. V1 will be the position of the MAX POINT in the LIMITED feature set
$$ NO,.
            ASSIGN/V1 = MAXINDEX(SCN1.HIT[(C1.INPUT)..(C2.INPUT)].Z)
$$ NO,.
$$ NO,. V2 will be the position of the MAX POINT in the FULL feature set
$$ NO,.
            ASSIGN/V2 = C1.INPUT+V1
$$ NO,.
$$ NO,. V3 is used for the building of the generic point
$$ NO,.
            ASSIGN/V3 = "PNT"+V2
$$ NO,.
GEN_FEAT_1 =GENERIC/POINT,DEPENDENT,RECT,$
            NOM/XYZ,V3.TX,V3.TY,V3.TZ,$
            MEAS/XYZ,V3.X,V3.Y,V3.Z,$
            NOM/IJK,V3.TI,V3.TJ,V3.TK,$
            MEAS/IJK,V3.I,V3.J,V3.K
$$ NO,.
$$ NO,. To report the MAX POINT :
$$ NO,  Dimension any Feature
$$ NO,.
DIM LOC1= LOCATION OF POINT PNT10  UNITS=MM ,$
GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=NONE
AX       MEAS    NOMINAL       +TOL       -TOL        DEV     OUTTOL
Z      0.0063     0.0000     1.0000     1.0000     0.0063     0.0000
END OF DIMENSION LOC1
$$ NO,.
$$ NO,. Then you must change the name of the PNT that was dimensioned
$$ NO, In this example you must highlight PNT10 with the cursor and then change it to "PNT"+V2
$$ NO,.
DIM LOC2= LOCATION OF POINT "PNT"+V2  UNITS=MM ,$
GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=REPORT
AX       MEAS    NOMINAL       +TOL       -TOL        DEV     OUTTOL
Z      0.0961     0.0000     1.0000     1.0000     0.0961     0.0000
END OF DIMENSION LOC2
$$ NO,.
  • Well done, dph51!

    Personally, I am not a fan of having the code in the partprogram. I prefer to have a script that asks all the INPUT questions and generates the necessary code in the partprogram (making it totally transparent to the next user). Nevertheless, good job!

    Just my 2 SEK.