Highlighted

how to use "vectorMaskLinked"

Engaged ,
Jul 11, 2019

Copy link to clipboard

Copied

hello,

     How did i get  the  "vectorMaskLinked" properties,The following code indicates that the property does not exist.

   try { 

        var r = new ActionReference(); 

       r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); 

        var options = executeActionGet(r);     

   //   alert(options.getBoolean(stringIDToTypeID("userMaskLinked")));

      alert(options.getBoolean(stringIDToTypeID("vectorMaskLinked")))

        

       } 

    catch (e) { alert(e); } 

Any tips will be appreciated,tks!

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Flaw adobe.

For CC2018, you can use this, but only for the active layer.

var r = new ActionReference();   

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));

r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var title = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu")).getObjectValue(3).getList(stringIDToTypeID("submenu")).getObjectValue(14).getList(stringIDToTypeID("submenu")).getObjectValue(5).getString(stringIDToTypeID("title"));

//alert(title)

var linked = title.match(/^un/i)?true:false;

alert(linked);

Topics

Actions and scripting

Views

809

Likes

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

how to use "vectorMaskLinked"

Engaged ,
Jul 11, 2019

Copy link to clipboard

Copied

hello,

     How did i get  the  "vectorMaskLinked" properties,The following code indicates that the property does not exist.

   try { 

        var r = new ActionReference(); 

       r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); 

        var options = executeActionGet(r);     

   //   alert(options.getBoolean(stringIDToTypeID("userMaskLinked")));

      alert(options.getBoolean(stringIDToTypeID("vectorMaskLinked")))

        

       } 

    catch (e) { alert(e); } 

Any tips will be appreciated,tks!

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Flaw adobe.

For CC2018, you can use this, but only for the active layer.

var r = new ActionReference();   

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));

r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var title = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu")).getObjectValue(3).getList(stringIDToTypeID("submenu")).getObjectValue(14).getList(stringIDToTypeID("submenu")).getObjectValue(5).getString(stringIDToTypeID("title"));

//alert(title)

var linked = title.match(/^un/i)?true:false;

alert(linked);

Topics

Actions and scripting

Views

810

Likes

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
Adobe Community Professional ,
Jul 12, 2019

Copy link to clipboard

Copied

Flaw adobe.

For CC2018, you can use this, but only for the active layer.

var r = new ActionReference();   

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));

r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var title = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu")).getObjectValue(3).getList(stringIDToTypeID("submenu")).getObjectValue(14).getList(stringIDToTypeID("submenu")).getObjectValue(5).getString(stringIDToTypeID("title"));

//alert(title)

var linked = title.match(/^un/i)?true:false;

alert(linked);

Likes

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
Reply
Loading...
Participant ,
Jun 10, 2020

Copy link to clipboard

Copied

Just stumbled on this.  It doesn't seem to work in 2020.  the whole "menuBarInfo" property seems to be missing from the "application" object.

 

That said, it feels to me like a terrible solution, for obvious reasons...   Is there anything new to get to the "vectorMaskLinked" property of a layer ?

 

Thanks.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jun 10, 2020

Copy link to clipboard

Copied

The script needs to be redone more cleverly so that it does not depend on the order of the menu.
But now just replace getObjectValue(3) with getObjectValue(4).
 
 

Likes

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
Reply
Loading...
Participant ,
Jun 10, 2020

Copy link to clipboard

Copied

Thanks for taking the time to answer.  Hope I didn't sound to harsh when I said this was a "terrible solution".  😉

 

That being said, it still doesn't work.  Take a look at what I get when I dump all of the "application"object properties, there's no "menuVarInfo".  I do notice there's an empty one though.  Could that be it, is this a bug ?

 

function exploreAM() {
  var str = "";
  r = new ActionReference ();
  r.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
  d = executeActionGet (r);//.getEnumerationValue(stringIDToTypeID("mode"));

  for (var i = 0; i <d.count; i++){
    str += typeIDToStringID(d.getKey(i)) + ':' + d.getType(d.getKey(i)) + '\n';
  }
  alert (str);
}

Returns : 

exactPoints:DescValueType.BOOLEANTYPE
numberOfCacheLevels:DescValueType.INTEGERTYPE
numberOfCacheLevels64:DescValueType.INTEGERTYPE
useCacheForHistograms:DescValueType.BOOLEANTYPE
interpolationMethod:DescValueType.ENUMERATEDTYPE
showToolTips:DescValueType.BOOLEANTYPE
:DescValueType.ENUMERATEDTYPE
serialString:DescValueType.STRINGTYPE
hostName:DescValueType.STRINGTYPE
gridMajor:DescValueType.INTEGERTYPE
gradientClassEvent:DescValueType.INTEGERTYPE
watchSuspension:DescValueType.INTEGERTYPE
numberOfDocuments:DescValueType.INTEGERTYPE
interfaceWhite:DescValueType.OBJECTTYPE
interfaceButtonUpFill:DescValueType.OBJECTTYPE
interfaceBevelShadow:DescValueType.OBJECTTYPE
interfaceIconFillActive:DescValueType.OBJECTTYPE
interfaceIconFillDimmed:DescValueType.OBJECTTYPE
interfacePaletteFill:DescValueType.OBJECTTYPE
interfaceIconFrameDimmed:DescValueType.OBJECTTYPE
interfaceIconFrameActive:DescValueType.OBJECTTYPE
interfaceBevelHighlight:DescValueType.OBJECTTYPE
interfaceButtonDownFill:DescValueType.OBJECTTYPE
interfaceIconFillSelected:DescValueType.OBJECTTYPE
interfaceBorder:DescValueType.OBJECTTYPE
interfaceButtonDarkShadow:DescValueType.OBJECTTYPE
interfaceIconFrameSelected:DescValueType.OBJECTTYPE
interfaceRed:DescValueType.OBJECTTYPE
interfaceBlack:DescValueType.OBJECTTYPE
interfaceToolTipBackground:DescValueType.OBJECTTYPE
interfaceToolTipText:DescValueType.OBJECTTYPE
interfaceTransparencyForeground:DescValueType.OBJECTTYPE
interfaceTransparencyBackground:DescValueType.OBJECTTYPE
interfaceOWLPaletteFill:DescValueType.OBJECTTYPE
interfaceButtonText:DescValueType.OBJECTTYPE
interfaceCanvasColor:DescValueType.OBJECTTYPE
interfaceStaticText:DescValueType.OBJECTTYPE
interfaceButtonShadow:DescValueType.OBJECTTYPE
historyPreferences:DescValueType.OBJECTTYPE
hostVersion:DescValueType.OBJECTTYPE
eyeDropperSample:DescValueType.ENUMERATEDTYPE
colorPickerPrefs:DescValueType.OBJECTTYPE
globalAngle:DescValueType.OBJECTTYPE
generalPreferences:DescValueType.OBJECTTYPE
interfacePrefs:DescValueType.OBJECTTYPE
workspacePreferences:DescValueType.OBJECTTYPE
toolsPreferences:DescValueType.OBJECTTYPE
historyLogPreferences:DescValueType.OBJECTTYPE
fileSavePrefs:DescValueType.OBJECTTYPE
exportAssetsPrefs:DescValueType.OBJECTTYPE
cachePrefs:DescValueType.OBJECTTYPE
scratchDiskPreferences:DescValueType.OBJECTTYPE
displayPrefs:DescValueType.OBJECTTYPE
transparencyPrefs:DescValueType.OBJECTTYPE
unitsPrefs:DescValueType.OBJECTTYPE
guidesPrefs:DescValueType.OBJECTTYPE
pluginPicker:DescValueType.OBJECTTYPE
typePreferences:DescValueType.OBJECTTYPE
z3DPrefs:DescValueType.OBJECTTYPE
experimentalFeatures:DescValueType.OBJECTTYPE
transparencyGamutPreferences:DescValueType.ENUMERATEDTYPE
colorSettings:DescValueType.OBJECTTYPE
foregroundColor:DescValueType.OBJECTTYPE
backgroundColor:DescValueType.OBJECTTYPE
path:DescValueType.ALIASTYPE
preferencesFolder:DescValueType.ALIASTYPE
kuiBrightnessLevel:DescValueType.ENUMERATEDTYPE
controlColor:DescValueType.ENUMERATEDTYPE
highlightColorOption:DescValueType.ENUMERATEDTYPE
limited:DescValueType.BOOLEANTYPE
defaultAppScript:DescValueType.INTEGERTYPE
regionCode:DescValueType.INTEGERTYPE
presetManager:DescValueType.LISTTYPE
fontList:DescValueType.OBJECTTYPE
fontLargeName:DescValueType.STRINGTYPE
fontLargeSize:DescValueType.INTEGERTYPE
fontSmallName:DescValueType.STRINGTYPE
fontSmallSize:DescValueType.INTEGERTYPE
recentFiles:DescValueType.LISTTYPE
currentToolOptions:DescValueType.OBJECTTYPE
tool:DescValueType.ENUMERATEDTYPE
vectorToolSettings:DescValueType.OBJECTTYPE
buildNumber:DescValueType.STRINGTYPE
systemInfo:DescValueType.STRINGTYPE
osVersion:DescValueType.STRING

 

 

I'm having a hard time understanding why there isn't a "vectorMaskLinked" property on a layer object...Just like there is a "userMaskLinked".  This data has to be stored somewhere doesn't it ?

 

Thanks again.

 

J. 

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jun 10, 2020

Copy link to clipboard

Copied

 

sTT = stringIDToTypeID; (dsc = new ActionDescriptor())
.putInteger(sTT(' '), 3083), typeIDToStringID(dsc.getInteger(sTT(' ')))

 

I guess they wrongly inserted 'vectorMaskLinked' at position 1359, while it shouldn't be in this descriptor amid other keys at all? At least there is no 'userMaskLinked' since that's property of layer. 'vectorMaskLinked' is its property as well (like we can see from layer properties list), but I mean the functionality of it they used in above descriptor instead of putting it in proper 'place'?

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jun 11, 2020

Copy link to clipboard

Copied

What are your problems?
Everything works with the proposed changes for 2020 (for english version)
 

Likes

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
Reply
Loading...
Participant ,
Jun 28, 2020

Copy link to clipboard

Copied

"(for english version)"...

 

That's a problem in itself.  We can't develop extensions with functions that are going to work only for the English version... That doesn't make any sense.

 

We need a proper way to access the vector mask link property...

Likes

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
Reply
Loading...
Participant ,
Jun 28, 2020

Copy link to clipboard

Copied

to Kukurykus : 

 

Not quite sure I get what this little piece of code should be doing...

Are you saying you get a "vectorMaskLinked" when you list all of a layer's properties ?  Cause I don't...  I do have those : 

 

hasVectorMask:DescValueType.BOOLEANTYPE

vectorMaskEnabled:DescValueType.BOOLEANTYPE
vectorMaskEmpty:DescValueType.BOOLEANTYPE

vectorMaskDensity:DescValueType.INTEGERTYPE
vectorMaskFeather:DescValueType.DOUBLETYPE

 

compared to those for the "user mask"

 

hasUserMask:DescValueType.BOOLEANTYPE

userMaskEnabled:DescValueType.BOOLEANTYPE
userMaskLinked:DescValueType.BOOLEANTYPE

userMaskDensity:DescValueType.INTEGERTYPE
userMaskFeather:DescValueType.DOUBLETYPE

 

Now... listing those makes me wonder about that "vectorMaskEmpty" property...

Likes

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
Reply
Loading...
Enthusiast ,
Jun 28, 2020

Copy link to clipboard

Copied

you can get a localized name and just compare it with the name obtained from the menu

var unlinkStr = localize("$$$/Menu/VectorMask/Unlink")
var linkStr = localize("$$$/Menu/VectorMask/Link")

 

Likes

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
Reply
Loading...
Participant ,
Jul 06, 2020

Copy link to clipboard

Copied

Finally had some time to work on this... I think I know why replacing "getObjectValue(3) with getObjectValue(4)" like you proposed isn't working here.  

 

