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

getCustomOptions, putCustomOptions

Guest
Nov 10, 2010 Nov 10, 2010

Copy link to clipboard

Copied

I have a Photoshop CS5 panel that I want to have the functionality to save/load preset values.

I used a Local Shared Object in Photoshop CS4. Worked fine. WOuld not work with Photoshop CS5. Compiles but does not work. So, I rewrote the code to use getCustomOptions and putCustomOptions. Again, compiles without a warning or error, but the code does nothing.

It acts like the functions are unimplemented code stubs.

Does anyone have a suggestion for saving/loading runtime values with Photoshop CS5.

I'm using Flex4 Standard. Code samples follow.

Thanks,

Mitch

/** Handle Photoshop Registry **/

private function getSharedObject():void{

try {

// Fetch settings from Photoshop Registry

var defaultsExist:Boolean = true;

var desc:ActionDescriptor = Photoshop.app.getCustomOptions("TLRCapturePro.PanelVersion");

// If DefaultsExist was reset to false, load PanelVersion;

if (defaultsExist == false) {

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.PanelVersion")

}

// If settings are from older verison, create and save them;

if (desc.getString(0) != panelVersion){

resetDefaults();

flushSharedObject();

}

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.PresetDefault");

PresetSetting = desc.getInteger(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.USMDefaults");

USMAmountSetting = desc.getInteger(0);

USMRadiusSetting = desc.getInteger(1);

USMThresholdSetting = desc.getInteger(2);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.LayerBlendDefault");

LayerBlendSetting = desc.getInteger(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.LayerOpacityDefault");

LayerOpacitySetting = desc.getInteger(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.MaskWidthDefault");

MaskWidthSetting = desc.getInteger(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.BlendIfDefaults");

SharpeningBlendIf1Setting = desc.getInteger(0);

SharpeningBlendIf2Setting = desc.getInteger(1);

SharpeningBlendIf3Setting = desc.getInteger(2);

SharpeningBlendIf4Setting = desc.getInteger(3);

UnderlyingBlendIf1Setting = desc.getInteger(4);

UnderlyingBlendIf2Setting = desc.getInteger(5);

UnderlyingBlendIf3Setting = desc.getInteger(6);

UnderlyingBlendIf4Setting = desc.getInteger(7);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.UseEnhancedMasksDefault");

UseEnhancedMasksSetting = desc.getBoolean(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.RetainAlphaChannelsDefault");

RetainAlphaChannelsSetting = desc.getBoolean(0);

desc = Photoshop.app.getCustomOptions(

"TLRCapturePro.PresetList");

PresetList =

new XMLList(desc.getString(0));

PresetLabelList =

new XMLList(PresetList.preset.attribute("label"));

}

catch(error:Error) {

resetDefaults();

flushSharedObject();

defaultsExist =

false;

}

}

private function flushSharedObject():void{

try {

var desc:ActionDescriptor = new ActionDescriptor;

desc.putString(0,panelVersion);

Photoshop.app.putCustomOptions(

"TLRCapturePro.PanelVersion",desc,true);

desc =

new ActionDescriptor;

desc.putInteger(0,USMAmountSetting);

desc.putInteger(1,USMRadiusSetting);

desc.putInteger(2,USMThresholdSetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.USMDefaults",desc,true);

desc =

new ActionDescriptor;

desc.putInteger(0,LayerBlendSetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.LayerBlendDefault",desc,true);

desc =

new ActionDescriptor;

desc.putInteger(0,LayerOpacitySetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.LayerOpacityDefault",desc,true);

desc =

new ActionDescriptor;

desc.putInteger(0,MaskWidthSetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.MaskWidthDefault",desc,true);

desc =

new ActionDescriptor;

desc.putInteger(0,SharpeningBlendIf1Setting);

desc.putInteger(1,SharpeningBlendIf2Setting);

desc.putInteger(2,SharpeningBlendIf3Setting);

desc.putInteger(3,SharpeningBlendIf4Setting);

desc.putInteger(4,UnderlyingBlendIf1Setting);

desc.putInteger(5,UnderlyingBlendIf2Setting);

desc.putInteger(6,UnderlyingBlendIf3Setting);

desc.putInteger(7,UnderlyingBlendIf4Setting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.BlendIfDefaults",desc,true);

desc =

new ActionDescriptor;

desc.putBoolean(0,UseEnhancedMasksSetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.UseEnhancedMasksDefault",desc,true);

desc =

new ActionDescriptor;

desc.putBoolean(0,RetainAlphaChannelsSetting);

Photoshop.app.putCustomOptions(

"TLRCapturePro.RetainAlphaChannelsDefault",desc,true);

desc =

new ActionDescriptor;

desc.putString(0,PresetList.toXMLString());

Photoshop.app.putCustomOptions(

"TLRCapturePro.PresetList",desc,true);

}

catch(error:Error) {

Alert.show(

"Error in flushSharedObject(): " + error.message, "Error!", Alert.OK, Sprite(mx.core.Application.application));

}

}

private function resetDefaults():void{

try {

PresetList =

new XMLList(

<presets>

<preset label="(None)" settings="300,0.8,0,1,65,1,30,50,100,195,25,50,80,200" canDelete="false" canEdit="false" />

<preset label="HRDC: Wide Edges" settings="275,1,0,1,65,0,30,50,100,195,25,50,80,200" canDelete="false" canEdit="false" />

<preset label="HRDC: Medium Edges" settings="300,0.8,0,1,65,1,30,50,100,195,25,50,80,200" canDelete="false" canEdit="false" />

<preset label="HRDC: Narrow Edges" settings="300,0.6,0,1,65,2,30,50,100,195,25,50,80,200" canDelete="false" canEdit="false" />

<preset label="HRDC: Extra Narrow Edges" settings="325,0.5,0,1,65,3,30,50,100,195,25,50,80,200" canDelete="false" canEdit="false" />

<preset label="MRDC: Wide Edges" settings="150,1,0,1,65,0,10,40,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="MRDC: Medium Edges" settings="150,0.7,0,1,65,1,10,40,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="MRDC: Narrow Edges" settings="150,0.6,0,1,65,2,10,40,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="MRDC: Extra Narrow Edges" settings="175,0.5,0,1,65,3,10,40,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="LRDC: Wide Edges" settings="65,2.5,0,1,65,0,0,0,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="LRDC: Medium Edges" settings="65,2.5,0,1,65,1,0,0,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="LRDC: Narrow Edges" settings="60,2.5,0,1,65,2,0,0,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="LRDC: Extra Narrow Edges" settings="60,2.5,0,1,65,3,0,0,140,250,10,40,140,250" canDelete="false" canEdit="false" />

<preset label="SFS: Wide Edges" settings="300,0.8,0,1,65,0,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="SFS: Medium Edges" settings="325,1,0,1,65,1,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="SFS: Narrow Edges" settings="350,1,0,1,65,2,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="SFS: Extra Narrow Edges" settings="400,1,0,1,65,3,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="LFS: Wide Edges" settings="375,1.7,0,1,65,0,0,180,0,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="LFS: Medium Edges" settings="375,1.2,0,1,65,1,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="LFS: Narrow Edges" settings="400,1.3,0,1,65,2,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

<preset label="LFS: Extra Narrow Edges" settings="400,1.2,0,1,65,3,0,0,180,250,10,30,180,250" canDelete="false" canEdit="false" />

</presets>

);

PresetLabelList = XMLList(PresetList.preset.attribute(

"label"));

PresetSetting = 0;

USMAmountSetting = 300;

USMRadiusSetting = 0.8;

USMThresholdSetting = 0;

LayerBlendSetting = 1;

LayerOpacitySetting = 65;

MaskWidthSetting = 1;

SharpeningBlendIf1Setting = 16;

SharpeningBlendIf2Setting = 24;

SharpeningBlendIf3Setting = 208;

SharpeningBlendIf4Setting = 224;

UnderlyingBlendIf1Setting = 24;

UnderlyingBlendIf2Setting = 32;

UnderlyingBlendIf3Setting = 176;

UnderlyingBlendIf4Setting = 208;

UseEnhancedMasksSetting =

false;

RetainAlphaChannelsSetting =

false

}

catch(error:Error) {

Alert.show(

"Error in resetDefaults(): " + error.message, "Error!", Alert.OK, Sprite(mx.core.Application.application));

}

}

TOPICS
SDK

Views

1.9K

Translate

Translate

Report

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
Adobe
Adobe Employee ,
Nov 11, 2010 Nov 11, 2010

Copy link to clipboard

Copied

For panels you should use the CSXSInterface to store and retrieve settings.

import com.adobe.csxs.core.CSXSInterface;

import com.adobe.csxs.events.*;

import com.adobe.csxs.types.*;

....

csxs = CSXSInterface.getInstance();

.....

// Getting

result = csxs.retrievePreference("rbUseLogoFile");

if (SyncRequestResult.COMPLETE == result.status && result.data) {

rbUseLogoFile.selected = result.data.toString() == "true";

}

// Storing

csxs.storePreference("rbUseLogoFile", rbUseLogoFile.selected.toString());

Votes

Translate

Translate

Report

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
Guest
Nov 11, 2010 Nov 11, 2010

Copy link to clipboard

Copied

Thanks, Tom. I was hoping very much to hear from you about this. I'll make the changes and give this a try!

You're the best!

Mitch

Votes

Translate

Translate

Report

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
Guest
Nov 11, 2010 Nov 11, 2010

Copy link to clipboard

Copied

LATEST

It worked! Thanks A LOT!

Votes

Translate

Translate

Report

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