So does that mean trying to create more complex paths from pre set coordinates is a dead end?
What about if had two arrays outer shape and inner shapes, then after they have been drawn combine them and set the second set of paths info to exclude from the first path?
custom shape point data
-
Mike Hale
custom shape point data
I think it depends on the path. I made a crude copy of the problem path in Photoshop and the following code creates a matching shape.
I don't know enough about Illustrator but you may be able to copy problem paths there and do something there that would make the path more suitable to Photoshop scripting. The problem is there is no way I see to set the shapeOperation of those 'subSubPaths'. If you know or find a way to use Illustrator to convert those types of paths please let me know.
Speaking of the shapeOperation. That could be a problem even with simple paths. The xor operation only has a stringID. stringIDs can vary from Photoshop session to session. So I had to modify the function that extracts the path as an array. It was using whatever the current typeID that maps to stringIDToTypeID('xor'). But that meant the array would only work during that one Photoshop session.
Code: Select allvar shapeArray = [[[[550, 343], [550, 343], [550, 343], false], [[861, 345], [861, 345], [861, 345], false], [[864, 742], [851.700737618546, 773.634042553192], [876.299262381454, 710.365957446808], true], [[828, 787], [790.222339304531, 788.62695035461], [865.777660695469, 785.37304964539], true], [[549, 789], [549, 789], [549, 789], false], true, stringIDToTypeID('xor')], [[[580, 376], [580, 376], [580, 376], false], [[831, 375], [831, 375], [831, 375], false], [[834, 579], [834, 579], [834, 579], false], [[580, 583], [580, 583], [580, 583], false], true, stringIDToTypeID('xor')], [[[612, 615], [612, 615], [612, 615], false], [[642, 615], [642, 615], [642, 615], false], [[640, 643], [640, 643], [640, 643], false], [[673, 645], [673, 645], [673, 645], false], [[673, 672], [673, 672], [673, 672], false], [[643, 672], [643, 672], [643, 672], false], [[643, 706], [643, 706], [643, 706], false], [[613, 706], [613, 706], [613, 706], false], [[613, 678], [613, 678], [613, 678], false], [[579, 673], [579, 673], [579, 673], false], [[579, 648], [579, 648], [579, 648], false], [[613, 645], [613, 645], [613, 645], false], true, stringIDToTypeID('xor')], [[[745, 645], [782.724973656481, 646.194326241135], [707.275026343519, 643.805673758865], true], [[744, 691], [715.248682824025, 689.673758865248], [772.751317175975, 692.326241134752], true], true, stringIDToTypeID('xor')], [[[808, 630], [848.701791359326, 629.702127659574], [767.298208640674, 630.297872340426], true], [[807, 678], [781.22550052687, 677.679432624113], [832.77449947313, 678.320567375887], true], true, stringIDToTypeID('xor')]];
var tempPath = createPath2012(shapeArray,'tempPath1');
defineCustomShape('ShapeName1');
tempPath.remove();
function createPath2012(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Path'), charIDToTypeID('WrPt'));
desc1.putReference(stringIDToTypeID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(stringIDToTypeID('shapeOperation'), stringIDToTypeID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(charIDToTypeID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[0][1]);
desc4.putObject(charIDToTypeID('Anch'), charIDToTypeID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[1][1]);
desc4.putObject(charIDToTypeID('Fwd '), charIDToTypeID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[2][1]);
desc4.putObject(charIDToTypeID('Bwd '), charIDToTypeID('Pnt '), desc7);
desc4.putBoolean(charIDToTypeID('Smoo'), thisPoint[3]);
list3.putObject(charIDToTypeID('Pthp'), desc4);
};
desc3.putList(charIDToTypeID('Pts '), list3);
list2.putObject(charIDToTypeID('Sbpl'), desc3);
desc2.putList(charIDToTypeID('SbpL'), list2);
list1.putObject(charIDToTypeID('PaCm'), desc2);
};
desc1.putList(charIDToTypeID('T '), list1);
executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
if (hasVectorMask() == false) {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1];
}
else {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2];
};
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
};
function defineCustomShape( shapeName ) {// make shape preset from active path
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID('customShape') );
desc.putReference( charIDToTypeID('null'), ref );
var ref2 = new ActionReference();
ref2.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('fsel') );
ref2.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('Usng'), ref2 );
desc.putString( charIDToTypeID('Nm '), shapeName );
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
};
function hasVectorMask() {
var hasVectorMask = false;
try {
var ref = new ActionReference();
var keyVectorMaskEnabled = app.stringIDToTypeID( 'vectorMask' );
var keyKind = app.charIDToTypeID( 'Knd ' );
ref.putEnumerated( app.charIDToTypeID( 'Path' ), app.charIDToTypeID( 'Ordn' ), keyVectorMaskEnabled );
var desc = executeActionGet( ref );
if ( desc.hasKey( keyKind ) ) {
var kindValue = desc.getEnumerationValue( keyKind );
if (kindValue == keyVectorMaskEnabled) {
hasVectorMask = true;
}
}
}catch(e) {
hasVectorMask = false;
}
return hasVectorMask;
};
BTW, here is the array from the problem sample path. It thinks all the shapeOperations are charIDToTypeID('Add ') which is why the inter shapes don't show.
Code: Select all[[[[800.995174467564, 784.983918964863], [800.995174467564, 784.983918964863], [848.242373168468, 784.983918964863], false], [[549.0091817379, 784.983918964863], [549.0091817379, 784.983918964863], [549.0091817379, 784.983918964863], false], [[549.0091817379, 343.017694413662], [549.0091817379, 343.017694413662], [549.0091817379, 343.017694413662], false], [[863.991184949875, 343.017694413662], [863.991184949875, 343.017694413662], [863.991184949875, 343.017694413662], false], [[863.991184949875, 721.845724880695], [863.991184949875, 769.198992431164], [863.991184949875, 721.845724880695], false], true, 1097098272], [[[745.873188197613, 690.276438832283], [758.920056581497, 690.276438832283], [732.826404631138, 690.276438832283], true], [[769.496787548065, 666.599364042282], [769.496787548065, 653.523276209831], [769.496787548065, 679.676396906376], true], [[745.873188197613, 642.923297286034], [732.826404631138, 642.923297286034], [758.920056581497, 642.923297286034], true], [[722.24967366457, 666.599364042282], [722.24967366457, 679.676396906376], [722.24967366457, 653.523276209831], true], true, 1097098272], [[[580.507483839989, 674.49207931757], [580.507483839989, 674.49207931757], [580.507483839989, 674.49207931757], false], [[612.005192220211, 674.49207931757], [612.005192220211, 674.49207931757], [612.005192220211, 674.49207931757], false], [[612.005192220211, 706.061365365982], [612.005192220211, 706.061365365982], [612.005192220211, 706.061365365982], false], [[643.5034943223, 706.061365365982], [643.5034943223, 706.061365365982], [643.5034943223, 706.061365365982], false], [[643.5034943223, 674.49207931757], [643.5034943223, 674.49207931757], [643.5034943223, 674.49207931757], false], [[675.001881241798, 674.49207931757], [675.001881241798, 674.49207931757], [675.001881241798, 674.49207931757], false], [[675.001881241798, 642.923297286034], [675.001881241798, 642.923297286034], [675.001881241798, 642.923297286034], false], [[643.5034943223, 642.923297286034], [643.5034943223, 642.923297286034], [643.5034943223, 642.923297286034], false], [[643.5034943223, 611.353948235512], [643.5034943223, 611.353948235512], [643.5034943223, 611.353948235512], false], [[612.005192220211, 611.353948235512], [612.005192220211, 611.353948235512], [612.005192220211, 611.353948235512], false], [[612.005192220211, 642.923297286034], [612.005192220211, 642.923297286034], [612.005192220211, 642.923297286034], false], [[580.507483839989, 642.923297286034], [580.507483839989, 642.923297286034], [580.507483839989, 642.923297286034], false], true, 1097098272], [[[832.492798030376, 374.586476445198], [832.492798030376, 374.586476445198], [832.492798030376, 374.586476445198], false], [[580.507483839989, 374.586476445198], [580.507483839989, 374.586476445198], [580.507483839989, 374.586476445198], false], [[580.507483839989, 579.785166203976], [580.507483839989, 579.785166203976], [580.507483839989, 579.785166203976], false], [[832.492798030376, 579.785166203976], [832.492798030376, 579.785166203976], [832.492798030376, 579.785166203976], false], true, 1097098272], [[[808.8698772192, 627.138370752335], [795.823093652725, 627.138370752335], [821.917339324951, 627.138370752335], true], [[785.246277868748, 650.815508544445], [785.246277868748, 663.891533374786], [785.246277868748, 637.738916695118], true], [[808.8698772192, 674.49207931757], [821.917339324951, 674.49207931757], [795.823093652725, 674.49207931757], true], [[832.492798030376, 650.815508544445], [832.492798030376, 637.738916695118], [832.492798030376, 663.891533374786], true], true, 1097098272]]
I don't know enough about Illustrator but you may be able to copy problem paths there and do something there that would make the path more suitable to Photoshop scripting. The problem is there is no way I see to set the shapeOperation of those 'subSubPaths'. If you know or find a way to use Illustrator to convert those types of paths please let me know.
Speaking of the shapeOperation. That could be a problem even with simple paths. The xor operation only has a stringID. stringIDs can vary from Photoshop session to session. So I had to modify the function that extracts the path as an array. It was using whatever the current typeID that maps to stringIDToTypeID('xor'). But that meant the array would only work during that one Photoshop session.
Code: Select allvar shapeArray = [[[[550, 343], [550, 343], [550, 343], false], [[861, 345], [861, 345], [861, 345], false], [[864, 742], [851.700737618546, 773.634042553192], [876.299262381454, 710.365957446808], true], [[828, 787], [790.222339304531, 788.62695035461], [865.777660695469, 785.37304964539], true], [[549, 789], [549, 789], [549, 789], false], true, stringIDToTypeID('xor')], [[[580, 376], [580, 376], [580, 376], false], [[831, 375], [831, 375], [831, 375], false], [[834, 579], [834, 579], [834, 579], false], [[580, 583], [580, 583], [580, 583], false], true, stringIDToTypeID('xor')], [[[612, 615], [612, 615], [612, 615], false], [[642, 615], [642, 615], [642, 615], false], [[640, 643], [640, 643], [640, 643], false], [[673, 645], [673, 645], [673, 645], false], [[673, 672], [673, 672], [673, 672], false], [[643, 672], [643, 672], [643, 672], false], [[643, 706], [643, 706], [643, 706], false], [[613, 706], [613, 706], [613, 706], false], [[613, 678], [613, 678], [613, 678], false], [[579, 673], [579, 673], [579, 673], false], [[579, 648], [579, 648], [579, 648], false], [[613, 645], [613, 645], [613, 645], false], true, stringIDToTypeID('xor')], [[[745, 645], [782.724973656481, 646.194326241135], [707.275026343519, 643.805673758865], true], [[744, 691], [715.248682824025, 689.673758865248], [772.751317175975, 692.326241134752], true], true, stringIDToTypeID('xor')], [[[808, 630], [848.701791359326, 629.702127659574], [767.298208640674, 630.297872340426], true], [[807, 678], [781.22550052687, 677.679432624113], [832.77449947313, 678.320567375887], true], true, stringIDToTypeID('xor')]];
var tempPath = createPath2012(shapeArray,'tempPath1');
defineCustomShape('ShapeName1');
tempPath.remove();
function createPath2012(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Path'), charIDToTypeID('WrPt'));
desc1.putReference(stringIDToTypeID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(stringIDToTypeID('shapeOperation'), stringIDToTypeID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(charIDToTypeID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[0][1]);
desc4.putObject(charIDToTypeID('Anch'), charIDToTypeID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[1][1]);
desc4.putObject(charIDToTypeID('Fwd '), charIDToTypeID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), thisPoint[2][1]);
desc4.putObject(charIDToTypeID('Bwd '), charIDToTypeID('Pnt '), desc7);
desc4.putBoolean(charIDToTypeID('Smoo'), thisPoint[3]);
list3.putObject(charIDToTypeID('Pthp'), desc4);
};
desc3.putList(charIDToTypeID('Pts '), list3);
list2.putObject(charIDToTypeID('Sbpl'), desc3);
desc2.putList(charIDToTypeID('SbpL'), list2);
list1.putObject(charIDToTypeID('PaCm'), desc2);
};
desc1.putList(charIDToTypeID('T '), list1);
executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
if (hasVectorMask() == false) {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1];
}
else {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2];
};
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
};
function defineCustomShape( shapeName ) {// make shape preset from active path
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID('customShape') );
desc.putReference( charIDToTypeID('null'), ref );
var ref2 = new ActionReference();
ref2.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('fsel') );
ref2.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('Usng'), ref2 );
desc.putString( charIDToTypeID('Nm '), shapeName );
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
};
function hasVectorMask() {
var hasVectorMask = false;
try {
var ref = new ActionReference();
var keyVectorMaskEnabled = app.stringIDToTypeID( 'vectorMask' );
var keyKind = app.charIDToTypeID( 'Knd ' );
ref.putEnumerated( app.charIDToTypeID( 'Path' ), app.charIDToTypeID( 'Ordn' ), keyVectorMaskEnabled );
var desc = executeActionGet( ref );
if ( desc.hasKey( keyKind ) ) {
var kindValue = desc.getEnumerationValue( keyKind );
if (kindValue == keyVectorMaskEnabled) {
hasVectorMask = true;
}
}
}catch(e) {
hasVectorMask = false;
}
return hasVectorMask;
};
BTW, here is the array from the problem sample path. It thinks all the shapeOperations are charIDToTypeID('Add ') which is why the inter shapes don't show.
Code: Select all[[[[800.995174467564, 784.983918964863], [800.995174467564, 784.983918964863], [848.242373168468, 784.983918964863], false], [[549.0091817379, 784.983918964863], [549.0091817379, 784.983918964863], [549.0091817379, 784.983918964863], false], [[549.0091817379, 343.017694413662], [549.0091817379, 343.017694413662], [549.0091817379, 343.017694413662], false], [[863.991184949875, 343.017694413662], [863.991184949875, 343.017694413662], [863.991184949875, 343.017694413662], false], [[863.991184949875, 721.845724880695], [863.991184949875, 769.198992431164], [863.991184949875, 721.845724880695], false], true, 1097098272], [[[745.873188197613, 690.276438832283], [758.920056581497, 690.276438832283], [732.826404631138, 690.276438832283], true], [[769.496787548065, 666.599364042282], [769.496787548065, 653.523276209831], [769.496787548065, 679.676396906376], true], [[745.873188197613, 642.923297286034], [732.826404631138, 642.923297286034], [758.920056581497, 642.923297286034], true], [[722.24967366457, 666.599364042282], [722.24967366457, 679.676396906376], [722.24967366457, 653.523276209831], true], true, 1097098272], [[[580.507483839989, 674.49207931757], [580.507483839989, 674.49207931757], [580.507483839989, 674.49207931757], false], [[612.005192220211, 674.49207931757], [612.005192220211, 674.49207931757], [612.005192220211, 674.49207931757], false], [[612.005192220211, 706.061365365982], [612.005192220211, 706.061365365982], [612.005192220211, 706.061365365982], false], [[643.5034943223, 706.061365365982], [643.5034943223, 706.061365365982], [643.5034943223, 706.061365365982], false], [[643.5034943223, 674.49207931757], [643.5034943223, 674.49207931757], [643.5034943223, 674.49207931757], false], [[675.001881241798, 674.49207931757], [675.001881241798, 674.49207931757], [675.001881241798, 674.49207931757], false], [[675.001881241798, 642.923297286034], [675.001881241798, 642.923297286034], [675.001881241798, 642.923297286034], false], [[643.5034943223, 642.923297286034], [643.5034943223, 642.923297286034], [643.5034943223, 642.923297286034], false], [[643.5034943223, 611.353948235512], [643.5034943223, 611.353948235512], [643.5034943223, 611.353948235512], false], [[612.005192220211, 611.353948235512], [612.005192220211, 611.353948235512], [612.005192220211, 611.353948235512], false], [[612.005192220211, 642.923297286034], [612.005192220211, 642.923297286034], [612.005192220211, 642.923297286034], false], [[580.507483839989, 642.923297286034], [580.507483839989, 642.923297286034], [580.507483839989, 642.923297286034], false], true, 1097098272], [[[832.492798030376, 374.586476445198], [832.492798030376, 374.586476445198], [832.492798030376, 374.586476445198], false], [[580.507483839989, 374.586476445198], [580.507483839989, 374.586476445198], [580.507483839989, 374.586476445198], false], [[580.507483839989, 579.785166203976], [580.507483839989, 579.785166203976], [580.507483839989, 579.785166203976], false], [[832.492798030376, 579.785166203976], [832.492798030376, 579.785166203976], [832.492798030376, 579.785166203976], false], true, 1097098272], [[[808.8698772192, 627.138370752335], [795.823093652725, 627.138370752335], [821.917339324951, 627.138370752335], true], [[785.246277868748, 650.815508544445], [785.246277868748, 663.891533374786], [785.246277868748, 637.738916695118], true], [[808.8698772192, 674.49207931757], [821.917339324951, 674.49207931757], [795.823093652725, 674.49207931757], true], [[832.492798030376, 650.815508544445], [832.492798030376, 637.738916695118], [832.492798030376, 663.891533374786], true], true, 1097098272]]
-
norm
custom shape point data
how did you manage to get the shapeArray in its natural format ie inside the [] brackets? do you have a script for exporting that?
-
Mike Hale
custom shape point data
No script, just an Array method common to most objects in javascript.
var myArray = [1,1,1,1,1,1];
alert(myArray.toSource());
var myArray = [1,1,1,1,1,1];
alert(myArray.toSource());
-
Mike Hale
custom shape point data
No, I made a new solidFill layer using the path from your sample file as the vector mask. I then made a new path using the pen tool with the masked layer as a guide. I used that new path and a modified collectPathInfoFromDesc2012 function to get the array. That array has quotes around the stringIDToType('xor'). I manually removed the quotes before using it with the script I posted.
Did that script work for you? It should have created a new custom shape named 'ShapeName1'.
Did that script work for you? It should have created a new custom shape named 'ShapeName1'.
-
norm
custom shape point data
Im making some progress, Im still just experimenting.
could you please share your mod of collectPathInfoFromDesc2012? did you get it to write the array to a text doc so you could paste it in the samples you posted?
could you please share your mod of collectPathInfoFromDesc2012? did you get it to write the array to a text doc so you could paste it in the samples you posted?
-
Mike Hale
custom shape point data
I didn't write the array to a file( but I guess it could ). I just wrote it to the javascript console in ESTK. Still would like to know if the script I posted created a shape for you.
Code: Select allvar AAAArray = collectPathInfoFromDesc2012 (app.activeDocument, app.activeDocument.pathItems[0]);
$.writeln(AAAArray.toSource().replace(/"/g,''));
function collectPathInfoFromDesc2012 (myDocument, thePath) {// modified version of function by pfaffenbichler
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// based of functions from xbytor’s stdlib;
var ref = new ActionReference();
for (var l = 0; l < myDocument.pathItems.length; l++) {
var thisPath = myDocument.pathItems[l];
if (thisPath == thePath && thisPath.name == "Work Path") {
ref.putProperty(charIDToTypeID("Path"), charIDToTypeID("WrPt"));
};
if (thisPath == thePath && thisPath.name != "Work Path" && thisPath.kind != PathKind.VECTORMASK) {
ref.putIndex(charIDToTypeID("Path"), l + 1);
};
if (thisPath == thePath && thisPath.kind == PathKind.VECTORMASK) {
ref.putEnumerated( charIDToTypeID( "Path" ), charIDToTypeID( "Path" ), stringIDToTypeID( "vectorMask" ) );
};
};
var desc = app.executeActionGet(ref);
var pname = desc.getString(charIDToTypeID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(charIDToTypeID("PthC")).getList(stringIDToTypeID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
var listKey = pathComponents.getObjectValue(m).getList(charIDToTypeID("SbpL"));
var operation1 = pathComponents.getObjectValue(m).getEnumerationValue(stringIDToTypeID("shapeOperation"));
switch (operation1) {
case 1097098272:
var operation = 1097098272 //charIDToTypeID('Add ');
break;
case 1398961266:
var operation = 1398961266 //charIDToTypeID('Sbtr');
break;
case 1231975538:
var operation = 1231975538 //charIDToTypeID('Intr');
break;
default:
// case 1102:
var operation = "stringIDToTypeID('xor')" //ShapeOperation.SHAPEXOR;
break;
};
// for subpathitem’s count;
for (var n = 0; n < listKey.count; n++) {
theArray.push(new Array);
var points = listKey.getObjectValue(n).getList(stringIDToTypeID('points'));
try {var closed = listKey.getObjectValue(n).getBoolean(stringIDToTypeID("closedSubpath"))}
catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
for (var o = 0; o < points.count; o++) {
var anchorObj = points.getObjectValue(o).getObjectValue(stringIDToTypeID("anchor"));
var anchor = [anchorObj.getUnitDoubleValue(stringIDToTypeID('horizontal')), anchorObj.getUnitDoubleValue(stringIDToTypeID('vertical'))];
var thisPoint = [anchor];
try {
var left = points.getObjectValue(o).getObjectValue(charIDToTypeID("Fwd "));
var leftDirection = [left.getUnitDoubleValue(stringIDToTypeID('horizontal')), left.getUnitDoubleValue(stringIDToTypeID('vertical'))];
thisPoint.push(leftDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var right = points.getObjectValue(o).getObjectValue(charIDToTypeID("Bwd "));
var rightDirection = [right.getUnitDoubleValue(stringIDToTypeID('horizontal')), right.getUnitDoubleValue(stringIDToTypeID('vertical'))];
thisPoint.push(rightDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var smoothOr = points.getObjectValue(o).getBoolean(charIDToTypeID("Smoo"));
thisPoint.push(smoothOr)
}
catch (e) {thisPoint.push(false)};
theArray[theArray.length - 1].push(thisPoint);
};
theArray[theArray.length - 1].push(closed);
theArray[theArray.length - 1].push(operation);
};
};
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
};
Code: Select allvar AAAArray = collectPathInfoFromDesc2012 (app.activeDocument, app.activeDocument.pathItems[0]);
$.writeln(AAAArray.toSource().replace(/"/g,''));
function collectPathInfoFromDesc2012 (myDocument, thePath) {// modified version of function by pfaffenbichler
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// based of functions from xbytor’s stdlib;
var ref = new ActionReference();
for (var l = 0; l < myDocument.pathItems.length; l++) {
var thisPath = myDocument.pathItems[l];
if (thisPath == thePath && thisPath.name == "Work Path") {
ref.putProperty(charIDToTypeID("Path"), charIDToTypeID("WrPt"));
};
if (thisPath == thePath && thisPath.name != "Work Path" && thisPath.kind != PathKind.VECTORMASK) {
ref.putIndex(charIDToTypeID("Path"), l + 1);
};
if (thisPath == thePath && thisPath.kind == PathKind.VECTORMASK) {
ref.putEnumerated( charIDToTypeID( "Path" ), charIDToTypeID( "Path" ), stringIDToTypeID( "vectorMask" ) );
};
};
var desc = app.executeActionGet(ref);
var pname = desc.getString(charIDToTypeID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(charIDToTypeID("PthC")).getList(stringIDToTypeID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
var listKey = pathComponents.getObjectValue(m).getList(charIDToTypeID("SbpL"));
var operation1 = pathComponents.getObjectValue(m).getEnumerationValue(stringIDToTypeID("shapeOperation"));
switch (operation1) {
case 1097098272:
var operation = 1097098272 //charIDToTypeID('Add ');
break;
case 1398961266:
var operation = 1398961266 //charIDToTypeID('Sbtr');
break;
case 1231975538:
var operation = 1231975538 //charIDToTypeID('Intr');
break;
default:
// case 1102:
var operation = "stringIDToTypeID('xor')" //ShapeOperation.SHAPEXOR;
break;
};
// for subpathitem’s count;
for (var n = 0; n < listKey.count; n++) {
theArray.push(new Array);
var points = listKey.getObjectValue(n).getList(stringIDToTypeID('points'));
try {var closed = listKey.getObjectValue(n).getBoolean(stringIDToTypeID("closedSubpath"))}
catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
for (var o = 0; o < points.count; o++) {
var anchorObj = points.getObjectValue(o).getObjectValue(stringIDToTypeID("anchor"));
var anchor = [anchorObj.getUnitDoubleValue(stringIDToTypeID('horizontal')), anchorObj.getUnitDoubleValue(stringIDToTypeID('vertical'))];
var thisPoint = [anchor];
try {
var left = points.getObjectValue(o).getObjectValue(charIDToTypeID("Fwd "));
var leftDirection = [left.getUnitDoubleValue(stringIDToTypeID('horizontal')), left.getUnitDoubleValue(stringIDToTypeID('vertical'))];
thisPoint.push(leftDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var right = points.getObjectValue(o).getObjectValue(charIDToTypeID("Bwd "));
var rightDirection = [right.getUnitDoubleValue(stringIDToTypeID('horizontal')), right.getUnitDoubleValue(stringIDToTypeID('vertical'))];
thisPoint.push(rightDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var smoothOr = points.getObjectValue(o).getBoolean(charIDToTypeID("Smoo"));
thisPoint.push(smoothOr)
}
catch (e) {thisPoint.push(false)};
theArray[theArray.length - 1].push(thisPoint);
};
theArray[theArray.length - 1].push(closed);
theArray[theArray.length - 1].push(operation);
};
};
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
};
-
pfaffenbichler
custom shape point data
Does this help?
Code: Select all// use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
myDocument = app.activeDocument;
var theResolution = myDocument.resolution;
myDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
var theArray = [[[[800.995174467564,784.983918964863],[800.995174467564,784.983918964863],[848.242373168468,784.983918964863],false],[[549.0091817379,784.983918964863],[549.0091817379,784.983918964863],[549.0091817379,784.983918964863],false],[[549.0091817379,343.017694413662],[549.0091817379,343.017694413662],[549.0091817379,343.017694413662],false],[[863.991184949875,343.017694413662],[863.991184949875,343.017694413662],[863.991184949875,343.017694413662],false],[[863.991184949875,721.845724880695],[863.991184949875,769.198992431164],[863.991184949875,721.845724880695],false],true,app.stringIDToTypeID('xor')],[[[745.873188197613,690.276438832283],[758.920056581497,690.276438832283],[732.826404631138,690.276438832283],true],[[769.496787548065,666.599364042282],[769.496787548065,653.523276209831],[769.496787548065,679.676396906376],true],[[745.873188197613,642.923297286034],[732.826404631138,642.923297286034],[758.920056581497,642.923297286034],true],[[722.24967366457,666.599364042282],[722.24967366457,679.676396906376],[722.24967366457,653.523276209831],true],true,app.stringIDToTypeID('xor')],[[[580.507483839989,674.49207931757],[580.507483839989,674.49207931757],[580.507483839989,674.49207931757],false],[[612.005192220211,674.49207931757],[612.005192220211,674.49207931757],[612.005192220211,674.49207931757],false],[[612.005192220211,706.061365365982],[612.005192220211,706.061365365982],[612.005192220211,706.061365365982],false],[[643.5034943223,706.061365365982],[643.5034943223,706.061365365982],[643.5034943223,706.061365365982],false],[[643.5034943223,674.49207931757],[643.5034943223,674.49207931757],[643.5034943223,674.49207931757],false],[[675.001881241798,674.49207931757],[675.001881241798,674.49207931757],[675.001881241798,674.49207931757],false],[[675.001881241798,642.923297286034],[675.001881241798,642.923297286034],[675.001881241798,642.923297286034],false],[[643.5034943223,642.923297286034],[643.5034943223,642.923297286034],[643.5034943223,642.923297286034],false],[[643.5034943223,611.353948235512],[643.5034943223,611.353948235512],[643.5034943223,611.353948235512],false],[[612.005192220211,611.353948235512],[612.005192220211,611.353948235512],[612.005192220211,611.353948235512],false],[[612.005192220211,642.923297286034],[612.005192220211,642.923297286034],[612.005192220211,642.923297286034],false],[[580.507483839989,642.923297286034],[580.507483839989,642.923297286034],[580.507483839989,642.923297286034],false],true,app.stringIDToTypeID('xor')],[[[832.492798030376,374.586476445198],[832.492798030376,374.586476445198],[832.492798030376,374.586476445198],false],[[580.507483839989,374.586476445198],[580.507483839989,374.586476445198],[580.507483839989,374.586476445198],false],[[580.507483839989,579.785166203976],[580.507483839989,579.785166203976],[580.507483839989,579.785166203976],false],[[832.492798030376,579.785166203976],[832.492798030376,579.785166203976],[832.492798030376,579.785166203976],false],true,app.stringIDToTypeID('xor')],[[[808.8698772192,627.138370752335],[795.823093652725,627.138370752335],[821.917339324951,627.138370752335],true],[[785.246277868748,650.815508544445],[785.246277868748,663.891533374786],[785.246277868748,637.738916695118],true],[[808.8698772192,674.49207931757],[821.917339324951,674.49207931757],[795.823093652725,674.49207931757],true],[[832.492798030376,650.815508544445],[832.492798030376,637.738916695118],[832.492798030376,663.891533374786],true],true,app.stringIDToTypeID('xor')]];
var thePath = createPath2012(theArray, Math.random());
var theLayer = makeSolidColorLayer("shape", 150, 255, 0);
// reset;
myDocument.resizeImage (undefined, undefined, theResolution, ResampleMethod.NONE);
preferences.rulerUnits = originalRulerUnits;
};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2012(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// thanks to xbytor;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Path'), cTID('WrPt'));
desc1.putReference(sTID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
list3.putObject(cTID('Pthp'), desc4);
};
desc3.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc3);
desc2.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc2);
};
desc1.putList(cTID('T '), list1);
executeAction(cTID('setd'), desc1, DialogModes.NO);
if (hasVectorMask() == false) {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1];
}
else {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2];
};
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
};
////// the fill-layer-function //////
function makeSolidColorLayer (theName, theR, theG, theB) {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref1.putClass( idcontentLayer );
desc3.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var desc4 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc5 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc6 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc6.putDouble( idRd, theR );
var idGrn = charIDToTypeID( "Grn " );
desc6.putDouble( idGrn, theG );
var idBl = charIDToTypeID( "Bl " );
desc6.putDouble( idBl, theB );
var idRGBC = charIDToTypeID( "RGBC" );
desc5.putObject( idClr, idRGBC, desc6 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc4.putObject( idType, idsolidColorLayer, desc5 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc3.putObject( idUsng, idcontentLayer, desc4 );
executeAction( idMk, desc3, DialogModes.NO );
return app.activeDocument.activeLayer
};
////// split area until one distinct area is defined for every one of the total number //////
// from »Flatten All Masks.jsx« by jeffrey tranberry;
///////////////////////////////////////////////////////////////////////////////
// Function: hasVectorMask
// Usage: see if there is a vector layer mask
// Input: <none> Must have an open document
// Return: true if there is a vector mask
///////////////////////////////////////////////////////////////////////////////
function hasVectorMask() {
var hasVectorMask = false;
try {
var ref = new ActionReference();
var keyVectorMaskEnabled = app.stringIDToTypeID( 'vectorMask' );
var keyKind = app.charIDToTypeID( 'Knd ' );
ref.putEnumerated( app.charIDToTypeID( 'Path' ), app.charIDToTypeID( 'Ordn' ), keyVectorMaskEnabled );
var desc = executeActionGet( ref );
if ( desc.hasKey( keyKind ) ) {
var kindValue = desc.getEnumerationValue( keyKind );
if (kindValue == keyVectorMaskEnabled) {
hasVectorMask = true;
}
}
}catch(e) {
hasVectorMask = false;
}
return hasVectorMask;
};
Code: Select all// use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
myDocument = app.activeDocument;
var theResolution = myDocument.resolution;
myDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
var theArray = [[[[800.995174467564,784.983918964863],[800.995174467564,784.983918964863],[848.242373168468,784.983918964863],false],[[549.0091817379,784.983918964863],[549.0091817379,784.983918964863],[549.0091817379,784.983918964863],false],[[549.0091817379,343.017694413662],[549.0091817379,343.017694413662],[549.0091817379,343.017694413662],false],[[863.991184949875,343.017694413662],[863.991184949875,343.017694413662],[863.991184949875,343.017694413662],false],[[863.991184949875,721.845724880695],[863.991184949875,769.198992431164],[863.991184949875,721.845724880695],false],true,app.stringIDToTypeID('xor')],[[[745.873188197613,690.276438832283],[758.920056581497,690.276438832283],[732.826404631138,690.276438832283],true],[[769.496787548065,666.599364042282],[769.496787548065,653.523276209831],[769.496787548065,679.676396906376],true],[[745.873188197613,642.923297286034],[732.826404631138,642.923297286034],[758.920056581497,642.923297286034],true],[[722.24967366457,666.599364042282],[722.24967366457,679.676396906376],[722.24967366457,653.523276209831],true],true,app.stringIDToTypeID('xor')],[[[580.507483839989,674.49207931757],[580.507483839989,674.49207931757],[580.507483839989,674.49207931757],false],[[612.005192220211,674.49207931757],[612.005192220211,674.49207931757],[612.005192220211,674.49207931757],false],[[612.005192220211,706.061365365982],[612.005192220211,706.061365365982],[612.005192220211,706.061365365982],false],[[643.5034943223,706.061365365982],[643.5034943223,706.061365365982],[643.5034943223,706.061365365982],false],[[643.5034943223,674.49207931757],[643.5034943223,674.49207931757],[643.5034943223,674.49207931757],false],[[675.001881241798,674.49207931757],[675.001881241798,674.49207931757],[675.001881241798,674.49207931757],false],[[675.001881241798,642.923297286034],[675.001881241798,642.923297286034],[675.001881241798,642.923297286034],false],[[643.5034943223,642.923297286034],[643.5034943223,642.923297286034],[643.5034943223,642.923297286034],false],[[643.5034943223,611.353948235512],[643.5034943223,611.353948235512],[643.5034943223,611.353948235512],false],[[612.005192220211,611.353948235512],[612.005192220211,611.353948235512],[612.005192220211,611.353948235512],false],[[612.005192220211,642.923297286034],[612.005192220211,642.923297286034],[612.005192220211,642.923297286034],false],[[580.507483839989,642.923297286034],[580.507483839989,642.923297286034],[580.507483839989,642.923297286034],false],true,app.stringIDToTypeID('xor')],[[[832.492798030376,374.586476445198],[832.492798030376,374.586476445198],[832.492798030376,374.586476445198],false],[[580.507483839989,374.586476445198],[580.507483839989,374.586476445198],[580.507483839989,374.586476445198],false],[[580.507483839989,579.785166203976],[580.507483839989,579.785166203976],[580.507483839989,579.785166203976],false],[[832.492798030376,579.785166203976],[832.492798030376,579.785166203976],[832.492798030376,579.785166203976],false],true,app.stringIDToTypeID('xor')],[[[808.8698772192,627.138370752335],[795.823093652725,627.138370752335],[821.917339324951,627.138370752335],true],[[785.246277868748,650.815508544445],[785.246277868748,663.891533374786],[785.246277868748,637.738916695118],true],[[808.8698772192,674.49207931757],[821.917339324951,674.49207931757],[795.823093652725,674.49207931757],true],[[832.492798030376,650.815508544445],[832.492798030376,637.738916695118],[832.492798030376,663.891533374786],true],true,app.stringIDToTypeID('xor')]];
var thePath = createPath2012(theArray, Math.random());
var theLayer = makeSolidColorLayer("shape", 150, 255, 0);
// reset;
myDocument.resizeImage (undefined, undefined, theResolution, ResampleMethod.NONE);
preferences.rulerUnits = originalRulerUnits;
};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2012(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// thanks to xbytor;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Path'), cTID('WrPt'));
desc1.putReference(sTID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
list3.putObject(cTID('Pthp'), desc4);
};
desc3.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc3);
desc2.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc2);
};
desc1.putList(cTID('T '), list1);
executeAction(cTID('setd'), desc1, DialogModes.NO);
if (hasVectorMask() == false) {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 1];
}
else {
if (thePathsName != undefined) {app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2].name = thePathsName};
var myPathItem = app.activeDocument.pathItems[app.activeDocument.pathItems.length - 2];
};
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
};
////// the fill-layer-function //////
function makeSolidColorLayer (theName, theR, theG, theB) {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref1.putClass( idcontentLayer );
desc3.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var desc4 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc5 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc6 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc6.putDouble( idRd, theR );
var idGrn = charIDToTypeID( "Grn " );
desc6.putDouble( idGrn, theG );
var idBl = charIDToTypeID( "Bl " );
desc6.putDouble( idBl, theB );
var idRGBC = charIDToTypeID( "RGBC" );
desc5.putObject( idClr, idRGBC, desc6 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc4.putObject( idType, idsolidColorLayer, desc5 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc3.putObject( idUsng, idcontentLayer, desc4 );
executeAction( idMk, desc3, DialogModes.NO );
return app.activeDocument.activeLayer
};
////// split area until one distinct area is defined for every one of the total number //////
// from »Flatten All Masks.jsx« by jeffrey tranberry;
///////////////////////////////////////////////////////////////////////////////
// Function: hasVectorMask
// Usage: see if there is a vector layer mask
// Input: <none> Must have an open document
// Return: true if there is a vector mask
///////////////////////////////////////////////////////////////////////////////
function hasVectorMask() {
var hasVectorMask = false;
try {
var ref = new ActionReference();
var keyVectorMaskEnabled = app.stringIDToTypeID( 'vectorMask' );
var keyKind = app.charIDToTypeID( 'Knd ' );
ref.putEnumerated( app.charIDToTypeID( 'Path' ), app.charIDToTypeID( 'Ordn' ), keyVectorMaskEnabled );
var desc = executeActionGet( ref );
if ( desc.hasKey( keyKind ) ) {
var kindValue = desc.getEnumerationValue( keyKind );
if (kindValue == keyVectorMaskEnabled) {
hasVectorMask = true;
}
}
}catch(e) {
hasVectorMask = false;
}
return hasVectorMask;
};
-
norm
custom shape point data
@mike yeah that is defiantly recreating the path, the path to shape part didn't work but I replaced that with something I already had written.
As you identified the major issues comes from the faulty paths with regard to the inner details not being created. With a little experimentation I've discovered the problem lies with paths created with csh shapes. If you have a shape drawn entirely with the pen tool and have all points set to exclude overlapping shapes you can recreate a carbon copy of the shape using your script.
I think I have enough now to forge together the script I was trying to create with all of the snippets from this post so thanks for all the input guys
@pfaffenbichler thats for the new script I'll take a look at it.
As you identified the major issues comes from the faulty paths with regard to the inner details not being created. With a little experimentation I've discovered the problem lies with paths created with csh shapes. If you have a shape drawn entirely with the pen tool and have all points set to exclude overlapping shapes you can recreate a carbon copy of the shape using your script.
I think I have enough now to forge together the script I was trying to create with all of the snippets from this post so thanks for all the input guys
@pfaffenbichler thats for the new script I'll take a look at it.