Corel USER to USER Web Board • View topic – Script to change all font sizes
What version of PSP are you using? Language use for PSP Scripts is Python though PSP API’s are not available publicly, if you want to code your own scripts. You can however create a script on PSP by using the RECORDING feature of PSP. for more information on recording and saving a script on PSP X3, which is virtually the same process if you are using PSP X4. I can set record macro, manually select a text item and edit the size. Then view the recorded macro but this doesn’t help to solve my problem. That’s not altogether accurate Abiel. Corel published the APIs up through version X1. You just have to know where to look to download them. Version number actually has a little to do with it as some commands or methods change between versions every so slightly. Though most of the base is the same so you’re good with x2. To get you started I recommend downloading the ‘Scripting for Script Authors’ PDF guide which gives a good demonstration of moving through the layers of an image. The ‘Vector Merge Selected’ script also gives a good example of how to tell if the currently selected vector is text, preset shape, or path. I personally cannot tell you how to do this as I’ve never gone into a vector layer but all of the resources exist to help you figure it out. Or maybe one of our better scripters will be able to give you some information. ONe thing to remembe when working with text is that as soon as the point got added as a font size unit, this has caused major headaches in scripting. If you want a size 48 pixels, it might think 48 points which is totally different. Unfortunately, whether it decides to use the point or the pixel as a unit is often totally random. It is a real nightmare for scripting with the Text command. There is no real solution to it (yet). Just wanted to warn you in case you get unexpected results, it is not your fault! Well, no good solution anyway. Cassel and I once worked out some code that would create a new text object, determine its size, and perform the necessary calculations to determine if PSP is currently in Point or Pixel mode. I don’t remember where that one is anymore though. I would have to do some digging, but until then let me try to answer your question. The first option in the tuple moves up or down the level hierarchy (so if you wanted out of a group you’d move out using this one), the second moves up or down the current hierarchy, the third is a list that tells you where to move within the children of the currently selected layer group, and True means it has to match exactly. And so what your code is doing is it’s selecting the first child in the current group and then moving up 1 child for each currently selected object. No trouble if you have only text in the current vector layer and have them all selected but it messes up when you have three objects selected but the third child is not a text object or if you selected from the top down instead of from the bottom up. Or if you have children from multiple groups selected. So, this requires that you know exactly where the text should be. If the text object already exists it’ll change the values for that object. If it does not exist in that location it will create a new text object at that point. Since this is relative to the first selected object. So what you need to do is grab the navigation path for each selected object. This is provided in the dictionary under the key ‘Path.’ So instead of iterating ‘i’ and selecting the child from there just use the path that PSP has already figured out for you. The txt[‘TextTarget’] holds a path to the current object. By default this is set to None. If you don’t set this value it just makes a new text object. If you want it to change a current object you need to set this value like you were. Each vector object returned by ‘ReturnVectorObjectProperties’ includes a path variable already. So what you need to do is set the txt[‘TextTarget’] value equal to this returned path. It’s saved in the ‘Path’ key of the item object. So if you do say Thank you very much for your help, I doubt that I would have worked this out from the script writers guide alone. If you ask me, the script writers guide could do with a few more samples in vector processing. Source.