![]() |
#1
|
|||
|
|||
![]()
I know I may be jumping the gun a little, but the X3 trial was just released and I immediately found a problem with a VBA macro I have. It's very simple, it has a dialog that asks for width and height and will draw an ellipse or rectangle from that info. It also asks for a radius for the rectangle and that's where I've run into a problem. I already posted about this on the Draw X3 user forums, but was told I might get a faster response here.
This is the section of code that draws the rectangle: Code:
Private Sub DrawRectangle() If txtHeight.Text = "" Then GoTo Zero If txtWidth.Text = "" Then GoTo Zero Dim s As Shape, width As Double, height As Double, rradius As Double, x As Double, y As Double height = CDbl(txtHeight.Text) width = CDbl(txtWidth.Text) rradius = CDbl(txtRadius.Text) If rradius > (width / 2) Or rradius > (height / 2) Then GoTo RadWarn Set s = ActiveLayer.CreateRectangle(0, 0, width, height) s.Rectangle.SetRadius (rradius) s.Outline.SetProperties 0.003 s.Outline.Color.FixedAssign cdrPANTONECorel8, 566 s.OverprintOutline = True s.Application.CorelScript.AlignToCenterOfPage 3, 3 ActiveDocument.DrawingOriginX = 0 ActiveDocument.DrawingOriginY = 0 s.Shapes.Application.ActiveSelection.GetBoundingBox x, y, width, height ActiveDocument.DrawingOriginX = x ActiveDocument.DrawingOriginY = y + height If chkCreateBleed = True Then CreateBleed GoTo Unload Thanks for any help. LD |
#2
|
||||
|
||||
![]()
Yes, you are right. Rectangle.SetRadius seems to be broken. I'll log a bug on that.
However you can still create rectangles with rounded corners right with Layer.CreateRectangle (or Layer.CreateRectangle2) function. Compare these: Code:
' This doesn't work... Sub TestRoundRect() Dim s As Shape Set s = ActiveLayer.CreateRectangle2(0, 0, 4, 4) s.Rectangle.SetRadius 1 End Sub ' But this does... Sub TestRoundRect2() Dim s As Shape Set s = ActiveLayer.CreateRectangle2(0, 0, 4, 4, 1, 1, 1, 1) End Sub Code:
s.Application.CorelScript.AlignToCenterOfPage 3, 3 s.Shapes.Application.ActiveSelection.GetBoundingBox x, y, width, height ![]() Anyway, here is how you need to rewrite those two lines: Code:
s.AlignToPageCenter cdrAlignHCenter + cdrAlignVCenter s.GetBoundingBox x, y, width, height Last edited by Alex; 18-01-2006 at 13:56. |
#3
|
||||
|
||||
![]() Quote:
|
#4
|
|||
|
|||
![]()
Ah, thanks for the info, I'll check and see if that works.
As for the corel script and align to page functions...... this script started with the first version of corel script (not VBA) back in version 6 I think. So, there's a lot of carry-over "junk" and who knows what else from all previous versions. I'm sure there are a lot of things that could be corrected, simplified, etc, but in it's current form "it works" so unless something breaks, like the radius setting, I can't justify the time to fix it. I learned VBA by trial and error, mostly, and once I found a way to get it to do what I wanted, I left it at that and moved on. My more complex script is a mess, I'll be the first to admit, even this simple one is bad enough, as it sort of grew from an example script I found in a magazine, I think. Thanks again. LD |
#5
|
||||
|
||||
![]()
LGD, if you would like, you can IM me and send me the "more complex" code and I can take a look at it to "smooth" things out for you. I can't say that it will be fast, but I may have more time than you seem to have to "tidy things up".
I'd be happy to help you with this.
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#6
|
||||
|
||||
![]()
Also you can post your code in Code Critique forum where everyone can take a snap at it and recommend improvements...
|
#7
|
|||
|
|||
![]()
Also tried this as well, doesn't seem to work:
Code:
With ActiveShape.Rectangle .RadiusLowerLeft = 0.1 .RadiusLowerRight = 0.2 .RadiusUpperLeft = 0.3 .RadiusUpperRight = 0.4 End With Thanks for the help, the new command works fine: Code:
Set s = ActiveLayer.CreateRectangle2(0, 0, width, height, rradius, rradius, rradius, rradius) |
#8
|
|||
|
|||
![]() Quote:
If you really want to take it on, I can post the GMS file. LD |
#9
|
|||
|
|||
![]() Quote:
LD |
![]() |
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 |
Draw 12 : Printing Problem | Hernán | General | 3 | 20-09-2004 11:54 |
Problem with opened dialog box Corel Draw 11 | dergy | CorelDRAW/Corel DESIGNER VBA | 1 | 14-06-2004 11:04 |
Draw 12 VBA: Preliminary changes | Alex | CorelDRAW/Corel DESIGNER VBA | 2 | 18-10-2003 07:16 |
VBA Editor Problem | j_lyver | CorelDRAW/Corel DESIGNER VBA | 2 | 31-03-2003 06:30 |