Photoshop Scripting way slower than native Photoshop functionality
Hi everyone,
I'm currently working on a photoshop extension for more customizable grid layouts.
I noticed, that small operations like adding a guide line take quite long to execute.
However, when you use photoshops "create new guide layout"-function, all the guides (even if you add like 100+ columns) are displayed immediately, without any delay.

My code looks something like that:
function createGrid() {
resetGuides()
var guidePos = 0
for(var i = 1; i<= columns; i++) {
guidePos += columnStep*i
createGuideLine('Vrtc', guidePos)
}
}
function resetGuides() {
var idclearAllGuides = stringIDToTypeID( "clearAllGuides" )
executeAction( idclearAllGuides, undefined, DialogModes.NO )
}
function createGuideLine(orientation, pixelposition) {
var idMk = charIDToTypeID( "Mk " )
var desc37 = new ActionDescriptor()
var idNw = charIDToTypeID( "Nw " )
var desc38 = new ActionDescriptor()
var idPstn = charIDToTypeID( "Pstn" )
var idPxl = charIDToTypeID( "#Pxl" )
desc38.putUnitDouble( idPstn, idPxl, pixelposition )
var idOrnt = charIDToTypeID( "Ornt" )
var idOrnt = charIDToTypeID( "Ornt" )
var idOr = charIDToTypeID( orientation )
desc38.putEnumerated( idOrnt, idOrnt, idOr )
var idGd = charIDToTypeID( "Gd " )
desc37.putObject( idNw, idGd, desc38 )
executeAction( idMk, desc37, DialogModes.NO )
}
I've read that ActionDescriptor Code is faster than DOM operations (which would be app.guides.add(...)), but I'm already using those where possible and it's still increasingly slow the more guides are being added.
Also, I'm already using the SuspendHistory function.
Do you have any idea how to get a more instant rendering of the guides? Maybe clearing all guides and drawing them in a loop isn't the right way. Should I always keep track of the existing guides and just move them around? I don't feel like this would improve it, since photoshops "guide layout" feature can display many new guides in a milisecond..
