![]() |
#1
|
||||
|
||||
![]()
CD11 is my version... and now, on with the show...
I am trying to create a macro that will take the selected object (i.e. straight line or circle) and rotate copies of that object. Here's the deal... I am starting with an object, preferably the selected object. In the user form, the user inputs info like CenterRotationX, CenterRotationY, Total Number of degrees to rotate through, and number of object copies. I then want the code to do a few calculations. I want it to take the Total Rotation Degrees and rotate a copy of the object by an amount based on a random number from the main degrees. Then subtract the first amount from the total rotation and rotate another copy based on the new rotation info. Procede with this until the number of copies has been reached. Code:
Private Sub OKButton_Click() Dim nor As Integer 'Number Of Rotations Dim ar As Integer 'Angle of Rotation Dim ang As Integer 'Recalculated Rotation Angle ar = txbRot.Text For i = 1 To nor s.RotationCenterX = CenX.Text s.RotationCenterY = CenY.Text ang = (Rnd() * ar) s.Rotate ang ar = ar - ang s.Duplicate Next i End Sub
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#2
|
||||
|
||||
![]()
This is a question. I keep getting errors when I run this. Can I get some help?
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#4
|
||||
|
||||
![]()
Oops. I forgot to report the nor value. I am actually doing this code on my PC at home and trying to remember what the code was on my PC at work. My biggest problem is getting the variable s defined and set.
Code:
Private Sub OKButton_Click() Dim nor As Integer 'Number Of Rotations Dim ar As Integer 'Angle of Rotation Dim ang As Integer 'Recalculated Rotation Angle Dim s As Shape Dim i As Integer ar = txbRot.Text nor = txbNumRot Set s = ActiveSelection.Shapes For i = 1 To nor s.RotationCenterX = CenX.Text s.RotationCenterY = CenY.Text ang = (Rnd() * ar) s.Rotate ang ar = ar - ang s.Duplicate Next i End Sub Code:
s11 = s12.Duplicate
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#5
|
||||
|
||||
![]() Quote:
But you can do it like this: Code:
Set s = ActiveSelection |
#6
|
||||
|
||||
![]()
This is what I came up with...
Code:
Private Sub OKButton_Click() Dim nor As Integer 'Number Of Rotations Dim ar As Integer 'Angle of Rotation Dim ang As Integer 'Recalculated Rotation Angle Dim s As Shape Dim i As Integer ar = txbRot.Text nor = txbNumRot Set s = ActiveShape For i = 1 To nor s.RotationCenterX = CenX.Text s.RotationCenterY = CenY.Text ang = (Rnd() * ar) s.Rotate ang ar = ar - ang s.Duplicate Next i Unload Me End Sub What this code does so far is work within a given area and puts copies on copies and doesn't use the whole 360.
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#7
|
||||
|
||||
![]()
That is because you used ActiveShape instead of ActiveSelection as I suggested originally. ActiveSelection is a special shape which represents the current selection. When you call Duplicate, the duplicated object will become a new selection, so that on the next loop you will be duplicating it, and so on.
However if you use ActiveShape instead, you will link to a particular shape and will be duplicating it over and over again. You no longer work with whatever is selected. You can fix it either by using ActiveSelection instead of ActiveShape, or by reassigning the reference to the shape when you duplicate the object: Code:
Set s = s.Duplicate However I can see that this approach of yours might not be what you really want to do. The spacing between spokes will almost always be greater in the beginning and then they will become closer to each other. Like the first duplicate might be placed at 180°, then the remaining 9 will have to split up the rest of the circle. The second copy can use up another 90°, so it'll be at 270°, and you are left with 90° for the remaining 8 copies and so on. Maybe what you need to do is divide 360° among all the copies. If you need to make 10 copies, then you'll place them each at 36°, then you will add some random number to each angle to slightly shift each object position both ways to add some randomness to the design... But I don't know what you are trying to do, so I can't tell if that's what you need... |
#8
|
||||
|
||||
![]()
This is what I've ended up with...
Code:
Private Sub OKButton_Click() Dim nor As Integer 'Number Of Rotations Dim ar As Integer 'Angle of Rotation Dim ang As Integer 'Recalculated Rotation Angle Dim s As Shape Dim i As Integer ar = txbRot.Text nor = txbNumRot.Text Set s = ActiveSelection For i = 1 To nor Set s = s.Duplicate s.RotationCenterX = CenX.Text s.RotationCenterY = CenY.Text ang = (ar / nor) + (Rnd() * 10) s.Rotate ang Next i Unload Me End Sub
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Rotate around a centre | Anonymous | Code Critique | 3 | 14-01-2005 17:07 |
Where does COrelPhotopaint 12 keeps its Globalmacros file? | cyrilgupta | Corel Photo-Paint VBA | 1 | 08-11-2004 15:02 |
Layer rotate without anti aliasing (PP11) | joexx | Corel Photo-Paint VBA | 2 | 19-03-2004 01:08 |
Special Characters | Craig Tucker | CorelDRAW/Corel DESIGNER VBA | 3 | 12-03-2003 11:57 |