NEW! PaintShop Pro 2019

Where is the vector text in my script?

Moderator: Kathy_9

Where is the vector text in my script?

Postby Rivermonster » Mon Feb 06, 2012 1:12 pm

(PaintShop Pro v8.10)

Hi,

(My actual problem is more complex. I have simplified it here.)

I have a single vector text instance in my (PSP file) image. It says "cat". I want to make multiple copies of the image but with the word "cat" localized into different languages. Rather than editing the vector text via the "Text Entry" dialog box I was hoping to be able to do this with a script. The the idea is that I would have a copy of the script for each language, change the relevant text as required and run the script. E.g. For French, I would edit the script changing "cat" to "chat" and then run the script against the French image. (If you are now thinking there are better ways to do this, please bear with me because like I said I have simplified things).

So first I wanted to identify the part of the script that I would need to edit. To do this I created a script as follows: I started the script recorder, change the text "cat" to "dog" in the Text Entry dialog box, saved the script, opened it in a text editor and searched for the text "dog". However, the word "dog" does not appear anywhere in the script. I don't understand this. Where is the vector text "dog" being stored? If I run the script against a different image that also has a single instance of vector text, it changes the text to "dog", so the script is working correctly.

Any help would be appreciated.

Thanks,

Adrian
Rivermonster
 
Posts: 7
Joined: Mon May 23, 2011 8:50 pm
Location: Bristol, UK
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Where is the vector text in my script?

Postby LeviFiction » Mon Feb 06, 2012 3:33 pm

Does your text editor search for the complete word or just the letters themselves? PSP would use " u'dog' " to specify unicode text. So if your search function doesn't separate dog from the surrounding u' ' it won't find it.

The command should be TextEx and the parameter should be 'Characters' : u'dog' ,

Might look something like this (I don't have PSP 8 so there could be differences)

Code: Select all
#Text
App.Do( Environment, 'TextEx', {
...'Some long list of parameters'
'Characters' : u'dog',
'Strings': None,
....'more parameters'
}
})
LeviFiction
Advisor
 
Posts: 5397
Joined: Thu Oct 02, 2008 1:07 pm
Location: USA
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019

Re: Where is the vector text in my script?

Postby Rivermonster » Mon Feb 06, 2012 4:18 pm

Thanks for your reply.

My text editor looks for the search term in any combination. I checked the script line by line manually and do not find the term. In fact, I do not see any line containing "'Characters" either. I have pasted the script below. In case it was corrupted the first attempt I have repeated capturing the script and it comes out the same. I must be doing something wrong but as the script runs properly I cant work out what.

Adrian
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx SCRIPT BELOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxx
from JascApp import *

def ScriptProperties():
return {
'Author': u'Adrian',
'Copyright': u'',
'Description': u'',
'Host': u'Paint Shop Pro',
'Host Version': u'8.10'
}

def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {

})

# TextEditDelete
App.Do( Environment, 'TextEditDelete', {
'DeleteBegin': (0,0),
'DeleteEnd': (0,-1),
'Path': (0,0,[1],App.Constants.Boolean.false),
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})

# TextEditInsert
App.Do( Environment, 'TextEditInsert', {
'Visibility': App.Constants.Boolean.true,
'Fill': None,
'Font': u'Microsoft Sans Serif',
'LineStyle': {
'Name': u'',
'FirstCap': (u'Butt',0.25,0.25),
'LastCap': (u'Butt',0.25,0.25),
'FirstSegCap': (u'',0.25),
'LastSegCap': (u'',0.25),
'UseSegmentCaps': App.Constants.Boolean.false,
'Segments': []
},
'LineWidth': 0.05,
'MiterLimit': None,
'PointSize': 8,
'StartRowColumn': (0,0),
'Start': (0,0),
'Stroke': None,
'Text': u'd',
'TextType': None,
'ForceLine': App.Constants.Boolean.false,
'Path': (0,0,[1],App.Constants.Boolean.false),
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})

