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

Define/Redefine styles

Mentor ,
Jun 26, 2012 Jun 26, 2012

Hi,

Is that possible, using script code (method) to define/redefine object/paragraph style based on selected object/paragraph as one can do in UI by click?

thx

TOPICS
Scripting
2.7K
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
Guru ,
Jun 27, 2012 Jun 27, 2012

Easy Peasy.

This is one way of doing it

Go through Jongware's Object reference and go through all the properties of paragraph style and continue the list I started.  Should only take an hour or so.

Do the same with object properties, could take a very lot of hours there But it will work

should be a more normal way to get all the properties but it's time for me to get to sleep

mySelection=app.selection[0]

saps=mySelection.appliedParagraphStyle

newOrRefinedStyle="My new or refined style"; // change the name as you please 😉

(app.activeDocument.paragraphStyles.item(newOrRefinedStyle).isValid) ? 0 : app.activeDocument.paragraphStyles.add ({name: newOrRefinedStyle});

with (app.activeDocument.paragraphStyles.item(newOrRefinedStyle))

{

    alignToBaseline = saps.alignToBaseline;

    allowArbitraryHyphenation = saps.allowArbitraryHyphenation;

    appliedFont = saps.appliedFont;

    appliedLanguage = saps.appliedLanguage;

    // and so on and so on .............

}

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
Mentor ,
Jun 27, 2012 Jun 27, 2012

"

Each scripting item corresponds to a tool or a palette or menu item in an Adobe application. In other

words, each scripting element is something you already know through your Adobe expertise. If you know

what you’d like your Adobe applications to do, you can easily learn to write scripts...

"

Thats one of first sentence in Adobe Introdution to Scripting. Thats why i hoped to find some solution for scripter, not for a monk...

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
Guru ,
Jun 27, 2012 Jun 27, 2012

Ok. I get the point.

To make a new style is realy easy

Just use

tempPS=saps.duplicate ();

tempPS.name=newOrRefinedStyle;

The problem is changing the properties if the style that exits.

You might be able to loop through them

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
Guru ,
Jun 27, 2012 Jun 27, 2012

OK If you don't want to be a monk then

mySelection=app.selection[0]

saps=mySelection.appliedParagraphStyle

newOrRefinedStyle="My new or refined style"; // change the name as you please 😉

tempPS=saps.duplicate ();

try{tempPS.name=newOrRefinedStyle}

catch (exists)

{app.activeDocument.paragraphStyles.item(newOrRefinedStyle).remove (tempPS);

  tempPS.name=newOrRefinedStyle;

  }

use the same idea for the objectstlye.

I'm off to bed now bye ZZZZZZzzzzzz

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
Guru ,
Jun 27, 2012 Jun 27, 2012

Well I think finally cottoned on to what you want to do.

You want the new style not to be based on an existing style of the selection but rather on the properties of the selected paragraph / object that have even though they don't have a style.

The below script does not do that !

It copies styles but might be a guide of how to go about things

You might be able to invoke a menu action to add the new style and then rename it using an addaption of the script bellow

mySelection=app.selection[0]

try {

    sas=mySelection.insertionPoints[0].appliedParagraphStyle;

    pOrOStyles = app.activeDocument.paragraphStyles;

    }

catch (selectionDosentHaveParaStyle) {

    try {

        sas=mySelection.appliedObjectStyle

        pOrOStyles =app.activeDocument.objectStyles;

        }

    catch (selectionDosentHaveObjectStyle) {alert("Select A paragraph with paragraph style or an object with an object style")}

    }

try {

newOrRefinedStyle="My new or refined style"; // change the name as you please 😉

tempPS=sas.duplicate ();

try{tempPS.name=newOrRefinedStyle}

catch (exists)

{

  pOrOStyles.item(newOrRefinedStyle).remove (tempPS);

  tempPS.name=newOrRefinedStyle;

  }

}

catch (noStyle) {}

I was looking through my menu actions and a came across this script by monk Thomas

a partial solution

/*

    Auto create paragraph and character styles

    Version: 1.0

   

    Script by Thomas Silkjær

    http://indesigning.net/

*/

var the_document = app.documents.item(0);

var the_story = app.selection[0].parentStory;

var auto_pstyle_number = 0;

var auto_cstyle_number = 0;

counter = 0;

do {

    var current_paragraph = the_story.paragraphs.item(counter);

   

    counter_2 = 0;

    do {

        pstyle_is_applied = 0;

        if(pstylePropertyDifferences(current_paragraph,the_document.paragraphStyles.item(counter_2),0) != 1) {

            current_paragraph.applyParagraphStyle(the_document.paragraphStyles.item(counter_2),false);

            counter_2 = the_document.paragraphStyles.length;

            pstyle_is_applied = 1;

        }

    counter_2++;   

    } while (counter_2 < the_document.paragraphStyles.length);

   

    if(pstyle_is_applied == 0) {

        auto_pstyle_number++;

        var created_style = pstylePropertyDifferences(current_paragraph,the_document.paragraphStyles.item(0),1);

        created_style.name = "AutoStyle"+auto_pstyle_number;

        current_paragraph.applyParagraphStyle(created_style,false);

    }

   

    counter_3 = 0;

    do {

       

        var current_character = current_paragraph.characters.item(counter_3);

       

        if(current_character.styleOverridden == true) {

            counter_4 = 0;

            do {

                cstyle_is_applied = 0;

                var created_style = cstylePropertyDifferences(current_character,current_paragraph.appliedParagraphStyle,1);

                if(cstylePropertyDifferences(created_style,the_document.characterStyles.item(counter_4),0) != 1) {

                    current_character.applyCharacterStyle(the_document.characterStyles.item(counter_4));

                    counter_4 = the_document.characterStyles.length;

                    cstyle_is_applied = 1;

                }

                created_style.remove();

            counter_4++;   

            } while (counter_4 < the_document.characterStyles.length);

           

            if(cstyle_is_applied == 0) {

                auto_cstyle_number++;

                var created_style = cstylePropertyDifferences(current_character,current_paragraph.appliedParagraphStyle,1);

                created_style.name = "AutoStyle"+auto_cstyle_number;

                current_character.applyCharacterStyle(created_style);

            }

        }

       

    counter_3++;   

    } while (counter_3 < current_paragraph.characters.length);

       

    counter++;

} while (counter < the_story.paragraphs.length);

