## OCODoc(name)

An Open Cut-Out character or meta-rig document.
Constructor

#### # new OCODoc(name)

Creates a new OCO Document.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | `string` | The name of the character or the meta rig

View Source DuAEF_Duik_api.jsxinc, line 15109

# Members

Type: `Array.<float>`

#### # static centerOfMass

The coordinates of the center of mass of the character. [X, Y].

View Source DuAEF_Duik_api.jsxinc, line 15139

Type: `float`

#### # static height

The height of the character. Should always be 1!

View Source DuAEF_Duik_api.jsxinc, line 15125

Type: `string`

#### # static name

The name of this OCO Doc

View Source DuAEF_Duik_api.jsxinc, line 15118

Type: `string`

#### # static type

The type of this OCO Doc

View Source DuAEF_Duik_api.jsxinc, line 15111

Type: `float`

#### # static width

The width of the character.

View Source DuAEF_Duik_api.jsxinc, line 15132

Type: `string`

#### # icon

An icon or thumbnail path

View Source DuAEF_Duik_api.jsxinc, line 15172

Type: `OCO.ImageEncoding`

#### # imageEncoding

How images should be encoded when exporting the doc to a file/folder

View Source DuAEF_Duik_api.jsxinc, line 15177

Type: `float`

#### # pixelsPerCm

The definition

View Source DuAEF_Duik_api.jsxinc, line 15167

Type: `Array.<int>`

#### # resolution

The resolution, in pixels, of the document

View Source DuAEF_Duik_api.jsxinc, line 15157

Type: `Array.<float>`

#### # world

The world origin in pixels in the document

View Source DuAEF_Duik_api.jsxinc, line 15162

# Methods

#### # static extractIcon(file, destinationopt) → {File}

Extracts the icon from the OCO file

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`file` | `string` | `File` |  | The OCO file
`destination` | `string` | `File` | <optional> | The destination file if the file is included in the OCO file. Next to the OCO file by default.

View Source DuAEF_Duik_api.jsxinc, line 16635

Returns:
The icon file, or null if there was no icon/the file could not be written.
Type: `File`

#### # static fromComp(nameopt, compopt, layersopt, characterTopopt, characterCenterOfMassopt, groundopt, heightopt) → {DoOCODoc}

Creates an OCO doc from the given composition.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`name` | `string` | <optional> |  | The name of the character. If omitted, will use the comp name.
`comp` | `CompItem` | <optional> | DuAEProject.getActiveComp() | The composition
`layers` | `Array.<Layer>` | <optional> | Duik.Bone.get(false) | The layers to include as bones in the doc
`characterTop` | `float` | <optional> |  | The max Y coordinate of the character, in px in the comp
`characterCenterOfMass` | `Array.<float>` | <optional> |  | The coordinates of center of mass of the character, in px in the comp
`ground` | `float` | <optional> |  | The Y coordinate of the ground, in px in the comp
`height` | `float` | <optional> | 185 | The height of the character, in cm

View Source DuAEF_Duik_api.jsxinc, line 35448

Returns:
The new doc
Type: `DoOCODoc`

#### # static fromFile(file) → {OCODoc|null}

Creates a new doc by reading a file

##### Parameters:

Name | Type | Description
--- | --- | ---
`file` | `File` | `string` | The file

View Source DuAEF_Duik_api.jsxinc, line 16662

Returns:
The document or null if the file couldn't be read or parsed
Type: `OCODoc` | `null`

#### # static zBounds() → {Array.<int>}

Finds the maximum and minimum Z index from all bones

View Source DuAEF_Duik_api.jsxinc, line 16616

Returns:
The [min, max] Z indices
Type: `Array.<int>`

#### # bounds() → {Array.<float>}

Gets the boundaries of the doc

View Source DuAEF_Duik_api.jsxinc, line 15243

Returns:
[left, top, right, bottom]
Type: `Array.<float>`

#### # fromPixels(point) → {Array.<float>|float}

Converts coordinates in pixels in the world to centimeters coordinates in the doc
For multidimensionnal values (coordinates), the origin is adjusted image to doc.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | `Array.<float>` | `float` | The coordinate to convert

View Source DuAEF_Duik_api.jsxinc, line 16488

Returns:
The coordinates in centimeters relative to the doc
Type: `Array.<float>` | `float`

#### # getBones() → {Array.<OCOBone>}

Gets all the bones sorted by z index

View Source DuAEF_Duik_api.jsxinc, line 16581

