OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-10-2013, 05:31
dungbtl's Avatar
dungbtl dungbtl is offline
Senior Member
 
Join Date: Apr 2004
Posts: 148
Default Rotate to Reference Point Object

Hello All,

This one I wouldnt know where to begin:

Need a series of objects on maps that point to a reference point.
Doing this manually is time consuming as there are bunches of maps
and each one is different. Some maps are to zoomed into.

We are working in Coreldraw X4

Selected objects (Blue Box Arrows) must rotate to the reference point (Red Star), the pink dash lines are just for the path view, not to be included see pic below:

Thanks!
Attached Images
 
Reply With Quote
  #2  
Old 01-11-2013, 01:08
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Post process

One way of doing this might be to set the point from which you wish to measure the rotation as the origin and then work out the tangents from there

This is a bit of code that works in X6 it might do as a base for you to work with
Code:
Sub RotEach()
    
    Dim s As Shape
    Dim x As Double
    Dim y As Double
    Dim ro As Double

ActiveDocument.Unit = cdrMillimeter
ActiveDocument.DrawingOriginX = 0 ' x and y = 0 - seems to set origin
ActiveDocument.DrawingOriginY = 0 ' to centre of page
ActiveDocument.ReferencePoint = cdrCenter

    
    Optimization = True
    
For Each s In ActivePage.Shapes ' could be changed to activeselection
      
        x = s.PositionX
        y = s.PositionY

        If x < 0 And y <> 0 Then ro = Atn(y / x) * 57.29577 + 90 'Atan in radians - converts to degrees and adds right angle
        If x > 0 And y <> 0 Then ro = Atn(y / x) * 57.29577 - 90
        If x = 0 And y > 0 Then ro = 0
        If x = 0 And y < 0 Then ro = 180
        If y = 0 And x > 0 Then ro = 270
        If y = 0 And x < 0 Then ro = 90
        If y = 0 And x = 0 Then ro = 0
        
        s.Rotate ro 
        
Next s
        
        
    Optimization = False
    ActiveWindow.Refresh
End Sub

Last edited by nic; 15-11-2013 at 14:02. Reason: to prevent division by zero
Reply With Quote
  #3  
Old 30-11-2013, 10:06
dungbtl's Avatar
dungbtl dungbtl is offline
Senior Member
 
Join Date: Apr 2004
Posts: 148
Default

Thanks Nic

Sometimes hangs in X4

But otherwise like a charm.

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
Object reference xombie CorelDRAW/Corel DESIGNER VBA 2 25-05-2011 13:20
Macro to rotate first5mins General 2 21-01-2010 14:57
Is the a X3 to X4 Object Code difference reference? Steve CorelDRAW/Corel DESIGNER VBA 22 19-03-2008 09:48
Pick a Point met CorelDRAW/Corel DESIGNER VBA 1 02-11-2005 07:31
Rotate around a centre Anonymous Code Critique 3 14-01-2005 17:07


All times are GMT -5. The time now is 14:23.


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