function pstylePropertyDifferences(the_text,the_style,create_style){

    if(create_style == 1) {

        var temporary_style = the_document.paragraphStyles.add({name:"TempStyle"});

    } else {

        var the_difference = 0;

    }

   

    if (the_text.alignToBaseline != the_style.alignToBaseline) { if(create_style != 0) { temporary_style.alignToBaseline = the_text.alignToBaseline; } else { the_difference = 1; } }

    if (the_text.appliedFont != the_style.appliedFont) { if(create_style != 0) { temporary_style.appliedFont = the_text.appliedFont; } else { the_difference = 1; } }

    if (the_text.appliedLanguage != the_style.appliedLanguage) { if(create_style != 0) { temporary_style.appliedLanguage = the_text.appliedLanguage; } else { the_difference = 1; } }

    if (the_text.appliedNumberingList != the_style.appliedNumberingList) { if(create_style != 0) { temporary_style.appliedNumberingList = the_text.appliedNumberingList; } else { the_difference = 1; } }

    if (the_text.autoLeading != the_style.autoLeading) { if(create_style != 0) { temporary_style.autoLeading = the_text.autoLeading; } else { the_difference = 1; } }

    if (the_text.balanceRaggedLines != the_style.balanceRaggedLines) { if(create_style != 0) { temporary_style.balanceRaggedLines = the_text.balanceRaggedLines; } else { the_difference = 1; } }

    if (the_text.baselineShift != the_style.baselineShift) { if(create_style != 0) { temporary_style.baselineShift = the_text.baselineShift; } else { the_difference = 1; } }

    if (the_text.bulletsAlignment != the_style.bulletsAlignment) { if(create_style != 0) { temporary_style.bulletsAlignment = the_text.bulletsAlignment; } else { the_difference = 1; } }

    if (the_text.bulletsAndNumberingListType != the_style.bulletsAndNumberingListType) { if(create_style != 0) { temporary_style.bulletsAndNumberingListType = the_text.bulletsAndNumberingListType; } else { the_difference = 1; } }

    if (the_text.bulletsCharacterStyle != the_style.bulletsCharacterStyle) { if(create_style != 0) { temporary_style.bulletsCharacterStyle = the_text.bulletsCharacterStyle; } else { the_difference = 1; } }

    if (the_text.bulletsTextAfter != the_style.bulletsTextAfter) { if(create_style != 0) { temporary_style.bulletsTextAfter = the_text.bulletsTextAfter; } else { the_difference = 1; } }

    if (the_text.capitalization != the_style.capitalization) { if(create_style != 0) { temporary_style.capitalization = the_text.capitalization; } else { the_difference = 1; } }

    if (the_text.composer != the_style.composer) { if(create_style != 0) { temporary_style.composer = the_text.composer; } else { the_difference = 1; } }

    if (the_text.desiredGlyphScaling != the_style.desiredGlyphScaling) { if(create_style != 0) { temporary_style.desiredGlyphScaling = the_text.desiredGlyphScaling; } else { the_difference = 1; } }

    if (the_text.desiredLetterSpacing != the_style.desiredLetterSpacing) { if(create_style != 0) { temporary_style.desiredLetterSpacing = the_text.desiredLetterSpacing; } else { the_difference = 1; } }

    if (the_text.desiredWordSpacing != the_style.desiredWordSpacing) { if(create_style != 0) { temporary_style.desiredWordSpacing = the_text.desiredWordSpacing; } else { the_difference = 1; } }

    if (the_text.dropCapCharacters != the_style.dropCapCharacters) { if(create_style != 0) { temporary_style.dropCapCharacters = the_text.dropCapCharacters; } else { the_difference = 1; } }

    if (the_text.dropCapLines != the_style.dropCapLines) { if(create_style != 0) { temporary_style.dropCapLines = the_text.dropCapLines; } else { the_difference = 1; } }

    if (the_text.dropCapStyle != the_style.dropCapStyle) { if(create_style != 0) { temporary_style.dropCapStyle = the_text.dropCapStyle; } else { the_difference = 1; } }

    if (the_text.dropcapDetail != the_style.dropcapDetail) { if(create_style != 0) { temporary_style.dropcapDetail = the_text.dropcapDetail; } else { the_difference = 1; } }

    if (the_text.fillColor != the_style.fillColor) { if(create_style != 0) { temporary_style.fillColor = the_text.fillColor; } else { the_difference = 1; } }

    if (the_text.fillTint != the_style.fillTint) { if(create_style != 0) { temporary_style.fillTint = the_text.fillTint; } else { the_difference = 1; } }

    if (the_text.firstLineIndent != the_style.firstLineIndent) { if(create_style != 0) { temporary_style.firstLineIndent = the_text.firstLineIndent; } else { the_difference = 1; } }

    if (the_text.fontStyle != the_style.fontStyle) { if(create_style != 0) { temporary_style.fontStyle = the_text.fontStyle; } else { the_difference = 1; } }

    if (the_text.horizontalScale != the_style.horizontalScale) { if(create_style != 0) { temporary_style.horizontalScale = the_text.horizontalScale; } else { the_difference = 1; } }

    if (the_text.hyphenWeight != the_style.hyphenWeight) { if(create_style != 0) { temporary_style.hyphenWeight = the_text.hyphenWeight; } else { the_difference = 1; } }

    if (the_text.hyphenateAcrossColumns != the_style.hyphenateAcrossColumns) { if(create_style != 0) { temporary_style.hyphenateAcrossColumns = the_text.hyphenateAcrossColumns; } else { the_difference = 1; } }

    if (the_text.hyphenateAfterFirst != the_style.hyphenateAfterFirst) { if(create_style != 0) { temporary_style.hyphenateAfterFirst = the_text.hyphenateAfterFirst; } else { the_difference = 1; } }

    if (the_text.hyphenateBeforeLast != the_style.hyphenateBeforeLast) { if(create_style != 0) { temporary_style.hyphenateBeforeLast = the_text.hyphenateBeforeLast; } else { the_difference = 1; } }

    if (the_text.hyphenateCapitalizedWords != the_style.hyphenateCapitalizedWords) { if(create_style != 0) { temporary_style.hyphenateCapitalizedWords = the_text.hyphenateCapitalizedWords; } else { the_difference = 1; } }

    if (the_text.hyphenateLadderLimit != the_style.hyphenateLadderLimit) { if(create_style != 0) { temporary_style.hyphenateLadderLimit = the_text.hyphenateLadderLimit; } else { the_difference = 1; } }

    if (the_text.hyphenateLastWord != the_style.hyphenateLastWord) { if(create_style != 0) { temporary_style.hyphenateLastWord = the_text.hyphenateLastWord; } else { the_difference = 1; } }

    if (the_text.hyphenateWordsLongerThan != the_style.hyphenateWordsLongerThan) { if(create_style != 0) { temporary_style.hyphenateWordsLongerThan = the_text.hyphenateWordsLongerThan; } else { the_difference = 1; } }

    if (the_text.hyphenation != the_style.hyphenation) { if(create_style != 0) { temporary_style.hyphenation = the_text.hyphenation; } else { the_difference = 1; } }

    if (the_text.hyphenationZone != the_style.hyphenationZone) { if(create_style != 0) { temporary_style.hyphenationZone = the_text.hyphenationZone; } else { the_difference = 1; } }

    if (the_text.ignoreEdgeAlignment != the_style.ignoreEdgeAlignment) { if(create_style != 0) { temporary_style.ignoreEdgeAlignment = the_text.ignoreEdgeAlignment; } else { the_difference = 1; } }

    if (the_text.justification != the_style.justification) { if(create_style != 0) { temporary_style.justification = the_text.justification; } else { the_difference = 1; } }

    if (the_text.keepAllLinesTogether != the_style.keepAllLinesTogether) { if(create_style != 0) { temporary_style.keepAllLinesTogether = the_text.keepAllLinesTogether; } else { the_difference = 1; } }

    if (the_text.keepFirstLines != the_style.keepFirstLines) { if(create_style != 0) { temporary_style.keepFirstLines = the_text.keepFirstLines; } else { the_difference = 1; } }

    if (the_text.keepLastLines != the_style.keepLastLines) { if(create_style != 0) { temporary_style.keepLastLines = the_text.keepLastLines; } else { the_difference = 1; } }

    if (the_text.keepLinesTogether != the_style.keepLinesTogether) { if(create_style != 0) { temporary_style.keepLinesTogether = the_text.keepLinesTogether; } else { the_difference = 1; } }

    if (the_text.keepRuleAboveInFrame != the_style.keepRuleAboveInFrame) { if(create_style != 0) { temporary_style.keepRuleAboveInFrame = the_text.keepRuleAboveInFrame; } else { the_difference = 1; } }

    if (the_text.keepWithNext != the_style.keepWithNext) { if(create_style != 0) { temporary_style.keepWithNext = the_text.keepWithNext; } else { the_difference = 1; } }

    if (the_text.kerningMethod != the_style.kerningMethod) { if(create_style != 0) { temporary_style.kerningMethod = the_text.kerningMethod; } else { the_difference = 1; } }

    if (the_text.lastLineIndent != the_style.lastLineIndent) { if(create_style != 0) { temporary_style.lastLineIndent = the_text.lastLineIndent; } else { the_difference = 1; } }

    if (the_text.leading != the_style.leading) { if(create_style != 0) { temporary_style.leading = the_text.leading; } else { the_difference = 1; } }

    if (the_text.leftIndent != the_style.leftIndent) { if(create_style != 0) { temporary_style.leftIndent = the_text.leftIndent; } else { the_difference = 1; } }

    if (the_text.ligatures != the_style.ligatures) { if(create_style != 0) { temporary_style.ligatures = the_text.ligatures; } else { the_difference = 1; } }

    if (the_text.maximumGlyphScaling != the_style.maximumGlyphScaling) { if(create_style != 0) { temporary_style.maximumGlyphScaling = the_text.maximumGlyphScaling; } else { the_difference = 1; } }

    if (the_text.maximumLetterSpacing != the_style.maximumLetterSpacing) { if(create_style != 0) { temporary_style.maximumLetterSpacing = the_text.maximumLetterSpacing; } else { the_difference = 1; } }

    if (the_text.maximumWordSpacing != the_style.maximumWordSpacing) { if(create_style != 0) { temporary_style.maximumWordSpacing = the_text.maximumWordSpacing; } else { the_difference = 1; } }

    if (the_text.minimumGlyphScaling != the_style.minimumGlyphScaling) { if(create_style != 0) { temporary_style.minimumGlyphScaling = the_text.minimumGlyphScaling; } else { the_difference = 1; } }

    if (the_text.minimumLetterSpacing != the_style.minimumLetterSpacing) { if(create_style != 0) { temporary_style.minimumLetterSpacing = the_text.minimumLetterSpacing; } else { the_difference = 1; } }

    if (the_text.minimumWordSpacing != the_style.minimumWordSpacing) { if(create_style != 0) { temporary_style.minimumWordSpacing = the_text.minimumWordSpacing; } else { the_difference = 1; } }

    if (the_text.noBreak != the_style.noBreak) { if(create_style != 0) { temporary_style.noBreak = the_text.noBreak; } else { the_difference = 1; } }

    if (the_text.numberingAlignment != the_style.numberingAlignment) { if(create_style != 0) { temporary_style.numberingAlignment = the_text.numberingAlignment; } else { the_difference = 1; } }

    if (the_text.numberingApplyRestartPolicy != the_style.numberingApplyRestartPolicy) { if(create_style != 0) { temporary_style.numberingApplyRestartPolicy = the_text.numberingApplyRestartPolicy; } else { the_difference = 1; } }

    if (the_text.numberingCharacterStyle != the_style.numberingCharacterStyle) { if(create_style != 0) { temporary_style.numberingCharacterStyle = the_text.numberingCharacterStyle; } else { the_difference = 1; } }

    if (the_text.numberingContinue != the_style.numberingContinue) { if(create_style != 0) { temporary_style.numberingContinue = the_text.numberingContinue; } else { the_difference = 1; } }

    if (the_text.numberingExpression != the_style.numberingExpression) { if(create_style != 0) { temporary_style.numberingExpression = the_text.numberingExpression; } else { the_difference = 1; } }

    if (the_text.numberingFormat != the_style.numberingFormat) { if(create_style != 0) { temporary_style.numberingFormat = the_text.numberingFormat; } else { the_difference = 1; } }

    if (the_text.numberingLevel != the_style.numberingLevel) { if(create_style != 0) { temporary_style.numberingLevel = the_text.numberingLevel; } else { the_difference = 1; } }

    if (the_text.numberingStartAt != the_style.numberingStartAt) { if(create_style != 0) { temporary_style.numberingStartAt = the_text.numberingStartAt; } else { the_difference = 1; } }

    if (the_text.otfContextualAlternate != the_style.otfContextualAlternate) { if(create_style != 0) { temporary_style.otfContextualAlternate = the_text.otfContextualAlternate; } else { the_difference = 1; } }

    if (the_text.otfDiscretionaryLigature != the_style.otfDiscretionaryLigature) { if(create_style != 0) { temporary_style.otfDiscretionaryLigature = the_text.otfDiscretionaryLigature; } else { the_difference = 1; } }

    if (the_text.otfFigureStyle != the_style.otfFigureStyle) { if(create_style != 0) { temporary_style.otfFigureStyle = the_text.otfFigureStyle; } else { the_difference = 1; } }

    if (the_text.otfFraction != the_style.otfFraction) { if(create_style != 0) { temporary_style.otfFraction = the_text.otfFraction; } else { the_difference = 1; } }

    if (the_text.otfHistorical != the_style.otfHistorical) { if(create_style != 0) { temporary_style.otfHistorical = the_text.otfHistorical; } else { the_difference = 1; } }

    if (the_text.otfLocale != the_style.otfLocale) { if(create_style != 0) { temporary_style.otfLocale = the_text.otfLocale; } else { the_difference = 1; } }

    if (the_text.otfMark != the_style.otfMark) { if(create_style != 0) { temporary_style.otfMark = the_text.otfMark; } else { the_difference = 1; } }

    if (the_text.otfOrdinal != the_style.otfOrdinal) { if(create_style != 0) { temporary_style.otfOrdinal = the_text.otfOrdinal; } else { the_difference = 1; } }

    if (the_text.otfSlashedZero != the_style.otfSlashedZero) { if(create_style != 0) { temporary_style.otfSlashedZero = the_text.otfSlashedZero; } else { the_difference = 1; } }

    if (the_text.otfStylisticSets != the_style.otfStylisticSets) { if(create_style != 0) { temporary_style.otfStylisticSets = the_text.otfStylisticSets; } else { the_difference = 1; } }

    if (the_text.otfSwash != the_style.otfSwash) { if(create_style != 0) { temporary_style.otfSwash = the_text.otfSwash; } else { the_difference = 1; } }

    if (the_text.otfTitling != the_style.otfTitling) { if(create_style != 0) { temporary_style.otfTitling = the_text.otfTitling; } else { the_difference = 1; } }

    if (the_text.overprintFill != the_style.overprintFill) { if(create_style != 0) { temporary_style.overprintFill = the_text.overprintFill; } else { the_difference = 1; } }

    if (the_text.overprintStroke != the_style.overprintStroke) { if(create_style != 0) { temporary_style.overprintStroke = the_text.overprintStroke; } else { the_difference = 1; } }

    if (the_text.pointSize != the_style.pointSize) { if(create_style != 0) { temporary_style.pointSize = the_text.pointSize; } else { the_difference = 1; } }

    if (the_text.position != the_style.position) { if(create_style != 0) { temporary_style.position = the_text.position; } else { the_difference = 1; } }

    if (the_text.positionalForm != the_style.positionalForm) { if(create_style != 0) { temporary_style.positionalForm = the_text.positionalForm; } else { the_difference = 1; } }

    if (the_text.rightIndent != the_style.rightIndent) { if(create_style != 0) { temporary_style.rightIndent = the_text.rightIndent; } else { the_difference = 1; } }

    if (the_text.ruleAbove != the_style.ruleAbove) { if(create_style != 0) { temporary_style.ruleAbove = the_text.ruleAbove; } else { the_difference = 1; } }

    if (the_text.ruleAboveColor != the_style.ruleAboveColor) { if(create_style != 0) { temporary_style.ruleAboveColor = the_text.ruleAboveColor; } else { the_difference = 1; } }

    if (the_text.ruleAboveGapColor != the_style.ruleAboveGapColor) { if(create_style != 0) { temporary_style.ruleAboveGapColor = the_text.ruleAboveGapColor; } else { the_difference = 1; } }

    if (the_text.ruleAboveGapOverprint != the_style.ruleAboveGapOverprint) { if(create_style != 0) { temporary_style.ruleAboveGapOverprint = the_text.ruleAboveGapOverprint; } else { the_difference = 1; } }

    if (the_text.ruleAboveGapTint != the_style.ruleAboveGapTint) { if(create_style != 0) { temporary_style.ruleAboveGapTint = the_text.ruleAboveGapTint; } else { the_difference = 1; } }

    if (the_text.ruleAboveLeftIndent != the_style.ruleAboveLeftIndent) { if(create_style != 0) { temporary_style.ruleAboveLeftIndent = the_text.ruleAboveLeftIndent; } else { the_difference = 1; } }

    if (the_text.ruleAboveLineWeight != the_style.ruleAboveLineWeight) { if(create_style != 0) { temporary_style.ruleAboveLineWeight = the_text.ruleAboveLineWeight; } else { the_difference = 1; } }

    if (the_text.ruleAboveOffset != the_style.ruleAboveOffset) { if(create_style != 0) { temporary_style.ruleAboveOffset = the_text.ruleAboveOffset; } else { the_difference = 1; } }

    if (the_text.ruleAboveOverprint != the_style.ruleAboveOverprint) { if(create_style != 0) { temporary_style.ruleAboveOverprint = the_text.ruleAboveOverprint; } else { the_difference = 1; } }

    if (the_text.ruleAboveRightIndent != the_style.ruleAboveRightIndent) { if(create_style != 0) { temporary_style.ruleAboveRightIndent = the_text.ruleAboveRightIndent; } else { the_difference = 1; } }

    if (the_text.ruleAboveTint != the_style.ruleAboveTint) { if(create_style != 0) { temporary_style.ruleAboveTint = the_text.ruleAboveTint; } else { the_difference = 1; } }

    if (the_text.ruleAboveType != the_style.ruleAboveType) { if(create_style != 0) { temporary_style.ruleAboveType = the_text.ruleAboveType; } else { the_difference = 1; } }

    if (the_text.ruleAboveWidth != the_style.ruleAboveWidth) { if(create_style != 0) { temporary_style.ruleAboveWidth = the_text.ruleAboveWidth; } else { the_difference = 1; } }

    if (the_text.ruleBelow != the_style.ruleBelow) { if(create_style != 0) { temporary_style.ruleBelow = the_text.ruleBelow; } else { the_difference = 1; } }

    if (the_text.ruleBelowColor != the_style.ruleBelowColor) { if(create_style != 0) { temporary_style.ruleBelowColor = the_text.ruleBelowColor; } else { the_difference = 1; } }

    if (the_text.ruleBelowGapColor != the_style.ruleBelowGapColor) { if(create_style != 0) { temporary_style.ruleBelowGapColor = the_text.ruleBelowGapColor; } else { the_difference = 1; } }

    if (the_text.ruleBelowGapOverprint != the_style.ruleBelowGapOverprint) { if(create_style != 0) { temporary_style.ruleBelowGapOverprint = the_text.ruleBelowGapOverprint; } else { the_difference = 1; } }

    if (the_text.ruleBelowGapTint != the_style.ruleBelowGapTint) { if(create_style != 0) { temporary_style.ruleBelowGapTint = the_text.ruleBelowGapTint; } else { the_difference = 1; } }

    if (the_text.ruleBelowLeftIndent != the_style.ruleBelowLeftIndent) { if(create_style != 0) { temporary_style.ruleBelowLeftIndent = the_text.ruleBelowLeftIndent; } else { the_difference = 1; } }

    if (the_text.ruleBelowLineWeight != the_style.ruleBelowLineWeight) { if(create_style != 0) { temporary_style.ruleBelowLineWeight = the_text.ruleBelowLineWeight; } else { the_difference = 1; } }

    if (the_text.ruleBelowOffset != the_style.ruleBelowOffset) { if(create_style != 0) { temporary_style.ruleBelowOffset = the_text.ruleBelowOffset; } else { the_difference = 1; } }

    if (the_text.ruleBelowOverprint != the_style.ruleBelowOverprint) { if(create_style != 0) { temporary_style.ruleBelowOverprint = the_text.ruleBelowOverprint; } else { the_difference = 1; } }

    if (the_text.ruleBelowRightIndent != the_style.ruleBelowRightIndent) { if(create_style != 0) { temporary_style.ruleBelowRightIndent = the_text.ruleBelowRightIndent; } else { the_difference = 1; } }

    if (the_text.ruleBelowTint != the_style.ruleBelowTint) { if(create_style != 0) { temporary_style.ruleBelowTint = the_text.ruleBelowTint; } else { the_difference = 1; } }

    if (the_text.ruleBelowType != the_style.ruleBelowType) { if(create_style != 0) { temporary_style.ruleBelowType = the_text.ruleBelowType; } else { the_difference = 1; } }

    if (the_text.ruleBelowWidth != the_style.ruleBelowWidth) { if(create_style != 0) { temporary_style.ruleBelowWidth = the_text.ruleBelowWidth; } else { the_difference = 1; } }

    if (the_text.singleWordJustification != the_style.singleWordJustification) { if(create_style != 0) { temporary_style.singleWordJustification = the_text.singleWordJustification; } else { the_difference = 1; } }

    if (the_text.skew != the_style.skew) { if(create_style != 0) { temporary_style.skew = the_text.skew; } else { the_difference = 1; } }

    if (the_text.spaceAfter != the_style.spaceAfter) { if(create_style != 0) { temporary_style.spaceAfter = the_text.spaceAfter; } else { the_difference = 1; } }

    if (the_text.spaceBefore != the_style.spaceBefore) { if(create_style != 0) { temporary_style.spaceBefore = the_text.spaceBefore; } else { the_difference = 1; } }

    if (the_text.startParagraph != the_style.startParagraph) { if(create_style != 0) { temporary_style.startParagraph = the_text.startParagraph; } else { the_difference = 1; } }

    if (the_text.strikeThroughColor != the_style.strikeThroughColor) { if(create_style != 0) { temporary_style.strikeThroughColor = the_text.strikeThroughColor; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapColor != the_style.strikeThroughGapColor) { if(create_style != 0) { temporary_style.strikeThroughGapColor = the_text.strikeThroughGapColor; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapOverprint != the_style.strikeThroughGapOverprint) { if(create_style != 0) { temporary_style.strikeThroughGapOverprint = the_text.strikeThroughGapOverprint; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapTint != the_style.strikeThroughGapTint) { if(create_style != 0) { temporary_style.strikeThroughGapTint = the_text.strikeThroughGapTint; } else { the_difference = 1; } }

    if (the_text.strikeThroughOffset != the_style.strikeThroughOffset) { if(create_style != 0) { temporary_style.strikeThroughOffset = the_text.strikeThroughOffset; } else { the_difference = 1; } }

    if (the_text.strikeThroughOverprint != the_style.strikeThroughOverprint) { if(create_style != 0) { temporary_style.strikeThroughOverprint = the_text.strikeThroughOverprint; } else { the_difference = 1; } }

    if (the_text.strikeThroughTint != the_style.strikeThroughTint) { if(create_style != 0) { temporary_style.strikeThroughTint = the_text.strikeThroughTint; } else { the_difference = 1; } }

    if (the_text.strikeThroughType != the_style.strikeThroughType) { if(create_style != 0) { temporary_style.strikeThroughType = the_text.strikeThroughType; } else { the_difference = 1; } }

    if (the_text.strikeThroughWeight != the_style.strikeThroughWeight) { if(create_style != 0) { temporary_style.strikeThroughWeight = the_text.strikeThroughWeight; } else { the_difference = 1; } }

    if (the_text.strikeThru != the_style.strikeThru) { if(create_style != 0) { temporary_style.strikeThru = the_text.strikeThru; } else { the_difference = 1; } }

    if (the_text.strokeColor != the_style.strokeColor) { if(create_style != 0) { temporary_style.strokeColor = the_text.strokeColor; } else { the_difference = 1; } }

    if (the_text.strokeTint != the_style.strokeTint) { if(create_style != 0) { temporary_style.strokeTint = the_text.strokeTint; } else { the_difference = 1; } }

    if (the_text.strokeWeight != the_style.strokeWeight) { if(create_style != 0) { temporary_style.strokeWeight = the_text.strokeWeight; } else { the_difference = 1; } }

    if (the_text.tracking != the_style.tracking) { if(create_style != 0) { temporary_style.tracking = the_text.tracking; } else { the_difference = 1; } }

    if (the_text.underline != the_style.underline) { if(create_style != 0) { temporary_style.underline = the_text.underline; } else { the_difference = 1; } }

    if (the_text.underlineColor != the_style.underlineColor) { if(create_style != 0) { temporary_style.underlineColor = the_text.underlineColor; } else { the_difference = 1; } }

    if (the_text.underlineGapColor != the_style.underlineGapColor) { if(create_style != 0) { temporary_style.underlineGapColor = the_text.underlineGapColor; } else { the_difference = 1; } }

    if (the_text.underlineGapOverprint != the_style.underlineGapOverprint) { if(create_style != 0) { temporary_style.underlineGapOverprint = the_text.underlineGapOverprint; } else { the_difference = 1; } }

    if (the_text.underlineGapTint != the_style.underlineGapTint) { if(create_style != 0) { temporary_style.underlineGapTint = the_text.underlineGapTint; } else { the_difference = 1; } }

    if (the_text.underlineOffset != the_style.underlineOffset) { if(create_style != 0) { temporary_style.underlineOffset = the_text.underlineOffset; } else { the_difference = 1; } }

    if (the_text.underlineOverprint != the_style.underlineOverprint) { if(create_style != 0) { temporary_style.underlineOverprint = the_text.underlineOverprint; } else { the_difference = 1; } }

    if (the_text.underlineTint != the_style.underlineTint) { if(create_style != 0) { temporary_style.underlineTint = the_text.underlineTint; } else { the_difference = 1; } }

    if (the_text.underlineType != the_style.underlineType) { if(create_style != 0) { temporary_style.underlineType = the_text.underlineType; } else { the_difference = 1; } }

    if (the_text.underlineWeight != the_style.underlineWeight) { if(create_style != 0) { temporary_style.underlineWeight = the_text.underlineWeight; } else { the_difference = 1; } }

    if (the_text.verticalScale != the_style.verticalScale) { if(create_style != 0) { temporary_style.verticalScale = the_text.verticalScale; } else { the_difference = 1; } }

    if(create_style != 0) {

        return temporary_style;

    } else {

        return the_difference;

    }

}

function cstylePropertyDifferences(the_text,the_style,create_style){

    if(create_style == 1) {

        var temporary_style = the_document.characterStyles.add({name:"TempStyle"});

    } else {

        var the_difference = 0;

    }

   

    if (the_text.appliedFont != the_style.appliedFont) { if(create_style != 0) { temporary_style.appliedFont = the_text.appliedFont; } else { the_difference = 1; } }

    if (the_text.appliedLanguage != the_style.appliedLanguage) { if(create_style != 0) { temporary_style.appliedLanguage = the_text.appliedLanguage; } else { the_difference = 1; } }

    if (the_text.baselineShift != the_style.baselineShift) { if(create_style != 0) { temporary_style.baselineShift = the_text.baselineShift; } else { the_difference = 1; } }

    if (the_text.capitalization != the_style.capitalization) { if(create_style != 0) { temporary_style.capitalization = the_text.capitalization; } else { the_difference = 1; } }

    if (the_text.fillColor != the_style.fillColor) { if(create_style != 0) { temporary_style.fillColor = the_text.fillColor; } else { the_difference = 1; } }

    if (the_text.fillTint != the_style.fillTint) { if(create_style != 0) { temporary_style.fillTint = the_text.fillTint; } else { the_difference = 1; } }

    if (the_text.fontStyle != the_style.fontStyle) { if(create_style != 0) { temporary_style.fontStyle = the_text.fontStyle; } else { the_difference = 1; } }

    if (the_text.horizontalScale != the_style.horizontalScale) { if(create_style != 0) { temporary_style.horizontalScale = the_text.horizontalScale; } else { the_difference = 1; } }

    if (the_text.kerningMethod != the_style.kerningMethod) { if(create_style != 0) { temporary_style.kerningMethod = the_text.kerningMethod; } else { the_difference = 1; } }

    if (the_text.leading != the_style.leading) { if(create_style != 0) { temporary_style.leading = the_text.leading; } else { the_difference = 1; } }

    if (the_text.ligatures != the_style.ligatures) { if(create_style != 0) { temporary_style.ligatures = the_text.ligatures; } else { the_difference = 1; } }

    if (the_text.noBreak != the_style.noBreak) { if(create_style != 0) { temporary_style.noBreak = the_text.noBreak; } else { the_difference = 1; } }

    if (the_text.otfContextualAlternate != the_style.otfContextualAlternate) { if(create_style != 0) { temporary_style.otfContextualAlternate = the_text.otfContextualAlternate; } else { the_difference = 1; } }

    if (the_text.otfDiscretionaryLigature != the_style.otfDiscretionaryLigature) { if(create_style != 0) { temporary_style.otfDiscretionaryLigature = the_text.otfDiscretionaryLigature; } else { the_difference = 1; } }

    if (the_text.otfFigureStyle != the_style.otfFigureStyle) { if(create_style != 0) { temporary_style.otfFigureStyle = the_text.otfFigureStyle; } else { the_difference = 1; } }

    if (the_text.otfFraction != the_style.otfFraction) { if(create_style != 0) { temporary_style.otfFraction = the_text.otfFraction; } else { the_difference = 1; } }

    if (the_text.otfHistorical != the_style.otfHistorical) { if(create_style != 0) { temporary_style.otfHistorical = the_text.otfHistorical; } else { the_difference = 1; } }

    if (the_text.otfLocale != the_style.otfLocale) { if(create_style != 0) { temporary_style.otfLocale = the_text.otfLocale; } else { the_difference = 1; } }

    if (the_text.otfMark != the_style.otfMark) { if(create_style != 0) { temporary_style.otfMark = the_text.otfMark; } else { the_difference = 1; } }

    if (the_text.otfOrdinal != the_style.otfOrdinal) { if(create_style != 0) { temporary_style.otfOrdinal = the_text.otfOrdinal; } else { the_difference = 1; } }

    if (the_text.otfSlashedZero != the_style.otfSlashedZero) { if(create_style != 0) { temporary_style.otfSlashedZero = the_text.otfSlashedZero; } else { the_difference = 1; } }

    if (the_text.otfStylisticSets != the_style.otfStylisticSets) { if(create_style != 0) { temporary_style.otfStylisticSets = the_text.otfStylisticSets; } else { the_difference = 1; } }

    if (the_text.otfSwash != the_style.otfSwash) { if(create_style != 0) { temporary_style.otfSwash = the_text.otfSwash; } else { the_difference = 1; } }

    if (the_text.otfTitling != the_style.otfTitling) { if(create_style != 0) { temporary_style.otfTitling = the_text.otfTitling; } else { the_difference = 1; } }

    if (the_text.overprintFill != the_style.overprintFill) { if(create_style != 0) { temporary_style.overprintFill = the_text.overprintFill; } else { the_difference = 1; } }

    if (the_text.overprintStroke != the_style.overprintStroke) { if(create_style != 0) { temporary_style.overprintStroke = the_text.overprintStroke; } else { the_difference = 1; } }

    if (the_text.pointSize != the_style.pointSize) { if(create_style != 0) { temporary_style.pointSize = the_text.pointSize; } else { the_difference = 1; } }

    if (the_text.position != the_style.position) { if(create_style != 0) { temporary_style.position = the_text.position; } else { the_difference = 1; } }

    if (the_text.positionalForm != the_style.positionalForm) { if(create_style != 0) { temporary_style.positionalForm = the_text.positionalForm; } else { the_difference = 1; } }

    if (the_text.skew != the_style.skew) { if(create_style != 0) { temporary_style.skew = the_text.skew; } else { the_difference = 1; } }

    if (the_text.strikeThroughColor != the_style.strikeThroughColor) { if(create_style != 0) { temporary_style.strikeThroughColor = the_text.strikeThroughColor; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapColor != the_style.strikeThroughGapColor) { if(create_style != 0) { temporary_style.strikeThroughGapColor = the_text.strikeThroughGapColor; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapOverprint != the_style.strikeThroughGapOverprint) { if(create_style != 0) { temporary_style.strikeThroughGapOverprint = the_text.strikeThroughGapOverprint; } else { the_difference = 1; } }

    if (the_text.strikeThroughGapTint != the_style.strikeThroughGapTint) { if(create_style != 0) { temporary_style.strikeThroughGapTint = the_text.strikeThroughGapTint; } else { the_difference = 1; } }

    if (the_text.strikeThroughOffset != the_style.strikeThroughOffset) { if(create_style != 0) { temporary_style.strikeThroughOffset = the_text.strikeThroughOffset; } else { the_difference = 1; } }

    if (the_text.strikeThroughOverprint != the_style.strikeThroughOverprint) { if(create_style != 0) { temporary_style.strikeThroughOverprint = the_text.strikeThroughOverprint; } else { the_difference = 1; } }

    if (the_text.strikeThroughTint != the_style.strikeThroughTint) { if(create_style != 0) { temporary_style.strikeThroughTint = the_text.strikeThroughTint; } else { the_difference = 1; } }

    if (the_text.strikeThroughType != the_style.strikeThroughType) { if(create_style != 0) { temporary_style.strikeThroughType = the_text.strikeThroughType; } else { the_difference = 1; } }

    if (the_text.strikeThroughWeight != the_style.strikeThroughWeight) { if(create_style != 0) { temporary_style.strikeThroughWeight = the_text.strikeThroughWeight; } else { the_difference = 1; } }

    if (the_text.strikeThru != the_style.strikeThru) { if(create_style != 0) { temporary_style.strikeThru = the_text.strikeThru; } else { the_difference = 1; } }

    if (the_text.strokeColor != the_style.strokeColor) { if(create_style != 0) { temporary_style.strokeColor = the_text.strokeColor; } else { the_difference = 1; } }

    if (the_text.strokeTint != the_style.strokeTint) { if(create_style != 0) { temporary_style.strokeTint = the_text.strokeTint; } else { the_difference = 1; } }

    if (the_text.strokeWeight != the_style.strokeWeight) { if(create_style != 0) { temporary_style.strokeWeight = the_text.strokeWeight; } else { the_difference = 1; } }

    if (the_text.tracking != the_style.tracking) { if(create_style != 0) { temporary_style.tracking = the_text.tracking; } else { the_difference = 1; } }

    if (the_text.underline != the_style.underline) { if(create_style != 0) { temporary_style.underline = the_text.underline; } else { the_difference = 1; } }

    if (the_text.underlineColor != the_style.underlineColor) { if(create_style != 0) { temporary_style.underlineColor = the_text.underlineColor; } else { the_difference = 1; } }

    if (the_text.underlineGapColor != the_style.underlineGapColor) { if(create_style != 0) { temporary_style.underlineGapColor = the_text.underlineGapColor; } else { the_difference = 1; } }

    if (the_text.underlineGapOverprint != the_style.underlineGapOverprint) { if(create_style != 0) { temporary_style.underlineGapOverprint = the_text.underlineGapOverprint; } else { the_difference = 1; } }

    if (the_text.underlineGapTint != the_style.underlineGapTint) { if(create_style != 0) { temporary_style.underlineGapTint = the_text.underlineGapTint; } else { the_difference = 1; } }

    if (the_text.underlineOffset != the_style.underlineOffset) { if(create_style != 0) { temporary_style.underlineOffset = the_text.underlineOffset; } else { the_difference = 1; } }

    if (the_text.underlineOverprint != the_style.underlineOverprint) { if(create_style != 0) { temporary_style.underlineOverprint = the_text.underlineOverprint; } else { the_difference = 1; } }

    if (the_text.underlineTint != the_style.underlineTint) { if(create_style != 0) { temporary_style.underlineTint = the_text.underlineTint; } else { the_difference = 1; } }

    if (the_text.underlineType != the_style.underlineType) { if(create_style != 0) { temporary_style.underlineType = the_text.underlineType; } else { the_difference = 1; } }

    if (the_text.underlineWeight != the_style.underlineWeight) { if(create_style != 0) { temporary_style.underlineWeight = the_text.underlineWeight; } else { the_difference = 1; } }

    if (the_text.verticalScale != the_style.verticalScale) { if(create_style != 0) { temporary_style.verticalScale = the_text.verticalScale; } else { the_difference = 1; } }

    if(create_style != 0) {

        return temporary_style;

    } else {

        return the_difference;

    }

}

alert("Done!");

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
Mentor ,
Jun 28, 2012 Jun 28, 2012

Yes Trevor, You got me now. Thanks for a monk_Thomas_ready_to_be_copied_job.

I was just wondering, that there some way to use - i.e. -  app.selection[0].paragraphs[0].properties.toSource() and eval this to define a new para style, but I am completely not familiar with that. So... lets go to the monk room

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
Advocate ,
Jun 28, 2012 Jun 28, 2012

Hi Jump,

Why you not using the "Menu Actions" way i feel it is easy to achieve the menu actions way.

thx

csm_phil

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
Guru ,
Jun 28, 2012 Jun 28, 2012

Hi Phil

I couldn't get the menuactions to work.

myMenuAction = app.menuActions.item("$ID/New Paragraph Style...");

myMenuAction.invoke();

gives an error message

the following script could be a good lead and someone a bit more knolagable than be should be able to do something with it.

it give a list of the propeties and their values

ScreenShot039.png

myDoc= myDoc = app.activeDocument;

ns=app.selection[0].paragraphs[0].properties.toSource()

myPropName=[]

myPropValue=[]

st=""

myPropNameMatch = /[^,]+(?=:)/g;

myPropValueMatch = /((([^:]+(?=,))|((?<=:)[^:]+$)))/g;

//;

myPropName=ns.match(myPropNameMatch);

myPropValue=ns.match(myPropValueMatch);

myPropName[0]=myPropName[0].slice(2);

(myDoc.paragraphStyles.item("Oh").isValid) ? newst = myDoc.paragraphStyles.item("Oh") : myDoc.paragraphStyles.add({name:"Oh"});

for (c=0; c<myPropName.length; c++)

{

    st+=c+"\t"+myPropName+" = "+myPropValue+";\r"

    z=myPropName

    y= myPropValue

    newst.properties = {z:y}

    }

   

alert(st)

//with (newst) st;

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
Guru ,
Jul 02, 2012 Jul 02, 2012

Hi Jump_Over,

Two selfmade non copied scripts

They work for paragraph styles object styles need a bit of thought ..........

The first one which is the one to use I thought of second one first, oh well

The first script is obviously much better than the second script.

I am including the second script here because it has some nice methods.

I converts the string you get from the toSource() into a string that you can use as a properties = {......} by use of regex

It works but go for the first one!!!!!!!!!!!

The piccy show the reults

ScreenShot040.png

Regards

Trevor

Script 1: The Good

myDoc = app.activeDocument;
mySelection=app.selection[0]
myNewStyleName =  "Created or Redefined Style";
try {
    myProperties=mySelection.paragraphs[0].properties;
    newStyle = (myDoc.paragraphStyles.item(myNewStyleName).isValid) ?  myDoc.paragraphStyles.item(myNewStyleName) : myDoc.paragraphStyles.add({name:myNewStyleName});
    newStyle.properties=myProperties;
    // As the bulletChar is read only & has to be split into it's elelments easiest if done manually
    newStyle.bulletChar.bulletsFont = mySelection.bulletChar.bulletsFont;
    newStyle.bulletChar.bulletsFontStyle = mySelection.bulletChar.bulletsFontStyle;
    newStyle.bulletChar.characterType = mySelection.bulletChar.characterType;
    newStyle.bulletChar.characterValue = mySelection.bulletChar.characterValue;
    newStyle.bulletChar.characterType = mySelection.bulletChar.characterType;
    // sort out tablist problem
    newStyle.tabList = mySelection.tabList;
    // there might be other values that need to be returned in this way

    }
catch (selectionDosentHaveParaStyle) {alert("Select some text")}

Script 2: The Bad

#target indesign

// THE MUCH MUCH MUCH BETTER WAY OFF DOING THIS IS THE ABOVE

// SCRIPT .  USE THAT ONE

// Script by Trevor to Create Redefine Paragraph Style base on selected paragraph properties

// function uses regex expresions to convert paragraphs.properties.toSource() to a string of properties

// The string is then run as a doScript

app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Create Redefine Paragraph Style");

function main()

{

myDoc = app.activeDocument;

n=app.selection[0].paragraphs[0]

ns=n.properties.toSource()

newStyleName = "Created Redefined Paragraph Style";

newParaStyle = (myDoc.paragraphStyles.item(newStyleName).isValid) ?  myDoc.paragraphStyles.item(newStyleName) : myDoc.paragraphStyles.add({name:newStyleName});

// Check if selected paragraph has style applied to it with no overrides

// if so then just duplicate the style and remove newStyleName replacing with the duplicated style

// it is worth considering whether or not to make a new style even if there is an overide

if (n.appliedParagraphStyle.isValid && n.styleOverridden==0)

{

saps=n.appliedParagraphStyle

tempPS=saps.duplicate ();

app.activeDocument.paragraphStyles.item(newStyleName).remove (tempPS);

tempPS.name=newStyleName;

return false;

}

// remove contents property so as not to mess up future grep searches

con=n.contents

// change the paragraph contents result to the toSource result format so it can be removed from there

find=/\\/g

change='\\\\'

var con=con.replace (find, change)

find=/\"/g

change='\\\"'

con=con.replace (find, change)

con=', contents:\"'+con+'\"'

change =''

ns=ns.replace (con, change)

// remove Tab list from toSource (has subproperties) will apply them at the end

find ="tabList:"+n.tabList.toSource()+",";

ns=ns.replace (find, change)

// change enums ({}) that are not given in toSource into a true numeric value

myPropValueMatch = /[^,]+?:\(\{\}\)/g; //   finds  properties that have enums that need to be coverted

myPropNameMatch = /[^,]+?(?=:\(\{\}\))/g; // property name of above finds

myPropName=myPropValue=[];

myPropName=ns.match(myPropNameMatch);

myPropValue=ns.match(myPropValueMatch);

newStyle = (myDoc.paragraphStyles.item(newStyleName).isValid) ?  myDoc.paragraphStyles.item(newStyleName) : myDoc.paragraphStyles.add({name:newStyleName});

for (c=0; c<myPropName.length; c++)

{

    schange = "n."+myPropName;

    // use doScript to check for the property value can't do n.myPropName without that

    nchange=app.doScript(schange);

    change=myPropName+":"+nchange*1;

    ns=ns.replace (myPropValue, change)

}

// change the toSource () into a command string newParaStyle.properties = ({blah:0, blah:"fred", ...})

ns="newParaStyle.properties = "+ns;

// Run The command

app.doScript(ns); 

// Now for the monks work!!

// As the bulletChar is read only & has to be split into it's elelments easiest if done manually

newParaStyle.bulletChar.bulletsFont = n.bulletChar.bulletsFont;

newParaStyle.bulletChar.bulletsFontStyle = n.bulletChar.bulletsFontStyle;

newParaStyle.bulletChar.characterType = n.bulletChar.characterType;

newParaStyle.bulletChar.characterValue = n.bulletChar.characterValue;

newParaStyle.bulletChar.characterType = n.bulletChar.characterType;

// sort out tablist problem

newParaStyle.tabList=n.tabList;

// there might be other values that need to be returned in this way

}

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
Guru ,
Jul 03, 2012 Jul 03, 2012
LATEST

corrected the "Good Script"

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