[GastForen Programme Print/Bildbearbeitung Adobe InDesign Skriptwerkstatt Absatzformat aktivieren

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Print/Bildbearbeitung - Photos, Layout, Design
Themen
Beiträge
Moderatoren
Letzter Beitrag

Absatzformat aktivieren

SiggiB
Beiträge gesamt: 1

6. Sep 2018, 13:41
Beitrag # 1 von 2
Bewertung:
(1773 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Gibt es eine Möglichkeit ein Absatzformat in der Palette anzuwählen per Script?

Ich habe mir aus verschiedenen Quellen ein JavaScript zusammmengestellt um beliebige InDesign-Dokumente mit Bildunterschriften mit einem festgelegten Standard vollautomatisch zu versehen.
Es wird eine neue Ebene angelegt, diese wird ausgewählt und es wird ein Absatzformat angelegt.
Aber beim erstellen der Bildnamen wählt InDesign immer das "Default"-Absatzformat.
Wie gebe ich an das bei "add a text frame...“ das Absatzformat Bildnamen benutzt wird?

Ich bin Anfänger in diesen Dingen.

Das Script folgt hier:

var curDoc = app.activeDocument;
var tgt = app.activeDocument.allGraphics;

// prüft, ob die Ebene 'Beschriftung' da ist, falls nicht, wird sie angelegt
if (!curDoc.layers.itemByName("Beschriftungen").isValid) {
var lay = curDoc.layers.add({name: "Beschriftungen", layerColor: UIColors.MAGENTA});
// die Ebene nach oben verschieben
lay.move(LocationOptions.BEFORE, curDoc.layers[0]);
}

// prüft, ob das Absatzformat 'Bildnamen' da ist, falls nicht, wird es angelegt
if (!curDoc.paragraphStyles.itemByName("Bildnamen").isValid) {
NewParaStyle = curDoc.paragraphStyles.add();
with ( NewParaStyle ) { name= "Bildnamen";
appliedFont = app.fonts.item("Rotis Sans Serif Pro Cyrillic");
fontStyle = "ExtraBold";
pointSize = 7.0;
leading = "6.5";
fillColor = "C=15 M=100 Y=100 K=0";
tracking = 0;
horizontalScale = 60;
};
}

// TextFrame add ([layer: Layer][, at: LocationOptions=LocationOptions.UNKNOWN][, reference: varies][, withProperties: Object])
var myDocument = app.documents.item (0);
// var mypage = myDocument.pages.item (0);
var myTextFrame = myDocument.textFrames.add();
myTextFrame.contents = "Dies ist ein Beispieltext.";
// TextBox add (layer: Beschriftungen, at: LocationOptions=LocationOptions.UNKNOWN, withProperties: applyParagraphStyle(Bildnamen))
// void applyParagraphStyle (Bildnamen)
// applyParagraphStyle(Bildnamen)

for(var i=0;i<tgt.length;i++){

//Narrow the scope to all graphics on pages only:
if(tgt.parentPage != null){

//What to do with graphics, that are pasted directly from none-InDesign files:
//the caption will read "Undefined"
try{
var myName = tgt.itemLink.name;
}catch(e){var myName = "Undefined"};

//targets the page of the graphic:
var myPage = tgt.parentPage;

//adds a text frame to the page of the graphic:
var myCaption = myPage.textFrames.add();

myCaption.textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN;
// myCaption.textPreferences.appliedParagraphStyle = "Bildnamen";
myCaption.contents = myName;
myCaption.paragraphs[0].justification = Justification.CENTER_ALIGN;

//Why visible bounds and not geometric bounds?
var bnds = tgt.parent.visibleBounds;
myCaption.visibleBounds = [bnds[2]+12, bnds[1], bnds[2]+0.1, bnds[3]];
myCaption.fit(FitOptions.FRAME_TO_CONTENT);
};
};
X

Absatzformat aktivieren

Uwe Laubender
Beiträge gesamt: 5316

8. Sep 2018, 18:54
Beitrag # 2 von 2
Beitrag ID: #566133
Bewertung:
(1734 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Antwort auf: Gibt es eine Möglichkeit ein Absatzformat in der Palette anzuwählen per Script?…


Hallo SiggiB,
im Prinzip ja.

Erzeuge einen neuen Textrahmen mit Text, weise ein Absatzformat zu und wähle den Text aus.
Dann sollte das zugehörige Absatzformat in der Palette ausgewählt sein.

Für Deinen Zweck ist diese Vorgehensweise aber unnütz.
Probiere das hier:

Code
myTextFrame.parentStory.texts[0].appliedParagraphStyle =  
curDoc.paragraphStyles.itemByName("Bildnamen");



als Antwort auf: [#566073]