OberonPlace.com Forums > VBA Rotate to Reference Point Object
 Blogs Gallery FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

#1
10-10-2013, 05:31
 dungbtl Senior Member Join Date: Apr 2004 Posts: 151
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

#2
01-11-2013, 01:08
 nic Member Join Date: May 2009 Posts: 90
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
#3
30-11-2013, 10:06
 dungbtl Senior Member Join Date: Apr 2004 Posts: 151

Thanks Nic

Sometimes hangs in X4

But otherwise like a charm.

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

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home OberonPlace Discussion     Site News     Web site suggestions     Image Gallery     Testing Oberon Products     CurveWorks     SecuriDesign     Calendar Wizard     Oberon Function Plotter     Jigsaw Puzzle Creator     Other Oberon Commercial Products     New product ideas Corel User Forums     CorelDRAW         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel DESIGNER         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel PHOTO-PAINT         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     General         About Corel         Off-Topic Developer Forums     OberonPlace Development Portal     VBA         CorelDRAW/Corel DESIGNER VBA         Corel Photo-Paint VBA         Code Critique     Corel Script         CorelDRAW CS         Corel Photo-Paint CS

 Similar Threads Thread Thread Starter Forum Replies Last Post xombie CorelDRAW/Corel DESIGNER VBA 2 25-05-2011 13:20 first5mins General 2 21-01-2010 14:57 Steve CorelDRAW/Corel DESIGNER VBA 22 19-03-2008 09:48 met CorelDRAW/Corel DESIGNER VBA 1 02-11-2005 07:31 Anonymous Code Critique 3 14-01-2005 17:07

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

 OberonPlace.com - Archive - Top