Here is what I have so far. It needs more work but I don't think it will ever be very accurate. function toggleOtherLayersVisibility() { var desc = new ActionDescriptor(); var list = new ActionList(); var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); list.putReference( ref ); desc.putList( charIDToTypeID('null'), list ); desc.putBoolean( charIDToTypeID('TglO'), true ); executeAction( charIDToTypeID('Shw '), desc, DialogModes.NO ); }; function liveShapeFillEnabled( enable ) {// boolean var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); desc.putReference( charIDToTypeID('null'), ref ); var shapeDesc = new ActionDescriptor(); var styleDesc = new ActionDescriptor(); styleDesc.putInteger( stringIDToTypeID('strokeStyleVersion'), 2 ); styleDesc.putBoolean( stringIDToTypeID('fillEnabled'), enable ); shapeDesc.putObject( stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), styleDesc ); desc.putObject( charIDToTypeID('T '), stringIDToTypeID('shapeStyle'), shapeDesc ); executeAction( charIDToTypeID('setd'), desc, DialogModes.NO ); }; function dupeVisibleMerged() { var desc = new ActionDescriptor(); desc.putBoolean( charIDToTypeID('Dplc'), true ); executeAction( charIDToTypeID('MrgV'), desc, DialogModes.NO ); }; function loadTransparency(){ var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) ); desc.putReference( charIDToTypeID( "null" ), ref ); var ref1 = new ActionReference(); ref1.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) ); desc.putReference( charIDToTypeID( "T " ), ref1 ); executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO ); }; function getLiveShapeStrokeInfo(){ var doc = app.activeDocument; var lyr = doc.activeLayer; liveShapeFillEnabled( false ); toggleOtherLayersVisibility(); doc.artLayers.add(); dupeVisibleMerged(); var bounds = doc.activeLayer.bounds; var horzCenter = (bounds[2]-bounds[0])/2; var vertCenter = (bounds[3]-bounds[1])/2; lyr.visible = false; var sampler = doc.colorSamplers.add([bounds[0]+UnitValue(.5,'px'),bounds[1]+vertCenter]); sizeObject.color = sampler.color; loadTransparency(); doc.selection.select([ [bounds[0],bounds[1]+vertCenter], [bounds[0]+horzCenter,bounds[1]+vertCenter], [bounds[0]+horzCenter,bounds[1]+vertCenter+UnitValue(1,'px')], [bounds[0]+UnitValue(1,'px'),bounds[1]+vertCenter+UnitValue(1,'px')]],SelectionType.INTERSECT); sizeObject.size = doc.selection.bounds[2]-doc.selection.bounds[0]; }; var sizeObject = {}; app.activeDocument.suspendHistory('Get Live stroke info','getLiveShapeStrokeInfo()'); executeAction( charIDToTypeID('undo'), undefined, DialogModes.NO ); sizeObject.size;
... View more