![]() |
|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
![]()
Hi.
I have a simple function that rotates a line for example. Draw a line and angle it at whatever angle, say a 3 inch 45 degree line. The function will return the angle for rotation that rotates the line until it's at it's thinnest horizontal width. I use a virtual shape to greatly improve speed. But... When I create a virtual shape the angle for the prec (precision value) that I enter cannot seem to be less than .5 For a regular shape, not a virtual shape, I can use any value ie .01 Here's the function. Just pass the shape to it. Code:
Private Function rotateIt2(s As Shape) As Double 'Dim s As Shape Dim dup As Shape Dim thinnestw As Double Dim angle As Double Dim rotToThinW As Double, prec As Double prec = 0.25 'Set dup = s.TreeNode.GetCopy().VirtualShape 'use a virtual shape instead. Set dup = s.Duplicate thinnestw = 10000 angle = 0 For angle = 0 To 20 Step prec dup.Rotate prec If dup.SizeWidth < thinnestw Then thinnestw = dup.SizeWidth rotToThinW = angle ElseIf dup.SizeWidth > thinnestw And angle <> 0 Then GoTo exitMe: End If Next angle exitMe: dup.Delete rotateIt2 = rotToThinW + prec End Function -John |
#2
|
||||
|
||||
![]()
Hi.
Ok. Here's a solid testing code and result file. The code simply creates a rectangle then rotates it either as shape or a virtual shape duplicate of it. It takes a height measurement of the shape at each rotation angle in the loop. I'm getting unexpected results. I also attached a results file with my results to the test. Code:
Sub testVirtualShapeRotation() Dim s As Shape, sDup As Shape Dim dAngle As Double, dStep As Double, dH As Double Dim lSpace As Long Dim bUseVirtual As Boolean '''''''''''''''''''' '''''''''''''''''''' bUseVirtual = True '''''''''''''''''''' '''''''''''''''''''' lSpace = 1 dStep = 0.01 Set s = ActiveLayer.CreateRectangle2(0, 0, 6, 2) Set sDup = s.TreeNode.GetCopy().VirtualShape For dAngle = dStep To 360 Step dStep 'loop to rotate a rectangle and take height measurement If Not bUseVirtual Then s.Rotate dAngle 'rotate it! dH = s.SizeHeight 'height measurement taken Else 'use our virtual shape instead sDup.Rotate dAngle 'rotate it! dH = sDup.SizeHeight 'height measurement taken End If ActiveLayer.CreateArtisticText 0, lSpace, dH lSpace = lSpace + 1 Next dAngle End Sub -John |
![]() |
Tags |
virtual shape rotation |
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 |
Replace shape with another shape | dungbtl | CorelDRAW/Corel DESIGNER VBA | 24 | 28-12-2019 05:56 |
Changing selection when two-shape group loses one shape | Joe | CorelDRAW/Corel DESIGNER VBA | 1 | 19-02-2009 03:50 |
a shape on top of another | Seelenquell | CorelDRAW/Corel DESIGNER VBA | 15 | 01-03-2008 09:08 |
Get Shape Index ID Value | m31uk3 | CorelDRAW/Corel DESIGNER VBA | 6 | 08-02-2008 19:50 |
Numbers as shape name | clausm | General | 2 | 22-03-2007 13:02 |