Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

problem adressing shape layer groups via script - "object is invalid"

Contributor ,
May 21, 2025 May 21, 2025

hi people

 

This is the first time I've tried adding paths to more than one group in a shape layer and something is amiss.

 

I need to add 2 groups and then add multiple paths to each group. Each group is added and assigned to variable but for some reason the first group varibale becomes an "invalid object" after the second one is created?! the workaround is to create the first group add all the paths to that, then create the second and add paths to it, but this is clunky as all get out and shouln't be needed. what is going on ? any help greatly appreciated.

 

cutdown example code below

 

this breaks when trying to get the name of vrtGroup

var C = app.project.activeItem;
var L = C.layers.addShape()

var vrtGroup = L.Contents.addProperty("ADBE Vector Group");
vrtGroup.name = "vertical lines";
var hrzGroup = L.Contents.addProperty("ADBE Vector Group");
hrzGroup.name = "horizontal lines";

$.writeln("hrzGroup.name: " + hrzGroup.name)
$.writeln("vrtGroup.name: " + vrtGroup.name)

 

but this works ???

var C = app.project.activeItem;
var L = C.layers.addShape()

var vrtGroup = L.Contents.addProperty("ADBE Vector Group");
vrtGroup.name = "vertical lines";

$.writeln("vrtGroup.name: " + vrtGroup.name)

var hrzGroup = L.Contents.addProperty("ADBE Vector Group");
hrzGroup.name = "horizontal lines";

$.writeln("hrzGroup.name: " + hrzGroup.name)

 

TOPICS
Scripting
47
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation