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

Retrieve Artboard reference of active nested layer

New Here ,
Sep 06, 2015 Sep 06, 2015

Copy link to clipboard

Copied

Hi,

I am looking for a way to get the artboard reference of a currently active layer nested into it. I was browsing around, but I am still quite confused about how to proceed.

Any help very appreciated!

Thank you

TOPICS
Actions and scripting

Views

530

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

correct answers 1 Correct answer

Participant , Sep 07, 2015 Sep 07, 2015

I'm not sure, but maybe it will help you...

var doc = activeDocument,
	currentArtboard = getActiveArtboard();

/* ======================== */
alert(currentArtboard);
/* ======================== */

function getActiveArtboard() {
	while(true) {
		if (isArtboardLayer()) {
			return doc.activeLayer
		}
		selectForwardLayer();
	}
}

function isArtboardLayer() {
	var ref = new ActionReference();
	ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
	var isArtboar
...

Votes

Translate

Translate
Adobe
Participant ,
Sep 07, 2015 Sep 07, 2015

Copy link to clipboard

Copied

I'm not sure, but maybe it will help you...

var doc = activeDocument,
	currentArtboard = getActiveArtboard();

/* ======================== */
alert(currentArtboard);
/* ======================== */

function getActiveArtboard() {
	while(true) {
		if (isArtboardLayer()) {
			return doc.activeLayer
		}
		selectForwardLayer();
	}
}

function isArtboardLayer() {
	var ref = new ActionReference();
	ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
	var isArtboardLayer = executeActionGet(ref).getBoolean(stringIDToTypeID("artboardEnabled"));
	return isArtboardLayer
}

function selectForwardLayer() {
	var desc = new ActionDescriptor();
	var ref = new ActionReference();
	ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Frwr'));
	desc.putReference(charIDToTypeID('null'), ref);
	desc.putBoolean(charIDToTypeID('MkVs'), false);
	executeAction(charIDToTypeID('slct'), desc, DialogModes.NO);
}

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
New Here ,
Sep 07, 2015 Sep 07, 2015

Copy link to clipboard

Copied

Exactly what I was looking for. Thank you nvkzNemo‌ !

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
Participant ,
Sep 07, 2015 Sep 07, 2015

Copy link to clipboard

Copied

LATEST

Or this... better a little

var doc = activeDocument,
	l = doc.activeLayer,
	p = l.parent,
	key = false,
	currentArtboard = getActiveArtboard();

/* ========================= */
alert(currentArtboard);
doc.activeLayer = l;
/* ========================= */

function getActiveArtboard() {
	try{
    	while(!key) {
			doc.activeLayer = p;
			var ref = new ActionReference();
			ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
			key = executeActionGet(ref).getBoolean(stringIDToTypeID("artboardEnabled"));

			if (key) {
				return p
			}

			p = p.parent;
    	}
	}catch (e) {
		alert('That layer without artboard');
		return undefined
	}
} 
		

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