hexagon logo

Code Examples

I thought I might have a thread where anyone who wishes can post codes with a description of what it does. I know this code might be basic and even able to be written more efficiently but as I am new to this code stuff I just thought I would try.
COMMENT/REPT,
            CODE1 auto file and print on out tol, Promps
            opperator for print if in tol.
            ASSIGN/V1=GETPROGRAMINFO("NUMOOT","")
            IF/V1>"0"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=1,$
              TO_PRINTER=ON,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            IF/V1=="0"
C1         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            No features are out of tolerence, would you like to
            print this report?
            END_IF/
            IF/C1.INPUT=="YES"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=1,$
              TO_PRINTER=ON,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            IF/C1.INPUT=="NO"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=1,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=OFF,AUTO=1,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
$$ NO,
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$$ NO,
            CODE2 will print the report on any OOT.......
            ASSIGN/V2=GETPROGRAMINFO("NUMOOT","")
            IF/V2>"0"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=1,$
              TO_PRINTER=ON,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            IF/V2=="0"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=1,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=OFF,AUTO=1,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
$$ NO,
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$$ NO,
            CODE 3 Prompt to file, prompt to print
C3         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            Check report before saving.
            Would you like to save this report?
            IF/C3.INPUT=="YES"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=ON,AUTO=603,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
C4         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            Would you like to print this report
            IF/C4.INPUT=="YES"
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=OFF,AUTO=1,$
              TO_PRINTER=ON,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
            END_IF/
            PRINT/REPORT,EXEC MODE=END,$
              TO_FILE=OFF,AUTO=1,$
              TO_PRINTER=OFF,$
              TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
              REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
              PREVIOUS_RUNS=DELETE_INSTANCES
I have placed three codes here the first two will only work with new versions of pc-dmis because of the ASSIGN/V2=GETPROGRAMINFO("NUMOOT","") command only exists in new versions of pc-dmis.
  • This on converts a major diameter a minor diameter and a distance and converts it to taper per foot
    ASSIGN/MINDIAMEAS=LOC1.D.MEAS
                ASSIGN/MAXDIAMNOM=LOC2.D.MEAS
                ASSIGN/DISTMEAS=LOC3.Z.MEAS
                ASSIGN/VTPFMEAS=TAN(MAXDIAMNOM-MINDIAMEAS/DISTMEAS)*6
    F1         =GENERIC/NONE,DEPENDENT,CARTESIAN,OUT,$
                NOM/XYZ,<-9.32389,-4.81397,17.7668>,$
                MEAS/XYZ,<0,0,0>,$
                NOM/IJK,<0.00067,0.00013,0.9999998>,$
                MEAS/IJK,<0,0,1>,$
                RADIUS/0,0,$
                ANGLE/0,VTPFMEAS,$
                DISTANCE/0,0
    DIM TAPER/FOOT= LOCATION OF PLANE F1  UNITS=IN ,$
    GRAPH=OFF  TEXT=OFF  MULT=1000.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX       MEAS    NOMINAL       +TOL       -TOL        DEV     OUTTOL
    A      1.90879    1.78986    0.10000    0.10000    0.11893    0.01893 -------->
                END OF DIMENSION TAPER/FOOT
  • There is a separate sub-forum for posting code examples.
  • I found it once but I have been un-able to locate it again.
  • Also, maybe one example per thread? Seems easier to maintain with regards to replies and forum searches...
  • I have been searching past threads and cannot seem to locate anything on or if there is a code for GETPROGRAMINFO("NUMOOT","") in ver 2011MR1?
  • I am attempting to use giantslayer's code from thread #1 (Code1) and of course it does not work in 2011MR1.
    Is there a similar way to accomplish this with code that my version will read?
  • I thought I might have a thread where anyone who wishes can post codes with a description of what it does. I know this code might be basic and even able to be written more efficiently but as I am new to this code stuff I just thought I would try.
    COMMENT/REPT,
                CODE1 auto file and print on out tol, Promps
                opperator for print if in tol.
                ASSIGN/V1=GETPROGRAMINFO("NUMOOT","")[COLOR="#FF0000"]Would someone know what the code for this option is in 2011MR1?[/COLOR]
                IF/V1>"0"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=1,$
                  TO_PRINTER=ON,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                IF/V1=="0"
    C1         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                No features are out of tolerence, would you like to
                print this report?
                END_IF/
                IF/C1.INPUT=="YES"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=1,$
                  TO_PRINTER=ON,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                IF/C1.INPUT=="NO"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=1,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=OFF,AUTO=1,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
    $$ NO,
                xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    $$ NO,
                CODE2 will print the report on any OOT.......
                ASSIGN/V2=GETPROGRAMINFO("NUMOOT","")
                IF/V2>"0"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=1,$
                  TO_PRINTER=ON,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                IF/V2=="0"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=1,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=OFF,AUTO=1,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
    $$ NO,
                xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    $$ NO,
                CODE 3 Prompt to file, prompt to print
    C3         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Check report before saving.
                Would you like to save this report?
                IF/C3.INPUT=="YES"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,AUTO=603,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
    C4         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Would you like to print this report
                IF/C4.INPUT=="YES"
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=OFF,AUTO=1,$
                  TO_PRINTER=ON,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
                END_IF/
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=OFF,AUTO=1,$
                  TO_PRINTER=OFF,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  PREVIOUS_RUNS=DELETE_INSTANCES
    I have placed three codes here the first two will only work with new versions of pc-dmis because of the ASSIGN/V2=GETPROGRAMINFO("NUMOOT","") command only exists in new versions of pc-dmis.

    Also having problems with having multiple print options.It basically is ignoring what is in the edit window and will only do what is in the File>Printing>ReportWindowPrintOptions.
  • most likely a basic script that would go through the program looking for the number of OOT dimensions. There should be examples of this type of thing somewhere in the forum.