# \[UXP/batchPlay\] How to recreate a Live Shape (arrow) on a new layer?

**URL:** https://forums.creativeclouddeveloper.com/t/uxp-batchplay-how-to-recreate-a-live-shape-arrow-on-a-new-layer/11906
**Category:** Photoshop
**Created:** [May 7, 2026, 3:59pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-batchplay-how-to-recreate-a-live-shape-arrow-on-a-new-layer/11906 "2026-05-07T15:59:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dai0116](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dai0116](https://forums.creativeclouddeveloper.com/u/dai0116)
#### Post date: [May 7, 2026, 3:59pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-batchplay-how-to-recreate-a-live-shape-arrow-on-a-new-layer/11906/1 "2026-05-07T15:59:30Z")

</div>

## [UXP/batchPlay] How to reproduce a Live Shape (arrow, keyOriginType:9) on a new layer?

Hi everyone,

I’m developing a UXP plugin that saves layer groups as templates and reapplies them to other documents. I’ve hit a wall trying to programmatically reproduce **arrow shapes** (and other non-rectangle/ellipse Live Shapes).

### What I have

I can successfully **read** the arrow layer’s data via batchPlay GET:

- `keyOriginType: 9` (arrow)
- `vectorMask.pathComponents` with valid bézier data (percentUnit coordinates)
- All subpath points, anchors, and control handles

### The problem

I cannot recreate the arrow shape on a new layer. I’ve tried **14 different approaches** over several weeks. Here’s a summary:

**Approach A – `make contentLayer` with path data**

```js
// Tried with pathComponents, pathContents (_obj:"pathContents"), 
// and pathContents (_obj:"pathClass")
await batchPlay([{
  _obj: "make",
  _target: [{ _ref: "contentLayer" }],
  using: {
    _obj: "contentLayer",
    type: { _obj: "solidColorLayer", color: { ... } },
    shape: { _obj: "path", pathComponents: [/* arrow data */] }
  }
}], {});

```

**Result:** No layer created (silent failure, no error thrown).

**Approach B – Create shape layer → SET vectorMask**

```js
// 1. Create a rectangle shape layer
// 2. Set vectorMask with arrow path data
// 3. Clear keyOriginType with keyOriginType: []
await batchPlay([{
  _obj: "set",
  _target: [{ _ref: "path", _property: "vectorMask" }],
  to: { _obj: "pathClass", pathComponents: [/* arrow data */] }
}], {});

```

**Result:** Layer stays as rectangle. Even though a subsequent GET confirms the arrow path data is stored in vectorMask, PS continues to render the rectangle from `keyOriginType:1`. Clearing `keyOriginType: []` has no visual effect.

**Approach C – Fill layer → vectorMask**

```js
// Tried: addMask vectorMaskRevealAll → set vectorMask,
// set layer vectorMask directly,
// workPath → select → addMask vectorMaskFromCurrentPath

```

**Result:** Always renders as full-canvas fill. The vectorMask SET completes without error but never visually applies.

### What works (but has limitations)

`duplicate` is the **only** method that successfully preserves the arrow shape:

```js
await batchPlay([{
  _obj: "duplicate",
  _target: [{ _ref: "layer", _enum: "ordinal", _value: "targetEnum" }],
  version: 5,
  to: { _ref: "document", _id: destDocId }
}], {});

```

This works, but requires keeping the original layer alive somewhere as a “master copy,” which adds complexity to the template system.

### My questions

1. **Is there a correct batchPlay descriptor to create an arrow (or other non-rect/ellipse Live Shape) from scratch?** If anyone has captured the descriptor via Alchemist or Actions panel → “Copy as JavaScript” when manually drawing an arrow, I’d love to see the structure.

2. **Is `keyOriginType` fundamentally read-only for creation purposes?** My testing suggests PS only establishes it during the internal shape-creation flow and ignores external SET attempts.

3. **Is `duplicate` truly the only reliable path?** If so, any tips on controlling placement (parent group, position) after cross-document duplicate?

Any insights from the UXP/batchPlay community would be hugely appreciated. Thanks!

**Environment:** Photoshop 2025, UXP 8.x, macOS

---

<div class="post-metadata">

### Author: ![shuji](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/shuji/32/4905_2.png) [@shuji](https://forums.creativeclouddeveloper.com/u/shuji)
#### Post date: [May 9, 2026, 6:12am UTC](https://forums.creativeclouddeveloper.com/t/uxp-batchplay-how-to-recreate-a-live-shape-arrow-on-a-new-layer/11906/2 "2026-05-09T06:12:38Z")

</div>

Are you looking for this?

```auto
/*
Create an arrow shape through the custom line shape
*/
async function drawArrow() {
   const result = await batchPlay(
      [
         {
            _obj: "make",
            _target: [
               {
                  _ref: "contentLayer"
               }
            ],
            using: {
               _obj: "contentLayer",
               type: {
                  _obj: "solidColorLayer",
                  color: {
                     _obj: "RGBColor",
                     red: 255,
                     grain: 255,
                     blue: 255
                  }
               },
               shape: {
                  _obj: "customShape",
                  name: "矢印 10",// write the arrow shape name
                  keyOriginType: 9,// custom shape
                  top: {
                     _unit: "pixelsUnit",
                     _value: 665
                  },
                  left: {
                     _unit: "pixelsUnit",
                     _value: 102
                  },
                  bottom: {
                     _unit: "pixelsUnit",
                     _value: 807
                  },
                  right: {
                     _unit: "pixelsUnit",
                     _value: 366
                  }
               },
               strokeStyle: {
                  _obj: "strokeStyle",
                  strokeStyleVersion: 2,
                  strokeEnabled: true,
                  fillEnabled: true,
                  strokeStyleLineWidth: {
                     _unit: "pixelsUnit",
                     _value: 0.22
                  },
                  strokeStyleLineDashOffset: {
                     _unit: "pointsUnit",
                     _value: 0
                  },
                  strokeStyleMiterLimit: 100,
                  strokeStyleLineCapType: {
                     _enum: "strokeStyleLineCapType",
                     _value: "strokeStyleButtCap"
                  },
                  strokeStyleLineJoinType: {
                     _enum: "strokeStyleLineJoinType",
                     _value: "strokeStyleMiterJoin"
                  },
                  strokeStyleLineAlignment: {
                     _enum: "strokeStyleLineAlignment",
                     _value: "strokeStyleAlignCenter"
                  },
                  strokeStyleScaleLock: false,
                  strokeStyleStrokeAdjust: false,
                  strokeStyleLineDashSet: [],
                  strokeStyleBlendMode: {
                     _enum: "blendMode",
                     _value: "normal"
                  },
                  strokeStyleOpacity: {
                     _unit: "percentUnit",
                     _value: 100
                  },
                  strokeStyleContent: {
                     _obj: "solidColorLayer",
                     color: {
                        _obj: "RGBColor",
                        red: 0,
                        grain: 0,
                        blue: 0
                     }
                  },
                  strokeStyleResolution: 72
               }
            },
            layerID: app.activeDocument.activeLayers[0],// create on the current active layer
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {}
   );
   console.log(result);
}

```