# TextEditInsert
App.Do( Environment, 'TextEditInsert', {
'Antialias': None,
'WarpText': None,
'Visibility': App.Constants.Boolean.true,
'AutoKern': None,
'Bold': None,
'Kerning': None,
'Leading': None,
'Fill': None,
'Font': None,
'Italic': None,
'Join': None,
'LineStyle': None,
'LineWidth': None,
'MiterLimit': None,
'PointSize': None,
'StartRowColumn': (0,1),
'SetText': None,
'Start': (0,0),
'Strikethru': None,
'Stroke': None,
'Text': u'o',
'TextType': None,
'Underline': None,
'ForceLine': App.Constants.Boolean.false,
'Path': (0,0,[1],App.Constants.Boolean.false),
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})

# TextEditInsert
App.Do( Environment, 'TextEditInsert', {
'Antialias': None,
'WarpText': None,
'Visibility': App.Constants.Boolean.true,
'AutoKern': None,
'Bold': None,
'Kerning': None,
'Leading': None,
'Fill': None,
'Font': None,
'Italic': None,
'Join': None,
'LineStyle': None,
'LineWidth': None,
'MiterLimit': None,
'PointSize': None,
'StartRowColumn': (0,2),
'SetText': None,
'Start': (0,0),
'Strikethru': None,
'Stroke': None,
'Text': u'g',
'TextType': None,
'Underline': None,
'ForceLine': App.Constants.Boolean.false,
'Path': (0,0,[1],App.Constants.Boolean.false),
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})
Rivermonster
 
Posts: 7
Joined: Mon May 23, 2011 8:50 pm
Location: Bristol, UK
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Where is the vector text in my script?

Postby LeviFiction » Mon Feb 06, 2012 4:46 pm

I have solved your issue.

First it opens the text for editing, then it has three commands that enter the text in one letter at a time. In other words PSP8 has recorded every step you made. You'll notice the three commands start like this

Code: Select all
# TextEditInsert
App.Do( Environment, 'TextEditInsert', {


Inside them you will find the parameter

Code: Select all
'Text': u'd',


Try deleting the other two copies and changing this line from "u'd'," to "u'dog'" and run the script. If I'm right this small edit will solve your issue. The problem was that PSP8 recorded each individual key-stroke as a separate command. Later versions just change the whole text value.

So the end result should be similar to this
Code: Select all
from JascApp import *

def ScriptProperties():
    return {
        'Author': u'Adrian',
        'Copyright': u'',
        'Description': u'',
        'Host': u'Paint Shop Pro',
        'Host Version': u'8.10'
}

def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {

    })

    # TextEditDelete
    App.Do( Environment, 'TextEditDelete', {
        'DeleteBegin': (0,0),
        'DeleteEnd': (0,-1),
        'Path': (0,0,[1],App.Constants.Boolean.false),
        'GeneralSettings': {
            'ExecutionMode': App.Constants.ExecutionMode.Default,
            'AutoActionMode': App.Constants.AutoActionMode.Match
        }
    })

    # TextEditInsert
    App.Do( Environment, 'TextEditInsert', {
        'Visibility': App.Constants.Boolean.true,
        'Fill': None,
        'Font': u'Microsoft Sans Serif',
        'LineStyle': {
            'Name': u'',
            'FirstCap': (u'Butt',0.25,0.25),
            'LastCap': (u'Butt',0.25,0.25),
            'FirstSegCap': (u'',0.25),
            'LastSegCap': (u'',0.25),
            'UseSegmentCaps': App.Constants.Boolean.false,
            'Segments': []
        },
        'LineWidth': 0.05,
        'MiterLimit': None,
        'PointSize': 8,
        'StartRowColumn': (0,0),
        'Start': (0,0),
        'Stroke': None,
        'Text': u'dog ',    <--This is the value to change
        'TextType': None,
        'ForceLine': App.Constants.Boolean.false,
        'Path': (0,0,[1],App.Constants.Boolean.false),
        'GeneralSettings': {
            'ExecutionMode': App.Constants.ExecutionMode.Default,
            'AutoActionMode': App.Constants.AutoActionMode.Match
        }
    })
LeviFiction
Advisor
 
Posts: 5397
Joined: Thu Oct 02, 2008 1:07 pm
Location: USA
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019

Re: Where is the vector text in my script?

Postby Rivermonster » Mon Feb 06, 2012 5:06 pm

I was wondering why there were three inserts :-)

That works great. Thanks!

Adrian
Rivermonster
 
Posts: 7
Joined: Mon May 23, 2011 8:50 pm
Location: Bristol, UK
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit


Return to PSP Scripting

Who is online

Users browsing this forum: No registered users and 2 guests