Jump to content

loadCADFile() not working


---
 Share

Recommended Posts

I took out the actual Part Numbers to avoid leaking any sensitive data. 

The PCM File runs fine except for the loadCADFile() function. when trying to compute it on its own it returns 0 shown in the attached picture.

 

Any help would be greatly appreciated.

Mike

 

// IGVAPCM.txt
//variable named 'paramFile' is equal to the actual .para file name
// Then 'fileExists' checks if the .para file is in the program's directory then reads(readPCMFile()) it if its there.

paramFile = "PARAMETER.para"
if fileExists(paramFile)
    readPCMFile(paramFile)

else // If file isnt there, this writes the file to the programs directory
    addToFile("PARAMETER.para","RH = getRecordHead("u_field1")") // part number header
    addToFile("PARAMETER.para","ORH = getRecordHead("planid")") // plan/program id header
    addToFile("PARAMETER.para","DWGREV = getRecordHead("u_field2")") // drawing revision header
    addToFile("PARAMETER.para","MNAME  = getRecordHead("operid")") // machine/operator name
    addToFile("PARAMETER.para","MAT = getRecordHead("u_field4")") // takes into account the material being used
endif

// Main selection / confirmation loop starts here.
// The repeat...until loop will keep asking until exitLoop becomes true.
repeat

        PART = inquireList("Select the correct Program Number","ZA3657","ZA3658")

       validSelection = false // reset the flag for this loop iteration
    
    fileExists("ZA3657CAD.sat")
    fileExists("ZA3658CAD.sat")
       clearCAD()
       setCoordSysVisible(true)
    // --- PART-specific cases ---

    if PART == "ZA3657"
       loadCADFile("ZA3657CAD.sat")    
        setRecordHead("planid",  "ZA3657_PARTNO_002_OP40")
        setRecordHead("u_field9", "ZA3657_PARTNO_002_OP40")
        setRunID("ZA3657") // runs the named mini-plan
       validSelection = true
    endif
  if PART == "ZA3658"
       loadCADFile("ZA3658CAD.sat")
        setRecordHead("planid",  "ZA3658_PARTNO_002_OP40")
        setRecordHead("u_field9", "ZA3658_PARTNO_002_OP40")
        setRunID("ZA3658") // runs the named mini-plan
       validSelection = true
    endif
    
    wait(10)
    redrawCAD()
    setFit()

    // If no valid PART matched (user canceled or selected an unexpected value), show a message
    if validSelection == false
        message("No valid selection. Please select a part or check automation headers.")
       endInspection()
    else
        // Refresh header variables so the next steps use what we just set
        RH     = getRecordHead("u_field1")     // part number we set above
        ORH    = getRecordHead("planid")      // program/plan id we set above
        DWGREV = getRecordHead("u_field2")     // drawing / revision read back
        MAT = getRecordHead("u_field4") // FIX: ensure the header key is a string
       
            // Ask the operator to confirm the displayed metadata before starting
            exitLoop = confirm("ARE THESE VALUES CORRECT?", cr(),"PART NUMBER: ", RH, cr(),"PROGRAM NUMBER: ", ORH, cr(),"REVISION: ", DWGREV)
            // confirm returns true if operator clicks Yes/OK

    endif
until exitLoop == true

Screenshot 2026-06-11 093008.png

Link to comment
Share on other sites

 Share

×
×
  • Create New...