Changing vector text/wrapping

Moderator: Kathy_9

Post Reply
kgsodie
Posts: 2
Joined: Wed Sep 26, 2018 9:24 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit

Changing vector text/wrapping

Post by kgsodie »

I have an existing image that has a layer whose vector text was created and bound to a selection rectangle. From a psp script, I'd like to replace the multi-line text and have it continue to honor the wrapping rectangle. However, my code efforts so far always replace the text, but performs no text wrapping (the text appears on a single line, off the right edge of the image).

With the layer selected, this is the script I am running:

Code: Select all

    Result = App.Do( Environment, 'ReturnVectorObjectProperties' )
    for item in Result['ListOfObjects']:
        myText = item['TextExData']
        if myText != None:
            break
    if myText == None:
        return
    myText['Characters'] = text
    myText['PointSize'] = pointSize
    myText['Fill']['Color'] = color
    myText['Stroke']['Color'] = color
    myText['InObject'] = True
    myText['TextFlow'] = App.Constants.TextFlow.HorizontalDown
    myText['TextTarget'] = (0,0,[1],True) #item['Path'] #layerTuples[name]
    App.Do(Environment, 'TextEx', myText)
Where I set the ['TextTarget'] I believe I should be able to use item['Path'], but this seems to create a new layer. The only thing that seems to work is the hard coded tuple (0,0,[1],True). This is all secondary though to the text wrapping. What am I doing wrong?
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
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: Changing vector text/wrapping

Post by LeviFiction »

1) You need to be careful with the TextTarget path, from what I can tell it's a relative path. As in "How do I get to the target from where I currently am?" The returned "Path" key is an absolute path, how do you get to the currently selected layer from the very bottom layer in the layers palette? This also means that (0, 0, [1], True) will always point to the bottom most object the in the current object group, or layer, or group layer. So if you have two text objects in the same vector layer, then (0,0,[1], True) will always select the bottom most one.

You can deal with this in one of two ways. 1) You can use the "SelectLayer" command with (-9999,-9999,[],False) to select the bottom most layer in the layers palette. Then the Path variable will correctly reference a relative path back to the text object. Or, take the path, grab the list from the path, grab the last item in the list, and that will be the child you need to use in this path (0,0, [child], True).

The second options is really easy. Just grab the -1 index from the 2nd index of the item path. In other words [ item['Path'][2][-1] ].

Code: Select all


RelativePath = (0, 0, [ item['Path'][2][-1] ], True)

2) As far as I know, you're not doing anything "wrong" it just doesn't work with scripts if your text is wrapped using a selection.

If you record yourself editing a text object, and then play back the recorded script you'll see it shows the same bug. So while it does work in the interface, it doesn't work in scripting.

But, if you have a vector path, and you set that path as the PathTarget (also a relative path), then scripts work just fine. The problem there being that ReturnVectorProperties doesn't tell you what path you're connected to if you're using text wrapping.
https://levifiction.wordpress.com/
kgsodie
Posts: 2
Joined: Wed Sep 26, 2018 9:24 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit

Re: Changing vector text/wrapping

Post by kgsodie »

Thanks for the advice Levi. As a PSP scripting newbie, I'm coming to understand that everything the script recorder records does not necessarily translate back into directly executable script. I have solved the problem by adding an invisible rectangle to the layer, then binding the text object to it via the PathTarget, as you suggested.

You're a font of information on this forum, and it is appreciated!

Kevin
Post Reply