Returns:
The list of bones
Type: `Array.<OCOBone>`

#### # getSpine() → {OCOLimb|null}

Finds the spine

View Source DuAEF_Duik_api.jsxinc, line 15200

Returns:
The spine.
Type: `OCOLimb` | `null`

#### # newArm(typeopt, sideopt, shoulderopt, armopt, forearmopt, handopt, clawsopt, positionopt, locationopt, viewopt) → {OCOLimb}

Creates a new arm.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`type` | `OCO.LimbType` | <optional> | OCO.LimbType.HOMINOID | The type of limb
`side` | `OCO.Side` | <optional> | OCO.Side.LEFT | The side
`shoulder` | `Boolean` | <optional> | false | Whether to create a shoulder
`arm` | `Boolean` | <optional> | true | Whether to create an arm / humerus
`forearm` | `Boolean` | <optional> | true | Whether to create a forearm
`hand` | `Boolean` | <optional> | true | Whether to create a hand
`claws` | `Boolean` | <optional> | false | Whether to add claws
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.
`location` | `OCO.Location` | <optional> | OCO.Location.FRONT | The location of the limb
`view` | `OCO.View` | <optional> |  | The view

View Source DuAEF_Duik_api.jsxinc, line 15306

Returns:
The arm
Type: `OCOLimb`

#### # newFin(sideopt, fishbonesopt, positionopt, viewopt) → {OCOLimb}

Creates a new fin.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`side` | `OCO.Side` | <optional> | OCO.Side.LEFT | The side
`fishbones` | `int` | <optional> | 5 | Number of feathers
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.
`view` | `OCO.View` | <optional> | OCO.View.RIGHT | The view

View Source DuAEF_Duik_api.jsxinc, line 16371

Returns:
The fin
Type: `OCOLimb`

#### # newFishSpine(headopt, spineopt, positionopt) → {OCOLimb}

Creates a new fish spine.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`head` | `Boolean` | <optional> | true | Whether to create a head
`spine` | `int` | <optional> | 3 | Number of spine bones
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the spine. If omitted, computed automatically according to the current character in the doc.

View Source DuAEF_Duik_api.jsxinc, line 16286

Returns:
The fish spine
Type: `OCOLimb`

#### # newHairStrand(numBonesopt) → {OCOLimb}

Creates a new hair strand.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`numBones` | `int` | <optional> | 3 | Number of hair bones

View Source DuAEF_Duik_api.jsxinc, line 15984

Returns:
The hair
Type: `OCOLimb`

#### # newLeg(typeopt, sideopt, thighopt, calfopt, footopt, clawsopt, positionopt, locationopt, viewopt) → {OCOLimb}

Creates a new leg.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`type` | `OCO.LimbType` | <optional> | OCO.LimbType.HOMINOID | The type of limb
`side` | `OCO.Side` | <optional> | OCO.Side.LEFT | The side
`thigh` | `Boolean` | <optional> | true | Whether to create a thigh
`calf` | `Boolean` | <optional> | true | Whether to create a calf
`foot` | `Boolean` | <optional> | true | Whether to create a foot
`claws` | `Boolean` | <optional> | false | Whether to add claws
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.
`location` | `OCO.Location` | <optional> | OCO.Location.BACK | The location of the limb
`view` | `OCO.View` | <optional> |  | The view

View Source DuAEF_Duik_api.jsxinc, line 15641

Returns:
The leg
Type: `OCOLimb`

#### # newLimb(limbopt, sideopt, locationopt, typeopt) → {OCOLimb}

Creates a new limb and adds it to the doc

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`limb` | `OCO.Limb` | <optional> | OCO.Limb.CUSTOM | A Predefined limb
`side` | `OCO.Side` | <optional> | OCO.Side.NONE | The side of the limb
`location` | `OCO.Location` | <optional> | OCO.Location.NONE | The location of the limb
`type` | `OCO.LimbType` | <optional> | OCO.LimbType.CUSTOM | The type of the limb

View Source DuAEF_Duik_api.jsxinc, line 15284

Returns:
The new limb
Type: `OCOLimb`

#### # newSnakeSpine(headopt, spineopt, positionopt) → {OCOLimb}

Creates a new snake spine.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`head` | `Boolean` | <optional> | true | Whether to create a head
`spine` | `int` | <optional> | 5 | Number of spine bones
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.

View Source DuAEF_Duik_api.jsxinc, line 16202

Returns:
The snake spine
Type: `OCOLimb`

