There is a scripting API for the repeat grid, but probably no one has seen it working correctly. Just a null pointer waiting for you. However, repeat grid spacing, flipping, etc. are under the control of preferences and can be handled with setRealPreference, and so on. /**
* @File make repeat grid from selection
* @version 1.0.0
* @author sttk3.com
* @copyright © 2023 sttk3.com
*/
(function() {
if(app.documents.length <= 0) {return ;}
var doc = app.documents[0] ;
var sel = doc.selection ;
if(sel.length <= 0) {return ;}
// define repeat grid pattern types value
var GridPatternTypes = {
'GRID': 0,
'BRICK_BY_ROW': 1,
'BRICK_BY_COLUMN': 2
} ;
// define preference keys
var pref = app.preferences ;
var keyHorizontalSpacing = 'plugin/Adobe Repeat Arts UI/HorizontalSpacing' ;
var keyVerticalSpacing = 'plugin/Adobe Repeat Arts UI/VerticalSpacing' ;
var keyGridPatternType = 'plugin/Adobe Repeat Arts UI/GridPatternType' ;
var keyFlipRowHorizontal = 'plugin/Adobe Repeat Arts UI/FlipRowY' ;
var keyFlipRowVertical = 'plugin/Adobe Repeat Arts UI/FlipRowX' ;
var keyFlipColumnHorizontal = 'plugin/Adobe Repeat Arts UI/FlipColumnY' ;
var keyFlipColumnVertical = 'plugin/Adobe Repeat Arts UI/FlipColumnX' ;
var oldHorizontalSpacing, oldVerticalSpacing, oldGridPatternType, oldFlipRowHorizontal, oldFlipRowVertical, oldFlipColumnHorizontal, oldFlipColumnVertical ;
try {
// store original settings
oldHorizontalSpacing = pref.getRealPreference(keyHorizontalSpacing) ;
oldVerticalSpacing = pref.getRealPreference(keyVerticalSpacing) ;
oldGridPatternType = pref.getIntegerPreference(keyGridPatternType) ;
oldFlipRowHorizontal = pref.getBooleanPreference(keyFlipRowHorizontal) ;
oldFlipRowVertical = pref.getBooleanPreference(keyFlipRowVertical) ;
oldFlipColumnHorizontal = pref.getBooleanPreference(keyFlipColumnHorizontal) ;
oldFlipColumnVertical = pref.getBooleanPreference(keyFlipColumnVertical) ;
// set horizontal spacing
pref.setRealPreference(keyHorizontalSpacing, 40.0) ;
// set vertical spacing
pref.setRealPreference(keyVerticalSpacing, 20.0) ;
// set grid type
pref.setIntegerPreference(keyGridPatternType, GridPatternTypes.GRID) ;
// set flip rows
pref.setBooleanPreference(keyFlipRowHorizontal, true) ;
pref.setBooleanPreference(keyFlipRowVertical, false) ;
// set flip column
pref.setBooleanPreference(keyFlipColumnHorizontal, false) ;
pref.setBooleanPreference(keyFlipColumnVertical, true) ;
// make repeat grid from selection
app.executeMenuCommand('Make Grid Repeat') ;
} catch(e) {
alert(e) ;
} finally {
// restore original settings
pref.setRealPreference(keyHorizontalSpacing, oldHorizontalSpacing) ;
pref.setRealPreference(keyVerticalSpacing, oldVerticalSpacing) ;
pref.setIntegerPreference(keyGridPatternType, oldGridPatternType) ;
pref.setBooleanPreference(keyFlipRowHorizontal, oldFlipRowHorizontal) ;
pref.setBooleanPreference(keyFlipRowVertical, oldFlipRowVertical) ;
pref.setBooleanPreference(keyFlipColumnHorizontal, oldFlipColumnHorizontal) ;
pref.setBooleanPreference(keyFlipColumnVertical, oldFlipColumnVertical) ;
}
})() ;
... View more