I have a script that I got from another resource, but I can't seem to get it to work. I am not sure what values to enter to make this script work. Any help would be appreciated. Before I give the script I will give a little detail about what I am trying to do. I am adding multiple layers to 1 image and arranging them to a grid, creating a multi layered sprite sheet. I have corel paintshop pro x8. The problem is with 60 plus images per sheet I do not want to individually arrange them. Each layer is 48x48 and the sheet size is dependent on the amount of layers per sheet. Thanks for your help.
if (documents.length > 0)
{
// --------------------------
docRef = activeDocument;
var activeLayer = docRef.activeLayer;
numLayers = docRef.artLayers.length;
var cols = docRef.width;
var spriteX = docRef.width;
// put things in order
app.*** = Units.PIXELS;
// resize the canvas
newX = numLayers * spriteX;
docRef.resizeCanvas( newX, docRef.height, AnchorPosition.TOPLEFT );
// move the layers around
for (i=0; i < numLayers; i++)
{
docRef.artLayers.visible = 1;
var movX = spriteX*i;
docRef.artLayers.translate(movX, 0);
}
}
Making A script work
Moderator: Kathy_9
-
tosbourne88
- Posts: 1
- Joined: Tue Dec 27, 2016 10:14 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Making A script work
Are you using PaintShop Pro X8? Or PhotoPaint X8? Just want to make sure I'm giving the right information. PhotoPaint comes with Corel Draw.
You can't get it to work because it seems to be written in javascript (or similar ECMAScript based language). Paint Shop Pro uses Python as its scripting language. Also because this comes from a different system not everything will work the same way. Like resizing, or translating individual layer items. It would be possible to convert this if needed provided there aren't any hidden items or major differences in how they're moving items around. Doesn't appear to be.
Cassel made a contact-sheet script which may be able to do what you're looking for. I am making an assumption there. And the manage mode does have its own Contact Sheet function. Not sure if you want to try these options.
Cassel's Script - http://creationcassel.com/store/index.p ... GPi-lyYL-s
For Manage Modes' Contact sheet option you need to either have all of the images in a single folder, or in a smart collection. With a collection selected along the bottom you'll see a button for "More Options" it looks like a blue rectangle with a down-arrow next to it. That'll open a menu with a "Print Contact Sheet' option. Only issue is that it doesn't create a custom sized image with images at a specific size. So I don't think it fits exactly with what you want.
Again, if you want this script converted we can probably do that. Is what you posted the whole script or just the re-arranging portion after all of the layers have been brought in?
EDIT:
I believe this would be the Python equivalent. It requires more lines, because some things PSP does are inefficient. They used an object oriented language like PSP and made very little of it Object Oriented. It's crazy, honestly. I also left in some parameters and lines that aren't strictly necessary either to match what was in the original script snippet you gave us or because I was lazy. And a few lines were added to make up for how PSP handles information. I also used Pick instead of Move which would have been smaller to write out. Not sure why I used pick...I just did.
You can't get it to work because it seems to be written in javascript (or similar ECMAScript based language). Paint Shop Pro uses Python as its scripting language. Also because this comes from a different system not everything will work the same way. Like resizing, or translating individual layer items. It would be possible to convert this if needed provided there aren't any hidden items or major differences in how they're moving items around. Doesn't appear to be.
Cassel made a contact-sheet script which may be able to do what you're looking for. I am making an assumption there. And the manage mode does have its own Contact Sheet function. Not sure if you want to try these options.
Cassel's Script - http://creationcassel.com/store/index.p ... GPi-lyYL-s
For Manage Modes' Contact sheet option you need to either have all of the images in a single folder, or in a smart collection. With a collection selected along the bottom you'll see a button for "More Options" it looks like a blue rectangle with a down-arrow next to it. That'll open a menu with a "Print Contact Sheet' option. Only issue is that it doesn't create a custom sized image with images at a specific size. So I don't think it fits exactly with what you want.
Again, if you want this script converted we can probably do that. Is what you posted the whole script or just the re-arranging portion after all of the layers have been brought in?
EDIT:
I believe this would be the Python equivalent. It requires more lines, because some things PSP does are inefficient. They used an object oriented language like PSP and made very little of it Object Oriented. It's crazy, honestly. I also left in some parameters and lines that aren't strictly necessary either to match what was in the original script snippet you gave us or because I was lazy. And a few lines were added to make up for how PSP handles information. I also used Pick instead of Move which would have been smaller to write out. Not sure why I used pick...I just did.
Code: Select all
from JascApp import *
def Do(Environment):
if len(App.Documents) > 0:
docRef = App.ActiveDocument
docWidth = docRef.Width
docHeight = docRef.Height
activeLayer = App.Do(Environment, 'ReturnLayerProperties',{})['Path']
info = App.Do(Environment, 'ReturnImageInfo',{})
numLayers = info['LayerNum']
cols = docRef.Width
spriteX = docRef.Width
PixelUnits = App.Constants.UnitsOfMeasure.Pixels
newX = numLayers * spriteX
App.Do( Environment, 'ResizeCanvas', {'AspectRatio': docRef.Width/docRef.Height, 'FillColor': (255,255,255), 'HoriPlace': App.Constants.HorizontalType.Left, 'MaintainAspect': False, 'NewDimUnits': PixelUnits, 'NewHeight': docRef.Height,'NewWidth': newX, 'PlaceBottom': 0, 'PlaceLeft': 0, 'PlaceRight': 0, 'PlaceTop': 0, 'VertPlace': App.Constants.VerticalType.Top, }, docRef)
#move the layers around
for i in range(numLayers):
movX = spriteX*i
App.Do( Environment, 'Pick', {'Type': App.Constants.ObjectSelection.Select,'X': 0,'Y': 0,'Width': 1, 'Height': 1, 'Group': True, 'Handle1': (movX,docHeight),'Handle2': (movX,0),'Handle3': (movX + docWidth,0),'Handle4': (movX + docWidth,docHeight),'Pivot': ((movX + docWidth)/2.0,docHeight/2.0), 'EarlyX4Script': False, })
App.Do(Environment, 'SelectNextLayer',{})
https://levifiction.wordpress.com/
