mirror of
https://github.com/sbrow/ps.git
synced 2025-12-29 18:47:38 -05:00
Fixed an error in dojs.vbs where arguments were being split.
* Fixed SetText() to update bounds.
This commit is contained in:
2
ps.go
2
ps.go
@@ -148,7 +148,7 @@ func run(name string, args ...string) ([]byte, error) {
|
|||||||
if strings.Contains(name, "dojs") {
|
if strings.Contains(name, "dojs") {
|
||||||
args = append([]string{opts, filepath.Join(pkgpath, "scripts", name)},
|
args = append([]string{opts, filepath.Join(pkgpath, "scripts", name)},
|
||||||
args[0],
|
args[0],
|
||||||
fmt.Sprintf("%s", strings.Join(args[1:], ",")),
|
fmt.Sprintf("%s", strings.Join(args[1:], ",,")),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
args = append([]string{opts, filepath.Join(pkgpath, "scripts", name)}, args...)
|
args = append([]string{opts, filepath.Join(pkgpath, "scripts", name)}, args...)
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ Set appRef = CreateObject("Photoshop.Application")
|
|||||||
if wScript.Arguments.Count = 0 then
|
if wScript.Arguments.Count = 0 then
|
||||||
wScript.Echo "Missing parameters"
|
wScript.Echo "Missing parameters"
|
||||||
else
|
else
|
||||||
|
' wScript.Echo wScript.Arguments(0)
|
||||||
|
' wScript.Echo wScript.Arguments(1)
|
||||||
path = wScript.Arguments(0)
|
path = wScript.Arguments(0)
|
||||||
args = wScript.Arguments(1)
|
args = wScript.Arguments(1)
|
||||||
error = appRef.DoJavaScriptFile(path, Split(args, ","))
|
error = appRef.DoJavaScriptFile(path, Split(args, ",,"))
|
||||||
if Not error = "true" and Not error = "[ActionDescriptor]" and Not error = "undefined" Then
|
if Not error = "true" and Not error = "[ActionDescriptor]" and Not error = "undefined" Then
|
||||||
Err.raise 1, "dojs.vbs", error
|
Err.raise 1, "dojs.vbs", error
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include lib.js
|
#include lib.js
|
||||||
|
|
||||||
// var saveFile = File(arguments[0]);
|
// var saveFile = File(arguments[0]);
|
||||||
var arg = 'app.activeDocument.layerSets.getByName("Text").artLayers.getByName("short");';
|
var arg = "app.activeDocument.layerSets.getByName('Text').artLayers.getByName('short').textItem.contents='When another sandman is discarded from a lane,';";
|
||||||
var set = eval(arg);
|
var set = eval(arg);
|
||||||
// set.textItem.size=10;
|
// set.textItem.size=10;
|
||||||
alert(set.textItem.font)
|
|
||||||
// var doc=app.activeDocument
|
// var doc=app.activeDocument
|
||||||
// doc.layerSets.getByName("ResolveGem").merge();
|
// doc.layerSets.getByName("ResolveGem").merge();
|
||||||
// alert(doc.artLayers.getByName("ResolveGem").bounds);
|
// alert(doc.artLayers.getByName("ResolveGem").bounds);
|
||||||
|
|||||||
17
structs.go
17
structs.go
@@ -753,11 +753,20 @@ func (t *TextItem) SetText(txt string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
lyr := strings.TrimRight(JSLayer(t.parent.Path()), ";")
|
lyr := strings.TrimRight(JSLayer(t.parent.Path()), ";")
|
||||||
js := fmt.Sprintf("%s.textItem.contents='%s';", lyr, txt)
|
bndtext := "[[' + lyr.bounds[0] + ',' + lyr.bounds[1] + '],[' + lyr.bounds[2] + ',' + lyr.bounds[3] + ']]"
|
||||||
_, err := DoJs("compilejs.jsx", js)
|
js := fmt.Sprintf(`%s.textItem.contents='%s';var lyr = %[1]s;stdout.writeln(('%[3]s').replace(/ px/g, ''));`,
|
||||||
if err != nil {
|
lyr, txt, bndtext)
|
||||||
t.contents = txt
|
byt, err := DoJs("compilejs.jsx", js)
|
||||||
|
var bnds *[2][2]int
|
||||||
|
json.Unmarshal(byt, &bnds)
|
||||||
|
if err != nil || bnds == nil {
|
||||||
|
log.Println("text:", txt)
|
||||||
|
log.Println("js:", js)
|
||||||
|
fmt.Printf("byt: '%s'\n", string(byt))
|
||||||
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
t.contents = txt
|
||||||
|
t.parent.bounds = *bnds
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TextItem) SetSize(s float64) {
|
func (t *TextItem) SetSize(s float64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user