I work in macOS.  Applications in macOS have a "default" menuBar item at position 0 that PC users don't have.  (the "Photoshop" menu beside the apple logo)

in macOsin macOs

 

in Windowsin Windows

So, changing "getObjectValue(3)" to "getObjectValue(5)" does work, since the "layer" submenu is at position 5.

 

So... If I was to use this technique, I guess I'd need a way to validate which OS is currently running...

 

...which brings me back to my original statement... This is a terrible solution.  😕

 

 

That being said, I really appreciate the efforts you guys made to help me with this, and I do get that the "clean" solution might just not exist...

 

Now...   Kukurykus , I still don't get what you mentioned in your comment earlier... but it feels like it could be used somehow to access the missing "vectorMaskLinked" property.   Right ?

 

And if there's no other options to get what I want... is there a way to access a menu bar item with its name instead of its index ?

 

I feel there's a greater risk that Adobe make some changes to the indexes (i.e. by adding or removing a submenu) than to the actual titel of the submenus...

 

 

Thanks !

Likes

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
Reply
Loading...
Enthusiast ,
Jul 06, 2020

Copy link to clipboard

Copied

You can easily get information about the current operating system:

 

$.os

 

To reduce the chance of errors due to a change in menu position you can cycle through the headers to get the object of the desired menu:

 

#target photoshop;

var r = new ActionReference();    
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("menuBarInfo"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var menu = executeActionGet(r).getObjectValue(stringIDToTypeID("menuBarInfo")).getList(stringIDToTypeID("submenu"))

var layersMenu = new ActionDescriptor()
for (var i = 0; i< menu.count; i++) {
    if (menu.getObjectValue(i).getString(stringIDToTypeID('title'))== localize ('$$$/Menu/Layer')) {
        layersMenu = menu.getObjectValue(i)
        break;
    }
}

 

after that, in the same way you can find the Vector Mask submenu:

 

var vectorMaskMenu = new ActionDescriptor()
for (var i = 0; i< layersMenu.count; i++) {
    if (layersMenu.getObjectValue(i).getString(stringIDToTypeID('title'))== localize ('$$$/Menu/Layer/VectorMask')) {
        vectorMaskMenu = layersMenu.getObjectValue(i).getList(stringIDToTypeID("submenu"))
        break;
    }
}

 

... and get the item you need

 

for (var i = 0; i < vectorMaskMenu.count; i++) {
    var title = vectorMaskMenu.getObjectValue(i).getString(stringIDToTypeID('title'))
    if (title == localize("$$$/Menu/VectorMask/Unlink") || title == localize("$$$/Menu/VectorMask/Link")) {
        alert(title == localize("$$$/Menu/VectorMask/Link") ? 'Unlinked' : 'Linked')
    }
}

 

 

As I understand, Kukurykus says that the absence of the vectorMaskLinked option looks like a bug. Even if you write about it in https://feedback.photoshop.com/photoshop_family (give a link to your message if you do), the error will be corrected only in future versions of Photoshop (which will not improve your situation if you need to ensure work extensions in previous versions)

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

New 100 percent working method.
Note - you must check the presence of the vector mask yourself before calling the function, otherwise there will be an error
alert(vector_mask_linked(activeDocument.layers[0].id));

function vector_mask_linked(id)
    {
    try {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putIdentifier(stringIDToTypeID("layer"), id);
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        d1.putBoolean(stringIDToTypeID("vectorMaskLinked"), true);
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layer"), d1);
        var ret = executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

        if (!ret.count) return true;

        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putIdentifier(stringIDToTypeID("layer"), id);
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        d1.putBoolean(stringIDToTypeID("vectorMaskLinked"), false);
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layer"), d1);
        var ret = executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

        return false;
        }
    catch (e) { /*return false*/ throw(e); }
    }

Likes

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
Reply
Loading...
Participant ,
Jul 07, 2020

Copy link to clipboard

Copied

This is brilliant.

 

Thanks a lot mate.

 

OP might want to change the "correct answer" to this latest post... it's a way more interesting solution.

 

 

Likes

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
Reply
Loading...