Sepasoft MES Module Suite
getNewByDefUUID(...)
Creates and returns a new SPC sample from an existing sample definition UUID. The new sample is initialized for the MES location identified by the supplied location path, including measurement structure from the definition.
Syntax
Python |
system.mes.spc.sample.getNewByDefUUID(defUUID, locationPath) |
Parameters
Parameter | Type | Required | Description |
|---|---|---|---|
defUUID | String | Required | UUID 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 defUUID 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 getNewByDefUUID.
Available from Gateway scripts and from Designer / Client script contexts through the Quality RPC layer.
Legacy SPC 2.0 API: system.quality.sample.data.getNewByDefUUID() exposes the same behavior (including an optional projectName overload). Prefer system.mes.spc.sample on new scripts.
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. Use getCreateByDefUUID() when a workflow may return an existing sample by UUID or create a new one.
Blank inputs: If defUUID or locationPath is blank, the function returns None without attempting sample creation.
Invalid location path: locationPath must resolve to an MES location. An invalid path raises an exception on the gateway (for example, Location path (...) not found).
Invalid sample definition: defUUID must match an existing sample definition; otherwise creation fails with an error such as Sample Def UUID of (...) could not be found.
Location not allowed for definition: The location must be configured as an allowed location on the sample definition; otherwise creation fails with an error indicating the location is not valid for that definition.
Licensing: The target location must be licensed for the Quality module; unlicensed locations cause creation to fail.
Example Usage
Minimal example
Python |
sample = system.mes.spc.sample.getNewByDefUUID( "8f6f2c8d-7dc8-4dd5-8d1f-1f3c8d9e9a01", "Enterprise\\Site\\Area\\Line 1" ) |
Complex example
Python |
defUUID = "8f6f2c8d-7dc8-4dd5-8d1f-1f3c8d9e9a01" locationPath = "Enterprise\\Site\\Area\\Line 1" sample = system.mes.spc.sample.getNewByDefUUID(defUUID, locationPath) if sample is None: raise ValueError("Unable to create the requested SPC sample.") sample.setRefNo("WO-100145") sample.setProductCode("FG-100") sample.setSampleData(1, "Weight", 12.4) system.mes.spc.sample.update(sample, True) |
Related Functions
system.mes.spc.sample.getNewByDefName() — Creates a new sample from a sample definition name and location path.
system.mes.spc.sample.getCreateByDefUUID() — Returns an existing sample when a sample UUID is supplied, or creates a new sample from a sample definition UUID.
system.mes.spc.sample.getSample() — Returns an existing sample by UUID.
system.mes.spc.sample.update() — Persists changes to a sample and optionally records values.
Sepasoft MES Module Suite