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

Code to be evaluated! [013] Auto-numbering Bullets and wrapping! …

LEGEND ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

Hi all!

A nice layout headache to finish the year! …

Video:  Bullets Wrapping Layout! … - YouTube

Capture d’écran 2016-12-30 à 18.45.34.png

Capture d’écran 2016-12-30 à 18.44.56.png

Capture d’écran 2016-12-30 à 18.45.14.png

Cool to imagine and write! … but Hot for me!

Thanks for your comments! 

app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Bullets + Wrapping! …"); 

 

function main() 

{

    var myDoc = app.activeDocument;

    var savedHorizontalMeasurementUnits = myDoc.viewPreferences.horizontalMeasurementUnits; 

    var savedVerticalMeasurementUnits = myDoc.viewPreferences.verticalMeasurementUnits; 

    myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS; 

    myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;

    var myParas = app.selection[0].paragraphs.everyItem().getElements();   

    var P = myParas.length;

    while (P--)

        {

            app.findGrepPreferences = app.changeGrepPreferences = null;

            app.findGrepPreferences.findWhat = "^(~a|~i)";

            app.changeGrepPreferences.changeTo = "";

            myParas

.changeGrep();

        }

 

    ///////  FIRST PARA ///////

    var myP = myParas[0];

   

    var myL = myP.lines;

    var L = myL.length;

    while ( L-- )

        {

            var A = myL.insertionPoints[0].horizontalOffset;

            var B = myL[L-1].insertionPoints[0].horizontalOffset;

            if ( A != B )

            {

                var myX = myL.insertionPoints[0].horizontalOffset;

                var myY = myL.characters[0].baseline;

                var myH = myL.paragraphs[0].characters[-1].baseline - myY;

                myAnchor = myL.paragraphs[0].insertionPoints[0].rectangles.add({geometricBounds: [myY, myX, myY + myH, myX + UnitValue('5mm').as('pt')]});

                myAnchor.appliedObjectStyle = myDoc.objectStyles.item("In-Visible");

                var myGB = myAnchor.geometricBounds;

                var transMatrix = app.transformationMatrices.add({verticalTranslation: myY - myGB[0] - 1, horizontalTranslation: myX - UnitValue('10mm').as('pt')}); 

                myAnchor.transform(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.TOP_LEFT_ANCHOR, transMatrix);

                break;

            }

        }

    var myParas = app.selection[0].paragraphs.everyItem().getElements();   

    var P = myParas.length;

    ///////  INTERMEDIATE PARAS ///////

    for ( var p = 1; p < P-1 ; p++ )

        { 

            var myP = myParas

;

   

            app.findGrepPreferences = app.changeGrepPreferences = null;

            app.findGrepPreferences.findWhat = "~a|~i";

            app.changeGrepPreferences.changeTo = "";

            myP.changeGrep();

            app.findGrepPreferences = app.changeGrepPreferences = null;

            app.findGrepPreferences.findWhat = "^.";

            app.changeGrepPreferences.changeTo = "~i$0";

            myP.changeGrep();

            app.findGrepPreferences = app.changeGrepPreferences = null;

        }

    ///////  LAST PARA ///////

    var myP = myParas[P-1];

   

    var myL = myP.lines;

    var L = myL.length;

    while ( L-- )

        {

            var A = myL.insertionPoints[0].horizontalOffset;

            var B = myL[L-1].insertionPoints[0].horizontalOffset;

            if ( A != B )

            {

                var myY0 = myL[1].baseline;

                var myX1 = myL[1].insertionPoints[0].horizontalOffset;

                var myY2 = myL[L-1].baseline;

                var myX3 = myX1+ UnitValue('5mm').as('pt');

                myAnchor = myL[1].insertionPoints[0].rectangles.add({geometricBounds: [myY0, myX1, myY2, myX3]});

                myAnchor.appliedObjectStyle = myDoc.objectStyles.item("In-Visible");

                exit();

            }

        }

  

    myDoc.viewPreferences.horizontalMeasurementUnits = savedHorizontalMeasurementUnits; 

    myDoc.viewPreferences.verticalMeasurementUnits = savedVerticalMeasurementUnits; 

}

(^/)

TOPICS
Scripting

Views

666

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
LEGEND ,
Dec 31, 2016 Dec 31, 2016

Copy link to clipboard

Copied

LATEST

For those who have nothing to do today! … play with bullets!

[IDCC2015-IDML files and Script_Beta1-version]

https://www.dropbox.com/s/kcgu9p334nqse8f/0073_BulletsWrapping_MichelAllio.zip?dl=0

(^/)

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