Python Command: Inspection

The Inspection commands in Python let you modify a running inspection. This command only functions while a Formula test is running in a sub-inspection.

See Special Variables for Python variables that apply to Inspections.

See Python commands for other commands you can use with GainSeeker.

 

Syntax

Example

Description/Remarks

inspect.cursubi.addfile(label, path)

inspect.cursubi.addfile("item label", "C:\\Users\\myfile.txt")

Adds a file or image to the side panel after the Python script completes.

inspect.cursubi.addwebpage(label, url)

inspect.cursubi.addwebpage("item label", "www.google.com")

Adds a webpage to the side panel after the Python script completes.

inspect.cursubi.anchorpoint

inspect.cursubi.anchorpoint = True

Marks all SPC records on the current sub-inspection as an anchor point.

Gets or sets whether all SPC records on the current sub-inspection will be marked as an anchor point.

This property is initialized to False ("not an anchor point") when a sub-inspection is loaded and after a sub-inspection is submitted.

inspect.cursubi.cancel()

inspect.cursubi.cancel()

Cancels the current sub-inspection.

This is equivalent to clicking the Cancel button except that GainSeeker will not display the warning message about unsaved data being lost.

The inspection will advance properly based on the inspect.setnextsubi or inspect.setnextinspection commands.

inspect.cursubi.checkbox(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.checkbox(0).enabled = False

You can disable or enable a checkbox test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.checkbox(idx).gettrace(index)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.checkbox(0).gettrace(3)

Gets the value of traceability field 3 that was set for this test only by the inspect.cursubi.checkbox(0).settrace(3, value) command.

Gets the value of a traceability field that was set for this test only by the corresponding inspect.cursubi.checkbox(idx).settrace command.

inspect.cursubi.checkbox(idx).required

where idx is the TestID property of the test.

inspect.cursubi.checkbox(0).required = True

Sets the EntryRequired Checkbox test property to true.

Gets or sets the value of the EntryRequired Checkbox test property.

inspect.cursubi.checkbox(idx).settrace(index, value)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.checkbox(0).settrace(3, "E1403")

Sets traceability field 3 to "E1403" for this test only.

Sets the value of a traceability field for this test only.

Takes precedence over all other methods that might set this traceability value (e.g., value pre-filled by inspection or planned inspection, value entered by user, value set by other Python commands, test-specific properties that might set this traceability value, etc.).

Value is automatically cleared from the current traceability buffer after the sub-inspection is submitted or cancelled.

inspect.cursubi.checkbox(idx).value

where idx is the TestID property of the test.

inspect.cursubi.checkbox(0).value = True

Sets the checkbox test status to checked.

Gets or sets the check status of the test. True is checked, False is unchecked.

inspect.cursubi.clearsidepanel

inspect.cursubi.clearsidepanel = True

This clears the side panel in PC Collect.

Clears the side panel when the Python script finishes when set to True.

inspect.cursubi.datetime(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.datetime(0).enabled = False

You can disable or enable a Date Time test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.defectlist(idx).defects

where idx is the TestID property of the test.

inspect.cursubi.defectlist(0).defects = ["Broken", "Burned"]

Sets the available defects in the Defect List to "Broken" and "Burned".

Gets or sets defect names in the Defect List.

Any defect names that do not exist in GainSeeker will be ignored.

inspect.cursubi.defectlist(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.defectlist(0).enabled = False

You can disable or enable a Defect List test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.defectlist(idx).gettrace(index)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.defectlist(0).gettrace(3)

Gets the value of traceability field 3 that was set for this test only by the inspect.cursubi.defectlist(0).settrace(3, value) command.

Gets the value of a traceability field that was set for this test only by the corresponding inspect.cursubi.defectlist(idx).settrace command.

inspect.cursubi.defectlist(idx).getvalue(index)

where idx is the TestID property of the test and where index is the index of the defect in the list of defects for the test.

print inspect.cursubi.defectlist(0).getvalue(0)

Prints the count of the first defect in the Defect List.

Returns the count of the defect at the specified index, with 0 being the first defect in the Defect List.

inspect.cursubi.defectlist(idx).ncu

where idx is the TestID property of the test.

print inspect.cursubi.defectlist(0).ncu = 2

Sets the number of non-conforming units of the test to 2.

Gets or sets the non-conforming units of the Defect List.

inspect.cursubi.defectlist(idx).note

where idx is the TestID property of the test.

inspect.cursubi.defectlist(0).note = "My note"

Sets the note for this test.

Gets or sets the note for this Defect List test.

inspect.cursubi.defectlist(idx).overrideprocess

where idx is the TestID property of the test.

inspect.cursubi.defectlist(0).overrideprocess = "B-Mixing"

Sets the Defects property to use the process "B-Mixing" for displaying defects and storing data for this test.

Gets or sets the portion of the Defects property that uses a specific Process for displaying defects and storing data for this Defect List test - regardless of the Process set for the Inspection (or Planned Inspection).

inspect.cursubi.defectlist(idx).samplesize

where idx is the TestID property of the test.

print inspect.cursubi.defectlist(0).samplesize = 5

Sets the sample size of the test to 5.

Gets or sets the sample size of the Defect List.

inspect.cursubi.defectlist(idx).settrace(index, value)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.defectlist(0).settrace(3, "E1403")

Sets traceability field 3 to "E1403" for this test only.

Sets the value of a traceability field for this test only.

Takes precedence over all other methods that might set this traceability value (e.g., value pre-filled by inspection or planned inspection, value entered by user, value set by other Python commands, test-specific properties that might set this traceability value, etc.).

Value is automatically cleared from the current traceability buffer after the sub-inspection is submitted or cancelled.

inspect.cursubi.defectlist(idx).setvalue(index, value)

where idx is the TestID property of the test and where index is the index of the defect in the list of defects for the test.

inspect.cursubi.defectlist(0).setvalue(0, 5)

Sets the count of the first defect to 5 in the Defect List.

Sets the count of the defect at the specified index to the count of value, with 0 being the index of the first defect.

inspect.cursubi.dmspart(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.dmspart(0).enabled = False

You can disable or enable a DMS Standard test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.dmspart(idx).partnumber

where idx is the TestID property of the test.

inspect.cursubi.dmspart(0).partnumber = "A-50 INSERT"

Gets or sets the DMS part number displayed on this test. This property has the same behavior as interactively setting a value in this test.

To clear any existing value from this test, set this to None.

inspect.cursubi.gettesttype(idx)

where idx is the TestID property of the test.

print inspect.cursubi.gettesttype("machine")

Finds the test where TestID = "machine" and returns the corresponding type of test (such as "TRACEABILITY").

Returns the type of test that corresponds to the specified TestID.

For a test type that cannot be modified by Python commands (such as Formula, Timer, or Line Break), this will return None.

Otherwise, this command returns one of the following strings:

"NUMERICINPUT"

"DATETIME"

"TRACEABILITY"

"PASSFAIL"

"CHECKBOX"

"DEFECTLIST"

"DMSSTANDARD"

"TEXT"

See also:

inspect.cursubi.testidlist

inspect.cursubi.ni(idx).rtfvalue

inspect.cursubi.name

print inspect.cursubi.name

Returns the name of the current sub-inspection.

inspect.cursubi.ni(idx).celllabels

where idx is the TestID property of the test.

inspect.cursubi.ni(idx).celllabels = ["Cavity 1", "Cavity 2", "Cavity 3"]

Gets/Sets the list of labels to display for individual data cells in the Numeric Input test, such as the default list ["Data 1", "Data2", etc.] or a custom list like ["Cavity 1", "Cavity 2", etc.] .

inspect.cursubi.ni(idx).deviceprofile

where idx is the TestID property of the test.

inspect.cursubi.ni(0).deviceprofile = "Acme Caliper on Com Port 3"

Gets/Sets the device profile currently associated with the numeric input test, None if keyboard entry.

inspect.cursubi.ni(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.ni(0).enabled = False

You can disable or enable a Numeric Input test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.ni(idx).gettrace(index)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.ni(0).gettrace(3)

Gets the value of traceability field 3 that was set for this test only by the inspect.cursubi.ni(0).settrace(3, value) command.

Gets the value of a traceability field that was set for this test only by the corresponding inspect.cursubi.ni(idx).settrace command.

inspect.cursubi.ni(idx).label

where idx is the TestID property of the test.

inspect.cursubi.ni("length").label = "Enter Length data"

inspect.cursubi.ni("weight").label = None

Gets or sets the Label property of this Numeric Input test.

Use None for a blank Label property.

inspect.cursubi.ni(idx).labelabovecell

where idx is the TestID property of the test.

inspect.cursubi.ni("weight").labelabovecell = True

If set to True, turns on the display of cell labels (Data 1, Data 2, etc., or custom labels set by inspect.cursubi.ni(idx).celllabels) above every cell. The larger Subgroup message will still be displayed above these cell labels.

Defaults to False.

inspect.cursubi.ni(idx).note

where idx is the TestID property of the test.

inspect.cursubi.ni(0).note = "My note"

Sets the note associated with this test.

Gets or sets the note associated with this numeric input test.

inspect.cursubi.ni(idx).novaluemode

where idx is the TestID property of the test.

inspect.cursubi.ni("length").novaluemode = 2

Set the "No Value Mode" for this test to "DoNotStore".

Gets or sets the NoValue property for this numeric input test.

0 = RequireEntry, 1 = StoreSentinel, and 2 = DoNotStore.

inspect.cursubi.ni(idx).partno

where idx is the TestID property of the test.

inspect.cursubi.ni(0).partno = "Temp 1250"

Sets the part number associated with this test.

Gets or sets the part number associated with this numeric input test.

inspect.cursubi.ni(idx).rtfvalue

where idx is the TestID property of the test.

x = inspect.cursubi.ni(7).rtfvalue & 1024

if x == 1024:

print "Data above spec"

Prints a message if the Numeric Input test with TestID 7 failed the Upper Spec Limit.

Returns a number representing the combined real-time failures for the specified Numeric Input test.

For a reference of the failures represented by the returned number, see Real-time Failure codes.

See also:

inspect.cursubi.gettesttype(idx)

inspect.cursubi.testidlist

inspect.cursubi.ni(idx).search

where idx is the TestID property of the test.

inspect.cursubi.ni(0).search = "Temp"

Sets the SPCStandardSearchString Numeric Input test property associated with this test.

Gets or sets the SPCStandardSearchString associated with this numeric input test.

inspect.cursubi.ni(idx).settrace(index, value)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.ni(0).settrace(3, "E1403")

Sets traceability field 3 to "E1403" for this test only.

Sets the value of a traceability field for this test only.

Takes precedence over all other methods that might set this traceability value (e.g., value pre-filled by inspection or planned inspection, value entered by user, value set by other Python commands, test-specific properties that might set this traceability value, etc.).

Value is automatically cleared from the current traceability buffer after the sub-inspection is submitted or cancelled.

inspect.cursubi.ni(idx).subgroupcomplete

where idx is the TestID property of the test.

inspect.cursubi.ni(idx).subgroupcomplete

Checks whether all fields in the subgroup have been filled with either a number or * (missing data value). Returns True if subgroup is complete and False if any of the fields in the subgroup are empty.

inspect.cursubi.ni(idx).subgroupsize

where idx is the TestID property of the test.

print inspect.cursubi.ni(0).subgroupsize

Prints the subgroup size of the test.

Gets the subgroup size associated with this numeric input test.

If the SPCStandardSelection property of the Numeric Input test is set to DoNotStore, you can use this command to set the subgroup size (number of input boxes) for this Numeric Input test. Common practice is to execute this type of command in a Formula test with the FormulaMode property set to Pre.

Selecting the SPC standard ("part number") for the numeric input test will reset the subgroup size to the value in the standard.

inspect.cursubi.ni(idx).values

where idx is the TestID property of the test.

inspect.cursubi.ni(0).values = [2.5, 12.4]

Sets the values associated with this test.

Gets or sets the values of each cell of this numeric input test as a list. The list length must match the number of cells in the test. Use None to clear the cell.

inspect.cursubi.ni(idx).visible

where idx is the TestID property of the test.

inspect.cursubi.ni("Length").visible = False

 

if inspect.cursubi.ni(0).visible == True:
  inspect.cursubi.text(4).text = "Begin test."

This command gets or sets the visible status of the specified numeric input test - when running either an inspection or a planned inspection. When the sub-inspection is submitted, no data will be stored for a numeric input test that is hidden.

If a planned inspection sets the numeric input test to be hidden, using this command to make this test visible will not display any charts configured for this test.

If the numeric input test is not hidden by a planned inspection, and the SPC standard has been set by either the inspection or a planned inspection, using this command to hide this test will not hide any charts configured for this test. This is true even if the command is triggered by a Pre script.

inspect.cursubi.note

inspect.cursubi.note = "My note"

Gets or sets the current sub-inspection note.

inspect.cursubi.passfail(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.passfail(0).enabled = False

You can disable or enable a Pass/Fail/NA test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.passfail(idx).gettrace(index)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.passfail(0).gettrace(3)

Gets the value of traceability field 3 that was set for this test only by the inspect.cursubi.passfail(0).settrace(3, value) command.

Gets the value of a traceability field that was set for this test only by the corresponding inspect.cursubi.passfail(idx).settrace command.

inspect.cursubi.passfail(idx).note

where idx is the TestID property of the test.

inspect.cursubi.passfail(0).note = "My note"

Sets the note for the test.

Gets or sets the note for the Pass/Fail/NA test.

inspect.cursubi.passfail(idx).settrace(index, value)

where idx is the TestID property of the test

and index is the traceability field number.

inspect.cursubi.passfail(0).settrace(3, "E1403")

Sets traceability field 3 to "E1403" for this test only.

Sets the value of a traceability field for this test only.

Takes precedence over all other methods that might set this traceability value (e.g., value pre-filled by inspection or planned inspection, value entered by user, value set by other Python commands, test-specific properties that might set this traceability value, etc.).

Value is automatically cleared from the current traceability buffer after the sub-inspection is submitted or cancelled.

inspect.cursubi.passfail(idx).value

where idx is the TestID property of the test.

inspect.cursubi.passfail(0).value = 1

Sets the test to "Fail".

Gets or sets the status of the Pass/Fail/NA test. 0 is Pass, 1 is Fail, and 2 is N/A (if enabled). If no option is selected, the value is -1.

inspect.cursubi.selectsidepanelitem(item)

inspect.cursubi.selectsidepanelitem("Flowchart")

Brings the document or image labeled "Flowchart" to the front.

 

inspect.cursubi.selectsidepanelitem(1)

Brings to the front whatever document or image is second from the right.

Brings the specified document or image to the front.

Item must be one of these:

  • The label for the image or thumbnail text for the document (entered as a string)

  • A number that corresponds to the order in which items were added to the side panel, from last/right-most to first/left-most, starting at 0.

    For example: on a panel with four documents/images, the fourth (right-most) item is number 0, the third is number 1, the second is number 2, and the first (left-most) is number 3.

inspect.cursubi.submit()

inspect.cursubi.submit()

This is equivalent to the user pressing the submit button, which triggers upon completing the current Python script. Submission fails if there are errors within the current sub-inspection.

inspect.cursubi.testidlist

inspect.cursubi.testidlist

Returns an unordered list of the TestIDs for the tests in the current sub-inspection.

See also:

inspect.cursubi.gettesttype(idx)

inspect.cursubi.ni(idx).rtfvalue

inspect.cursubi.text(idx).text

where idx is the TestID property of the test.

inspect.cursubi.text(0).text = "Please follow instructions."

Gets or sets the text for the Text test.

inspect.cursubi.timer(idx).value

where idx is the TestID property of the test.

inspect.cursubi.timer(0).value

Gets the current value of the Timer test.

inspect.cursubi.trace(idx).enabled

where idx is the TestID property of the test.

inspect.cursubi.trace(0).enabled = False

You can disable or enable a Traceability test in a running inspection. The value of the test can be set through Python code, regardless of whether it is enabled or disabled.

If the test is required, but disabled, and there is no value, the sub-inspection information cannot be submitted. The default is True.

inspect.cursubi.trace(idx).label

where idx is the TestID property of the test.

inspect.cursubi.trace(0).label = "Enter your 4-digit employee number:"

Gets or sets the label displayed to the user for a Traceability test.

inspect.cursubi.trace(idx).list

where idx is the TestID property of the test.

inspect.cursubi.trace(0).list = ["Machine 1", "Machine 2", "Machine3"]

Sets three values that can be selected by the operator.

inspect.cursubi.trace("SKUs").list = traceability.getprioritylist(6)

Changes the drop-down list for a traceability test with the Test ID "SKUs" to the priority list set up for traceability field 6 for the current GainSeeker user.

Gets or sets the list of items the operator can select for the Traceability test.

inspect.cursubi.trace(idx).required

where idx is the TestID property of the test.

inspect.cursubi.trace(0).required = True

Sets the EntryRequired Traceability test property to true.

Gets or sets the value of the EntryRequired Traceability test property.

inspect.cursubi.trace(idx).value

where idx is the TestID property of the test.

inspect.cursubi.trace(0).value = "Machine 1"

This sets the value of the traceability to "Machine 1"

Gets or sets the value of the Traceability test.

inspect.datetime

inspect.datetime = "3/4/2015 13:45"

print inspect.datetime

Gets or sets the datetime for the inspection. This does not affect a Date/Time test on the current sub-inspection.

inspect.dmspartnumber

inspect.dmspartnumber = "My part"

print inspect.dmspartnumber

Gets or sets the DMS part number associated with the inspection.

Setting this property will not update any tests on the current sub-inspection.

inspect.gettracevalue(index)

print inspect.gettracevalue(2)

Prints the traceability value for trace 2.

Returns the value of the specified traceability.

inspect.messagearea.color

inspect.messagearea.color = "Red"

Sets the sub-inspection message area background color to Red.

inspect.messagearea.color = "#00FF00"

Sets the sub-inspection message area background color to Lime.

Gets or sets the background color for the sub-inspection message area.

The sub-inspection message area is the blank space next to the Cancel button at the bottom of the sub-inspection. (This area is larger if the PictureMode and VideoMode properties for the sub-inspection are both Off.)

You may specify the color's rgb (hex) value or its colorname. (For a full list of colornames - such as "red", "orange", "yellow", "green", "blue", "white", and many more - see https://www.colorcodehex.com/html-color-names.html or http://cng.seas.rochester.edu/CNG/docs/x11color.html.) The text color is always black, so best practice is to avoid a dark color for the background.

To clear the background color, set this to None or a blank string.

This will persist across sub-inspections and inspections until the list of sub-inspections or inspections is displayed.

inspect.messagearea.text

inspect.messagearea.text = "Sample passed all tests"

Displays the specified text string in the sub-inspection message area.

Gets or sets the text string for display in the sub-inspection message area.

The sub-inspection message area is the blank space next to the Cancel button at the bottom of the sub-inspection. (This area is larger if the PictureMode and VideoMode properties for the sub-inspection are both Off.)

GainSeeker will dynamically size the font so that the entire text string is displayed.

To clear the text string, set this to None or a blank string.

This will persist across sub-inspections and inspections until the list of sub-inspections or inspections is displayed.

inspect.name

print inspect.name

Returns the name of the inspection.

inspect.persist["mykey"]

This first line of code is executed in one inspection:

inspect.persist["name"] = "Bob"

This second line of code is executed in another inspection:

print inspect.persist["name"]

The value printed on the second line should be "Bob"

Note: "mykey" is case sensitive. "Name" and "name" would not produce the same results.

Stores values between inspections. Variables are normally kept for the lifetime of a running inspection, so any information that must be passed between inspections may be stored using inspect.persist.

Note: any data stored is not saved after the Inspection Viewer window closes.

inspect.process

print inspect.process

Returns the Process property for the inspection.

inspect.setnextinspection(name, isPlannedInspection)

inspect.setnextinspection("Final Inspection")

This navigates the user to the specified inspection ("Final Inspection") upon submission.

inspect.setnextinspection("SKU 1400 Final Inspection", True)

This navigates the user to the specified planned inspection ("SKU 1400 Final Inspection") upon submission.

inspect.setnextinspection(None)

This navigates the user to the list of inspections upon submission

Directs the user to a specific inspection or planned inspection after the current sub-inspection is submitted.

  • To go to an Inspection, set name to an Inspection name and either omit the isPlannedInspection argument or set it to False.

  • To go to a Planned Inspection, set name to a Planned Inspection name and set isPlannedInspection to True.

  • Set the name to None to navigate back to the list of inspections.

inspect.setnextsubi(name)

inspect.setnextsubi("sub-inspection name")

This navigates the user to the specified sub-inspection upon submission.

inspect.setnextsubi(None)

This navigates the user to the list of sub-inspections upon submission.

Directs the user to a specific sub-inspection after the current sub-inspection is submitted. Set to None to navigate back to the list of sub-inspections. Overrides the AutoAdvance inspection property.

inspect.settracevalue(index, value)

inspect.settracevalue(5, "Machine 345")

This sets traceability 5 to "Machine 345".

Sets the value of the specified traceability. This does not affect any Traceability tests on the current sub-inspection.

inspect.shutdown()

inspect.shutdown()

Closes the PC Collect module and immediately stops execution of the script.

If executed by a Formula test with the FormulaMode property set to Post - which executes the formula after the data for the sub-inspection is submitted - the data will be submitted before the PC Collect module is closed.

inspect.storerecords

inspect.storerecords = False

Disables automatic storage of data records when the user Submits the current sub-inspection.

Disables or enables automatic storage of data records when the user Submits the current sub-inspection.

Set to False to disable automatic storage or True to (re-)enable automatic storage. Opening each sub-inspection automatically resets this to True.

This lets you create a sub-inspection where the user enters information on the sub-inspection, but you read the data they entered and then use other Python commands to create and store whatever records you need.

See also: datadms, dataspc

inspect.uniqueid

print inspect.uniqueid

Returns the unique ID for this inspection.

inspect.update()

inspect.update()

A Python script that is programmed to change any part of the displayed inspection window will not actually update the display until the script completes.

You can use this command to force an update of the displayed inspection window during script execution.