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

Creating a conditionSet

Explorer ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hi,
I'm trying to create a condition set thru scripting but i'm not getting how to define the visibility of a condition.
I want do create a condition set where the condition "hide" must be not visible.
Can anyone help me?
Here's the code.
var myDoc = app.activeDocument;
myDoc.conditions.add({name:"exercicio"});
myDoc.conditionSets.add ({name:"Hidden", setConditions: {condition:"exercicio", visible:false }});
 
Thanks
Paulo

 

TOPICS
Scripting

Views

291

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

Community Expert , Jul 19, 2022 Jul 19, 2022

Hi Peter,

it's rather silly; you only can see the Condition Set feature if you expand the feature set of the Conditional Text panel.

 

From my German InDesign; Conditional Text panel not expanded vs expanded:

EnableConditionSetsFeature-GUI.png

 

 

@PauloJC ,

note, that the value for setConditions must be an array of arrays.

See into the DOM documentation for this:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ConditionSet.html

 

The following sample will work:

 

var doc = app.documents[0];
var firstCond = doc.condit
...

Votes

Translate

Translate
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

I've never used conditionSets, didn't even know they existed! What are they for? There's nothing in the interface that shows anything like condition sets.

Anyway, to set a condition's visibility you'll have to do it on the condition itself, not the set:

myDoc.conditions.add({name:"exercicio", visible:false});

P.

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
Explorer ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

LATEST

Conditions Sets stores the visibility of conditions.
Instead of activating or deactivating the visibility of the conditions one by one, we can store the visibility in a condition set.


Screenshot 2022-07-19 at 10.47.11.pngScreenshot 2022-07-19 at 10.47.18.png

Anyway, i've managed following your indications. 

Changed the visibility and then creating the ConditionsSet

myDoc.conditions.add({name:"exercicio", visible:false});
var myConditon = myDoc.conditionSets.add({name:"Professor"});
myDoc.conditions.itemByName("exercicio").visible = true;
var myConditon = myDoc.conditionSets.add({name:"Aluno"});
 
@Peter Kahrel, thanks for the hint.
All the best
Paulo

 

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
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hi Peter,

it's rather silly; you only can see the Condition Set feature if you expand the feature set of the Conditional Text panel.

 

From my German InDesign; Conditional Text panel not expanded vs expanded:

EnableConditionSetsFeature-GUI.png

 

 

@PauloJC ,

note, that the value for setConditions must be an array of arrays.

See into the DOM documentation for this:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ConditionSet.html

 

The following sample will work:

 

var doc = app.documents[0];
var firstCond = doc.conditions.add
(
	{
		name : "Condition 1"
	}
);

var secCond = doc.conditions.add
(
	{
		name : "Condition 2"
	}
);

var myCondSet = doc.conditionSets.add
(
	{
		name : "Hide 1 Show 2", 
		setConditions : 
		[
			[ firstCond , false ] ,
			[ secCond , true ]
		]
	}
);

doc.conditionalTextPreferences.activeConditionSet = myCondSet ;

 

 

Result:

ResultAfterScriptRun-AddConditionSet.PNG

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

PS: Link to DOM documentation added.

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
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Well, what do you know. You live and learn.

Thanks, Uwe.

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
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Had to look it up in the DOM documentation myself.

And it took some time to re-discover the option on the Conditional Texts panel.

I don't use it that often…

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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