Skip to main content
clydeb68760240
Participant
February 8, 2019
Answered

Blending Two Paths in Javascript

  • February 8, 2019
  • 1 reply
  • 860 views

Hi I am writing a script to automate the creation of a graph with axes and grids.

I have two PathItems called xGridLeft and xGridRight, both contained in the "Grids" layer of my document.I want to be able to blend these two paths together in a manner similar to selecting Object > Blend > Make from the menu, using the Specified Steps blending mode.

Can anyone help me with the code I need to accomplish this?

var graph = app.activeDocument;

var Grids = graph.layers.add();

Grids.name = "Grids";

var xGridLeft = Grids.pathItems.add();

xGridLeft.name = "xGridLeft";

xGridLeft.setEntirePath(Array(*two points*));

xGridLeft.strokeColor = Grey;

xGridLeft.fillColor - NoColor;

xGridLeft.strokeWidth = 0.5;

xGridLeft.strokeDashes = [2];

var xGridRight = Grids.pathItems.add();

xGridRight.name = "xGridRight";

xGridRight.setEntirePath(Array(*two different points*));

xGridRight.strokeColor = Grey;

xGridRight.fillColor - NoColor;

xGridRight.strokeWidth = 0.5;

xGridRight.strokeDashes = [2];

//What code do I need to put here?

This topic has been closed for replies.
Correct answer pixxxelschubser

Your code is only part of a larger script?

(Some variables are undefined and there are some typos)

As a matter of fact you need only three new lines at the end of your pseudocode:

xGridLeft.selected = true;

xGridRight.selected = true;

app.executeMenuCommand('Path Blend Make');

Have fun

1 reply

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
February 9, 2019

Your code is only part of a larger script?

(Some variables are undefined and there are some typos)

As a matter of fact you need only three new lines at the end of your pseudocode:

xGridLeft.selected = true;

xGridRight.selected = true;

app.executeMenuCommand('Path Blend Make');

Have fun

clydeb68760240
Participant
February 11, 2019

Thank you so much pixxxel schubser this is really helpful! And yes you are correct, the code I provided consists of snippets of a longer script combined with a bit of pseudocode.

I'm hoping you can also tell me how to access the Blend settings before I run Line 04 in your provided code. Specifically I want to Blend using Specified Steps and a variable in my script as the # of steps. Any ideas?

Silly-V
Legend
February 12, 2019

It appears that the dialog to set the blend steps is recordable into an action!

You can use the dynamic action technique to set the steps after you create your blend.