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 01-10-2012, 19:55
MarkH MarkH is offline
Junior Member
 
Join Date: Oct 2012
Posts: 2
Default Inheriting/Copying Rotation Properties from Object

Hi everyone,

I hope someone can help. I have a programmer who is writing a CorelDraw X6 Macro program for me and is stuck.

I have a template with many objects with specific names. The macro is designed to replace the existing objects on the template with imported graphic files (.hpgl) with the same properties ( size, position, rotation etc.)



This works well with importing the files into the same position and scale as long as the rotation is zero

however if the object (shape) on the template is rotated <>0 then this property is ignored and the new imported graphic file is imported with NO rotation.



We do not want to hard code OR have to manually input the rotation. We want to copy, evaluate or inherit this properties from the existing object on the template and apply these properties to the new imported replacement file.

Ie. Get Rotation angle from (Object Name: 'Object1')

then replace old Object Name: 'Object1' with imported file (to be new Object1)

then apply Shape.Rotate = (old rotation angle for Object1)



So I can see the shape.rotate command, but can some help me with the code for how to inherit the existing rotation angle? Shape.Rotate = (old rotation angle for Object1)



I am not a programmer, so I hope I have made myself clear

any guidance would be appreciated

cheers

Mark
Reply With Quote
  #2  
Old 01-10-2012, 23:38
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
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 Rotation

Here is a quick example if I understand you correctly. The following code will import a shape to the currently selected shapes position, change the angle, change the name, then delete the original shape.
Code:
Sub MyAngle()
    Dim s1 As Shape, s2 As Shape
    Dim x As Double, y As Double
    
    Set s1 = ActiveShape 'Get the selected shape
    s1.GetPositionEx cdrCenter, x, y
    
    ActiveLayer.Import "C:\Temp\Files\MyNewShape.cdr" 'Import a new shape
    Set s2 = ActiveShape
    
    s2.SetPositionEx cdrCenter, x, y 'Move the imported shape to position
    s2.RotationAngle = s1.RotationAngle 'Set the angle as s1
    s2.Name = s1.Name 'Name the shapes the same
    s1.Delete 'Delete the original shape
End Sub
-Shelby
Reply With Quote
  #3  
Old 02-10-2012, 01:34
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default

If you just need to replace existing shapes with others ones leaving size, position and rotation then you may not have to use macro for it. Make any shape and convert it to symbol. After this duplicate, distribute, change size and position to make a template. When you need to replace existing shapes with new ones just copy new shape into buffer (Ctrl-C), enter to editing symbols (Ctrl-click on symbol), delete old and paste (Ctrl-V) new shape from buffer. After exiting from edit-mode (another ctrl-click) you can get all shapes are replaced and transformed.
P.S. Sorry for my English, I am from Russia

Last edited by shark; 02-10-2012 at 09:25.
Reply With Quote
  #4  
Old 03-10-2012, 19:09
MarkH MarkH is offline
Junior Member
 
Join Date: Oct 2012
Posts: 2
Default It Works

Thanks Shelby,
I gave the sample code to the programmer and he tested it successfully. Thanks for your help and support

cheers
Mark

Quote:
Originally Posted by shelbym View Post
Here is a quick example if I understand you correctly. The following code will import a shape to the currently selected shapes position, change the angle, change the name, then delete the original shape.
Code:
Sub MyAngle()
    Dim s1 As Shape, s2 As Shape
    Dim x As Double, y As Double
    
    Set s1 = ActiveShape 'Get the selected shape
    s1.GetPositionEx cdrCenter, x, y
    
    ActiveLayer.Import "C:\Temp\Files\MyNewShape.cdr" 'Import a new shape
    Set s2 = ActiveShape
    
    s2.SetPositionEx cdrCenter, x, y 'Move the imported shape to position
    s2.RotationAngle = s1.RotationAngle 'Set the angle as s1
    s2.Name = s1.Name 'Name the shapes the same
    s1.Delete 'Delete the original shape
End Sub
-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
copy center rotation properties buga Macros/Add-ons 0 20-01-2011 06:21
Precision in rotation vindaa CorelDRAW/Corel DESIGNER VBA 2 02-09-2008 21:05
Rotation and PowerClip Craig Tucker CorelDRAW/Corel DESIGNER VBA 3 23-08-2007 16:31
Rotation Angle norbert_ds CorelDRAW/Corel DESIGNER VBA 1 20-04-2007 02:39
Corel X3 - object properties bar absolute/relative position issue JeffDM General 4 14-11-2006 13:55


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


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