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

How read stroke type in dropdownlist?

Contributor ,
Jul 04, 2019 Jul 04, 2019

Hi experts,

my script like this:

function mDialog ()

{

    mMsg.funName = "mDialog";

var

        colorList = app.activeDocument.swatches.everyItem().name,

        strokeTypeList = app.activeDocument.strokeType.everyItem().name,

  curPartHistory = eval( app.extractLabel(mMsg.title) );

if (!curPartHistory || false)

  curPartHistory = {

   w: 0,

   c: 0

   };

     var

        w1 = new Window("dialog","", undefined, {closeButton: false}),  

            mPanel = w1.add("panel", undefined, "Add cell’s bottom edge"),

                mSpace = mPanel.add("group"),

                topLine = mPanel.add("group"),

                    mSt = topLine.add("statictext", undefined, "Line weight: "),

                    mEd = topLine.add("edittext", undefined, String(curPartHistory.w) ),

                    mSt1 = topLine.add("statictext", undefined, "pt"),

               botLine = mPanel.add("group"),

                    mSt2 = botLine.add("statictext", undefined, "Line color: "),

                    mDD = botLine.add("dropdownlist", undefined, colorList),

               botLine = mPanel.add("group"),

                    mSt3 = botLine.add("statictext", undefined, "Stroke type: "),

                    mLL = botLine.add("dropdownlist", undefined, strokeTypeList),

        mButtons = w1.add("group");

  

mButtons.add ('button', undefined, "取り消す", {name: "Cancel"});

mButtons.add ('button', undefined, "OK", {name: "OK"});

   

    mSt1.graphics.font = ScriptUI.newFont ("Verdana", "Italic", 10);

   

    mPanel.alignChildren= "left";

    mEd.characters = 3;

    mDD.selection = curPartHistory.c<colorList.length ? mDD.items[curPartHistory.c] : mDD.items[0];

   

    w1.location = [150,150];

    //|||||||||||||||||||||||||||||||||||||||||||| DIALOG OUTPUT |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  

if (w1.show() ==1 ) {

  with (curPartHistory) {

   w = Number(mEd.text);

   c = mDD.selection.index;

   }

  app.insertLabel(mMsg.title, curPartHistory.toSource() );

  return curPartHistory;

  }

else exit();

    }

if read my color swatches like this:

colorList = app.activeDocument.swatches.everyItem().name,

How can define the stroke, and read the stroke type in list:

strokeTypeList = app.activeDocument.strokeType.everyItem().name,

above like  seems not the correct syntax

could some one show me how, please.

thanks

regar

John

TOPICS
Scripting
452
Translate
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 04, 2019 Jul 04, 2019

Hi John,

Maybe the following will get you what you are finding

app.activeDocument.strokeStyles.everyItem().name

-Manan

Translate
Community Expert ,
Jul 04, 2019 Jul 04, 2019

Hi John,

strokeType is no property of document.

You could walk through the strokeStyles of a document.

For strokeStyle we have property strokeStyleType.

The value of  strokeStyleType for the build in strokeStyles is an empty string.

For the custom ones a user has added, the value is different. E.g. "Streifen" if it is added with a German InDesign.

Below an example from a document with my German InDesign where a user added a custom stroke style with strokeType striped ( "Streifen" 😞

var doc = app.documents[0] ;

var docStrokeStyles = doc.strokeStyles ;

var docStrokeStylesLength = docStrokeStyles.length;

var resultArray = [];

for( var n=0; n<docStrokeStylesLength ; n++ )

{

    resultArray =

        n +"\t"+

        docStrokeStyles.name +"\t" +

        app.findKeyStrings( docStrokeStyles.name ).join("\t") ; // Always returns an array

  

    if( docStrokeStyles.strokeStyleType == "" )

    {

        continue ;

    };

  

    resultArray = resultArray +"\t"+

    docStrokeStyles.strokeStyleType +"\t"+

    app.findKeyStrings( docStrokeStyles.strokeStyleType ).join("\t") ;

};

$.writeln( resultArray.join("\r") );

/*

  

Result from my German InDesign with a document where a user defined one custom stroke style.

It's strokeStyleType in my German InDesign is "Streifen". International string for this is "$ID/Stripe_DefaultInstName".

0    Dreifach    $ID/Triple_Stroke

1    Breit - Schmal - Breit    $ID/ThickThinThick

2    Schmal - Breit - Schmal    $ID/ThinThickThin

3    Breit - Breit    $ID/ThickThick

4    Breit - Schmal    $ID/ThickThin

5    Schmal - Breit    $ID/ThinThick

6    Schmal - Schmal    $ID/ThinThin

7    Japanische Punkte    $ID/Japanese Dots

8    Weiße Rauten    $ID/White Diamond

9    Schraffiert (nach links geneigt)    $ID/Left Slant Hash

10    Schraffiert (nach rechts geneigt)    $ID/Right Slant Hash

11    Schraffiert (gerade)    $ID/Straight Hash

12    Wellenlinie    $ID/Wavy    $ID/#ConditionTagOptions_WavyUnderline

13    Gepunktet    $ID/Canned Dotted    $ID/Dotted_DefaultInstName    $ID/Dotted_MetadataName

14    Gestrichelt (3 und 2)    $ID/Canned Dashed 3x2

15    Gestrichelt (4 und 4)    $ID/Canned Dashed 4x4

16    Gestrichelt    $ID/Dashed    $ID/#ConditionTagOptions_DashedUnderline

17    Durchgezogen    $ID/Solid    $ID/#ConditionTagOptions_SolidUnderline

18    CustomStrokeStyle-1        Streifen    $ID/Stripe_DefaultInstName    $ID/Stripe_MetadataName

*/

Regards,
Uwe

Translate
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 04, 2019 Jul 04, 2019

Hi John,

Maybe the following will get you what you are finding

app.activeDocument.strokeStyles.everyItem().name

-Manan

Translate
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
Contributor ,
Jul 04, 2019 Jul 04, 2019
LATEST

Hi Man,

thank you for your help.

but how to show the line type in the dropdownlist?

something like this:

未命名-1.jpg

thanks

regard

John

Translate
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