system.mes.spc.sample.getNewByDefName(defName, locationPath)

Sepasoft MES Module Suite

getNewByDefName(...)

Creates and returns a new SPC sample from an existing sample definition name. The new sample is initialized for the MES location identified by the supplied location path. 

Syntax

Python
system.mes.spc.sample.getNewByDefName(defName, locationPath)

Parameters

Parameter

Type

Required

Description

defName

String

Required

Name of the existing sample definition to use when creating the sample.

locationPath

String

Required

Equipment path for the MES location where the sample is initialized.

Return Value

Type

Description

CommonSample / QualitySample

A new sample based on defName and locationPath. Returns None when either parameter is blank in the current system.mes.spc.sample API.

Scope / Availability

  • Registered on the system.mes.spc.sample script module as getNewByDefName.

  • Available from Gateway scripts and from Designer / Client script contexts through the Quality RPC layer.

Behavior / Edge Cases

  • New sample creation: The function creates a new sample every time both inputs are valid; it does not look up or reuse an existing sample.

  • Blank inputs: If defName or locationPath is blank, the function returns None without attempting sample creation.

Example Usage

Minimal Example

Python
sample = system.mes.spc.sample.getNewByDefName(
	"Finished Good Weight",
	"Enterprise\\Site\\Area\\Line 1"
)

Complex Examples

Python
defName = "Finished Good Weight"
locationPath = "Enterprise\\Site\\Area\\Line 1"

sample = system.mes.spc.sample.getNewByDefName(defName, locationPath)

if sample is None:
	raise ValueError("Unable to create the requested SPC sample.")

sample.setRefNo("WO-100145")
sample.setProductCode("FG-100")
sample.getSampleData(1, "Weight").setAttrValue(12.4)

system.mes.spc.sample.update(sample, True)


Python
locationPath = 'Enterprise\El Dorado Hills\Test\location1'
defName = 'ManualSingleMeasurement'
sample = system.mes.spc.sample.getNewByDefName(defName, locationPath)
sample.setScheduledStart(system.date.now())
system.mes.spc.sample.update(sample, False)

Related Functions




Sepasoft MES Module Suite