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 18-01-2006, 09:13
LGD
Guest
 
Posts: n/a
Question Problem with VBA in Draw X3

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
It seems the SetRadius property does not work at all. Everything else in the script works fine, just the radius never gets changed. The help file doesn't say much, so the only thing I can assume is that the SetRadius command is broken in X3. I have a much more complex script that seems to work fine, so it doesn't look like much has been changed in the Draw VBA language.

Thanks for any help.

LD
Reply With Quote
  #2  
Old 18-01-2006, 13:50
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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
Also what's up with these two statements?

Code:
s.Application.CorelScript.AlignToCenterOfPage 3, 3
s.Shapes.Application.ActiveSelection.GetBoundingBox x, y, width, height
Looks like a very weird way to do the stuff. First, you don't need to go to CorelScript to align objects to the center of the page. And second, if you want to get a bounding box of a shape, just go ahead and do it, rather than going through ActiveSelection (did I say that getting to the Application object through s.Shapes is one innovative way of doing it , all application's methods and properties are global, so you can do just ActiveSelection.GetBoundingBox with exactly the same result).

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.
Reply With Quote
  #3  
Old 18-01-2006, 14:41
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by LGD
I have a much more complex script that seems to work fine, so it doesn't look like much has been changed in the Draw VBA language.
Well, actually there are a lot of new stuff in VBA in CGS X3. Check out this thread: http://forum.oberonplace.com/showthread.php?t=1287
Reply With Quote
  #4  
Old 19-01-2006, 09:03
LGD
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #5  
Old 19-01-2006, 09:39
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

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.
Reply With Quote
  #6  
Old 19-01-2006, 10:03
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Also you can post your code in Code Critique forum where everyone can take a snap at it and recommend improvements...
Reply With Quote
  #7  
Old 19-01-2006, 10:07
LGD
Guest
 
Posts: n/a
Default

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
Unless I did it wrong? I just replaced the s.Rectangle.SetRadius (rradius) with the above. It was from the example in the help file.

Thanks for the help, the new command works fine:

Code:
Set s = ActiveLayer.CreateRectangle2(0, 0, width, height, rradius, rradius, rradius, rradius)
LD
Reply With Quote
  #8  
Old 19-01-2006, 10:12
LGD
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by ddonnahoe
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.
I don't know if you want to take that one on, LOL! It's really bad, GOTOs all over the place, garbage code everywhere, who knows what's in there, I sure don't. Whenever I'm forced by changes in Draw to fix something in it, I have to spend an hour figuring out what the hell I was thinking at the time. There are a couple of things I would like to change/add to it, but the thought of wading through that mess again leaves me with little ambition for it.

If you really want to take it on, I can post the GMS file.

LD
Reply With Quote
  #9  
Old 19-01-2006, 10:14
LGD
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Alex
Also you can post your code in Code Critique forum where everyone can take a snap at it and recommend improvements...
OK, you asked for it, don't tell me I didn't warn you..................

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


All times are GMT -5. The time now is 08:05.


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