#### # newSpine(headopt, neckopt, spineopt, hipsopt, positionopt, viewopt) → {OCOLimb}

Creates a new spine.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`head` | `Boolean` | <optional> | true | Whether to create a head
`neck` | `int` | <optional> | 1 | Number of neck bones
`spine` | `int` | <optional> | 2 | Number of spine bones
`hips` | `Boolean` | <optional> | true | Whether to create hips
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.
`view` | `OCO.View` | <optional> |  | The view

View Source DuAEF_Duik_api.jsxinc, line 15833

Returns:
The spine
Type: `OCOLimb`

#### # newTail(numBonesopt) → {OCOLimb}

Creates a new tail.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`numBones` | `int` | <optional> | 3 | Number of tail bones

View Source DuAEF_Duik_api.jsxinc, line 15945

Returns:
The spine
Type: `OCOLimb`

#### # newWing(sideopt, armopt, forearmopt, handopt, feathersopt, positionopt, viewopt) → {OCOLimb}

Creates a new wing.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`side` | `OCO.Side` | <optional> | OCO.Side.LEFT | The side
`arm` | `Boolean` | <optional> | true | Whether to create an arm / humerus
`forearm` | `Boolean` | <optional> | true | Whether to create a forearm
`hand` | `Boolean` | <optional> | true | Whether to create a hand
`feathers` | `int` | <optional> | 5 | Number of feathers
`position` | `Array.<float>` | <optional> |  | The position of the first bone of the arm. If omitted, computed automatically according to the current character in the doc.
`view` | `OCO.View` | <optional> | OCO.View.TOP | The view

View Source DuAEF_Duik_api.jsxinc, line 16037

Returns:
The wing
Type: `OCOLimb`

#### # normalizeZIndices(offsetopt) → {int}

Normalizes the Z indices of all bones so they're positive (including 0) and continuous integers.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`offset` | `int` | <optional> | 0 | An offset/start number

View Source DuAEF_Duik_api.jsxinc, line 16599

Returns:
The highest index
Type: `int`

#### # numBones() → {int}

Counts the total number of bones in this doc

View Source DuAEF_Duik_api.jsxinc, line 15215

Returns:
Type: `int`

#### # numLimbs() → {int}

Counts the total number of limbs in this doc

View Source DuAEF_Duik_api.jsxinc, line 15229

Returns:
Type: `int`

#### # toComp(compopt, durationopt, floatopt) → {Array.<Layer>}

Creates the limbs and armatures in the comp

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`comp` | `CompItem` | <optional> |  | The composition to use. If omitted, creates a new composition.
`duration` | `float` | <optional> | 60.0 | The duration of the new comp, in seconds.
`float` | `frameRate` | <optional> | 24.0 | The frame rate of the new comp.

View Source DuAEF_Duik_api.jsxinc, line 35624

Returns:
The new layers
Type: `Array.<Layer>`

#### # toFile(file) → {File}

Exports the current document to an oco file

##### Parameters:

Name | Type | Description
--- | --- | ---
`file` | `File` | `string` | The file.

View Source DuAEF_Duik_api.jsxinc, line 16564

Returns:
the file.
Type: `File`

#### # toJson(imageEncodingopt, destinationFileopt) → {string}

Creates a JSON string representing this document

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`imageEncoding` | `OCO.ImageEncoding` | <optional> | OCO.ImageEncoding.PATH | How to encode images in the OCO File
`destinationFile` | `File` | <optional> |  | If imageEncoding is `OCO.ImageEncoding.PATH`, you must provide the OCO file to make the paths relative to it.

View Source DuAEF_Duik_api.jsxinc, line 16541

Returns:
the JSON document
Type: `string`

#### # toObject() → {Object}

Creates a js object containing this document data.
This object could then be exported to JSON for example.

View Source DuAEF_Duik_api.jsxinc, line 16510

Returns:
the JS Object
Type: `Object`

#### # toPixels(point) → {Array.<int>}

Converts a doc coordinate/value in centimeters to pixel coordinates.
For multidimensionnal values (coordinates), the origin is adjusted from doc to image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | `Array.<float>` | The coordinate to convert

View Source DuAEF_Duik_api.jsxinc, line 16469

Returns:
The coordinates in pixels
Type: `Array.<int>`

#### # updateSize()

Updates the width and height of the character, according to the content.
This method should be called each time a limb/bone is added/removed/edited and the bounds may change.

View Source DuAEF_Duik_api.jsxinc, line 15266