Macos InDesign Applescript使用属性生成文本框

Macos InDesign Applescript使用属性生成文本框,macos,applescript,adobe-indesign,Macos,Applescript,Adobe Indesign,我正在写一个小的Applescript,它在InDesign文档中添加了一个包含一些内容的文本框架。我试图在文本框中指定内容的属性,但没有应用任何规格,我将获得默认值。事件没有抛出任何错误,所以我有点迷路 任何帮助都将不胜感激 这就是我所拥有的: tell application "Adobe InDesign CC 2014" activate tell active document set xFrame1 to make text frame with properties {ju

我正在写一个小的Applescript,它在InDesign文档中添加了一个包含一些内容的文本框架。我试图在文本框中指定内容的属性,但没有应用任何规格,我将获得默认值。事件没有抛出任何错误,所以我有点迷路

任何帮助都将不胜感激

这就是我所拥有的:

tell application "Adobe InDesign CC 2014"
activate
tell active document
    set xFrame1 to make text frame with properties {justification:center align, point size:5, font:"Arial", geometric bounds:{50, 100, 300, 400}}
    set contents of xFrame1 to "Please work"
end tell

end tell

我做的第一个更改是在您的几何边界中

几何边界:{50100300400}

我把它改成

几何边界:{50分、100分、300分、400分}

请注意,我正在指定度量单位,并用引号括起来。这一点很重要,因为您可能无法始终预测文档设置为什么标尺单位

此外,正如上面的评论中所述,您试图将属性应用于文本框,但它无法理解。相反,您需要将它们应用到文本框架的故事中。完整的工作示例如下

tell application "Adobe InDesign CC 2014"

    activate -- in this instance, activate is optional and personally I don't usually use it unless required by the routine I'm using.
    tell document 1

         set myText to "Please work!"
         set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{"50 pts", "100 pts", "300 pts", "400 pts"}, contents:myText}

         set theStory to parent story of contents of xFrame1
         set properties of theStory to {justification:center align, point size:5, applied font:"Arial"}

    end tell
end tell

我设法解决它的目标文本框通过

                tell xFrame1
                    tell every line
                        set applied font to "Arial"
                        set point size to 10
                    end tell
                end tell

我只是有一个类似的问题,我意识到这可能是最干净的方法,除了应用一个单独的段落样式。希望这能对将来的人有所帮助

tell application "Adobe InDesign CC 2014"
    activate
    tell active document
        tell page 1
            set xFrame1 to make text frame with properties {geometric bounds:{50, 100, 300, 400}}
            set contents of xFrame1 to "Please work"
            tell first text of xFrame1
                set applied font to "Arial"
                set point size to 5
                set justification to center align
            end tell
        end tell
    end tell
end tell

请注意,我还必须告诉页面-对于我的问题,我必须循环浏览文档中的所有页面,并在每个页面上放置一个文本。

文本框没有文本属性。尝试针对它的text属性,因为它是复数,所以您可能需要第一个文本或其他与Javascript的textframe.text[0]等效的文本。