OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Corel Photo-Paint VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-06-2010, 11:18
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default Aligning an object to a specific coordinate

A recent thread on the Photo-paint X4 forum at coreldraw.com got me wondering if a macro could be created to align the center of a selected object in PP to a specified point or coordinate.

I tried something very basic first but the center always aligns to the upper left corner, not the x-y coordinates I entered in the macro. The 3 and 5 are inches and are just arbitrary. The goal is to align the object's (a.k.a. object layer) center with the whatever coordinates you want.


Code:
Sub AlignCenterToPoint()

   ActiveLayer.AlignToPoint pntAlignHCenter + pntAlignVCenter, 3#, 5#

End Sub

I also asked this on the PPX4 newsgroup, but only one person had any input. I thought I would throw it out here and see if anyone else had some ideas.
Patti
Reply With Quote
  #2  
Old 04-06-2010, 12:59
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default SetPosition

I believe you want to use SetPosition. From testing in X5, it looks like this sets the top left corner of the layer to any coordinates. So if you want to set the center you just do a little math with the width and height. Say I want the center of the layer at 100 pixels by 100 pixels I would do it like this:

Code:
Sub MoveMe()
    Dim w As Long, h As Long
    
    ActiveLayer.GetSize w, h
    ActiveLayer.SetPosition 100 - w / 2, 100 - h / 2
End Sub
If you wanted to move a number of layers to the same position, select them and run something like this:

Code:
Sub MoveMySelection()
    Dim w As Long, h As Long
    Dim ly As Layer
    
    For Each ly In Layers.Selection
        ly.GetSize w, h
        ly.SetPosition 100 - w / 2, 100 - h / 2
    Next ly
End Sub
Hope that helps,

-Shelby
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
X5 Watch For Specific Action knowbodynow CorelDRAW/Corel DESIGNER VBA 15 06-05-2010 00:24
How to select a word at specific tab position aakkaarr CorelDRAW/Corel DESIGNER VBA 4 28-12-2009 14:43
Aligning Grouped Objects bprice CorelDRAW/Corel DESIGNER VBA 1 12-10-2008 01:07
Align to Specific Layer ProofingGuy CorelDRAW/Corel DESIGNER VBA 6 11-06-2008 17:11
Node Coordinate designation ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 24-02-2005 09:00


All times are GMT -5. The time now is 04:25.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com