OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Thread Tools Search this Thread Display Modes
Old 16-01-2011, 11:37
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default Cannot rotate a virtual shape with the same precision as a shape

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.
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.

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
    rotateIt2 = rotToThinW + prec
End Function
Any ideas?
Reply With Quote
Old 19-01-2011, 14:34
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default virtual shape bug

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.

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
Attached Files
File Type: cdr virtual_test.cdr (40.8 KB, 365 views)
Reply With Quote

virtual shape rotation

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
Replace shape with another shape dungbtl CorelDRAW/Corel DESIGNER VBA 24 28-12-2019 04:56
Changing selection when two-shape group loses one shape Joe CorelDRAW/Corel DESIGNER VBA 1 19-02-2009 02:50
a shape on top of another Seelenquell CorelDRAW/Corel DESIGNER VBA 15 01-03-2008 08:08
Get Shape Index ID Value m31uk3 CorelDRAW/Corel DESIGNER VBA 6 08-02-2008 18:50
Numbers as shape name clausm General 2 22-03-2007 12:02

All times are GMT -5. The time now is 21:29.

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