Hello,
I'm working on designing an app that consists of a single background and many many buttons.
I have the look layed out in paintshop pro 2020, and I would like to get the positions of all the buttons.
Each element is in it's own layer.
The background is it's own layer/object and each button is it's own layer.
Is there a way to get the position of each button relative to the size of the entire image?
Also the buttons are created automatically by a script that uses TextTool as captured from the macro recorder. What i'm encountering sometimes is that the font size is to big and overruns the button. How would I detect this and scale back the font size?
-james
getting object position via vba
Moderator: Kathy_9
-
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: getting object position via vba
To get the rectangle to represents any selected object the command is GetVectorSelectionRect
That returns a dictionary with one of the keys being 'VectorRect'. This returns a tuple (non-editable array) of three values: 0) Another tuple of 2 values (x,y), 1) Width, 2)Height.
As for text.
If you know the size of the object you're comparing the size of the text to, you can easily just check the rectangles and then use the TextEx command to change the size of the text, and then recheck until it comes out how you want.
Code: Select all
info = App.Do( Environment, 'GetVectorSelectionRect', {})
Code: Select all
info = App.Do( Environment, 'GetVectorSelectionRect', {})
x,y = info['VectorRect'][0]
width,height = info['VectorRect'][1], info['VectorRect'][2]
If you know the size of the object you're comparing the size of the text to, you can easily just check the rectangles and then use the TextEx command to change the size of the text, and then recheck until it comes out how you want.
https://levifiction.wordpress.com/
Re: getting object position via vba
Thanks that makes sense and now for the embarrassing part.
I'm using photo-paint 2020
which would explain why the docs didn't match up...
The concept should still apply, just need to find the commands for it in the correct product documentation.
I'm using photo-paint 2020
The concept should still apply, just need to find the commands for it in the correct product documentation.
- Ken Berry
- Site Admin
- Posts: 22481
- Joined: Fri Dec 10, 2004 9:36 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Gigabyte B550M DS3H AC
- processor: AMD Ryzen 9 5900X
- ram: 32 GB DDR4
- Video Card: AMD RX 6600 XT
- Hard_Drive_Capacity: 1 TB SSD + 2 TB HDD
- Monitor/Display Make & Model: Kogan 32" 4K 3840 x 2160
- Corel programs: VS2022; PSP2023; DRAW2021; Painter 2022
- Location: Levin, New Zealand
Re: getting object position via vba
You could also register again in the CorelDRAW community at https://community.coreldraw.com/ It looks after Photo-Paint, not us.
Ken Berry
Re: getting object position via vba
sounds good, I will head over there.
Sorry for the noise.
Sorry for the noise.
