ZSK Web API

ZSK Web API

Needle assignment (SeqAssignmentJson)

SeqAssignmentJson assigns the color sequences of an existing design to thread cones. Cone k is stitched with needle k + 1. It is sent with CreateTC, CreateTBF and CreatePNG as a JSON string: serialize the object shown in the example and send the result as the value of SeqAssignmentJson.

EmbroideryTypeSeqAssignmentJson
DSTRequired. The DST color sequences get the needles and colors of their cones.
DSZRequired. The file is converted to DST first; the sequence indexes refer to the converted DST.
TCOptional, from ServerVersion 3. Every sequence of the Z00 design gets the needle of its cone, and the color table of the design is replaced by the cone definitions. The stitches are not changed.
TBFNot used.

CreateDST and CreateDSZ do not use SeqAssignmentJson.

Format
  • NeedleAssignment: object. Key: the cone index k ("0", "1" ...), a 0-based index into UsedConeDefs; the cone is stitched with needle k + 1. Value: array with the 0-based indexes of the sequences stitched with this cone.
  • UsedConeDefs: array with one cone definition per cone index. R, G and B (integers 0 to 255) are required. ColorNumber (integer), ColorName, Manufacturer and Name (thread type) are optional.
  • StartIndex: ignored. All indexes are 0-based.
DST and DSZ input

The sequence index is the 0-based index of the color sequence in the DST file (DSZ: in the converted DST).

TC input
  • Sequence index: the 0-based position in the list that GetNeedleSequence returns for the design with ServerVersion 3. Every needle change and every stop starts a new sequence.
  • Complete assignment: every sequence must be assigned to exactly one cone. UsedConeDefs must have an entry for every cone index in NeedleAssignment. The highest needle is 32 (cone index 31).
  • No assignment: if NeedleAssignment is missing or empty, the design is used unchanged.
  • Cone colors win: entry n of the Needle list is replaced by UsedConeDefs[n - 1], so text with UsedNeedle n also gets that cone color. "UseEmbroideryColors": 1 is ignored. With text, Needle can be omitted when every UsedNeedle refers to a cone.
  • Stops: if a sequence starts with a stop and gets a different cone than the sequence before it, a needle change is added after the stop. The NeedleSequence of the response then has one more entry than the GetNeedleSequence list of the input: the stop keeps the previous needle, and the added needle change starts the new one.
  • K-head: designs with K-head (Moos/Kettel) needles are rejected.

Example: GetNeedleSequence returns [7, 1, 24, 7, 2, 24] for a TC design, so it has the sequences 0 to 5. The example assigns sequences 0 and 3 to cone 0 (needle 1), sequences 1 and 4 to cone 1 (needle 2) and sequences 2 and 5 to cone 2 (needle 3). The created design uses the needles 1, 2, 3, 1, 2, 3 in the colors of the three cones. In the request:

"EmbroideryType": "TC",
"SeqAssignmentJson": "{\"NeedleAssignment\":{\"0\":[0,3],\"1\":[1,4],\"2\":[2,5]},\"UsedConeDefs\":[{\"R\":196,\"G\":30,\"B\":58,\"ColorNumber\":5566,\"ColorName\":\"radiant red\"},{\"R\":61,\"G\":142,\"B\":51,\"ColorNumber\":5540,\"ColorName\":\"kelly\"},{\"R\":234,\"G\":175,\"B\":15,\"ColorNumber\":5766,\"ColorName\":\"manila\"}]}"
Errors (TC input)

HTTP 400 with Success false and one of these texts in RequestData:

RequestDataCause
ApplyNasTC: Sequence 1 is not assigned to a coneA sequence of the design is missing in NeedleAssignment.
ApplyNasTC: Sequence 1 is assigned to more than one coneA sequence index is listed under more than one cone.
ApplyNasTC: Sequence index 6 is out of range; the TC design has 6 sequences (0..5)A sequence index is negative or not lower than the number of sequences.
ApplyNasTC: Invalid cone index 3 (no cone definition or needle > 32)A key of NeedleAssignment has no entry in UsedConeDefs, or it is negative or above 31.
ApplyNasTC: The NAS is not supported for TC designs with K-head (Moos/Kettel) needlesThe design uses K-head needles.
ApplyNasTC: Invalid NAS data ...SeqAssignmentJson is not a JSON object in the format above.
ApplyNasTC: Invalid TC data ... / ApplyNasTC: The TC design has no needle sequenceThe data cannot be read as TC, or it has no sequence.

Example

{
  "NeedleAssignment": {
    "0": [0, 3],
    "1": [1, 4],
    "2": [2, 5]
  },
  "UsedConeDefs": [
    { "R": 196, "G": 30, "B": 58, "ColorNumber": 5566, "ColorName": "radiant red", "Manufacturer": "A&E", "Name": "Robinson Anton" },
    { "R": 61, "G": 142, "B": 51, "ColorNumber": 5540, "ColorName": "kelly", "Manufacturer": "A&E", "Name": "Robinson Anton" },
    { "R": 234, "G": 175, "B": 15, "ColorNumber": 5766, "ColorName": "manila", "Manufacturer": "A&E", "Name": "Robinson Anton" }
  ]
}