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 05-03-2004, 09:06
dimmech
Guest
 
Posts: n/a
Default box and corner radius issues

Being somewhat new to draw, I know very little about it and less about vba. However, here it is.

I am creating a macro for coreldraw 11 that creates a shape for a laser cutting process. The macro prompts the user to enter dimensions for hieght and width. It creates a box in corel and sets the corner radius to 10 then scales the box to the dimensions required. The problem becomes once you scale the box the corner radius gets skewed. Is this known to be an issue in cd?

The only solutions I could see are to either be able to enter dimensions into corel and have it place your object on the canvas correctly porportioned (can it do that?), or create it with a script. If a script is required I can use the macro software to replace the "dimension" text before corel runs it. Is there a create box script out there? I would not know where to begin trying to write one.

Any other suggestions are welcome.
Reply With Quote
  #2  
Old 05-03-2004, 11:45
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: box and corner radius issues

Why don't you just create the rectangle with the right dimensions from the start? I don't know your exact requirements, but I believe it should be possible to calculate the final rectangle size right in the macro and create it with perfect round corners in a single step...
Reply With Quote
  #3  
Old 05-03-2004, 15:03
dimmech
Guest
 
Posts: n/a
Default

I am not aware of a way to do that. The only way I see to make a box is to click and drag. The dimensions for the basic shape will be different every time but it will have consistent rules that determine it's overall apearance(holes, position, ect...).

The macro software I'm doing this in (macro express), creates the box in draw, prompts me for hieght and width values then inserts the numeric values for me into the Object size boxes in the property tool bar.

If I could copy those vaues into input boxes in draw and tell it to create the box to those dimentions it would be great.
Reply With Quote
  #4  
Old 05-03-2004, 15:54
dimmech
Guest
 
Posts: n/a
Default

Just found Oberon Instant Object Creator and it is what I need but I get 611 runtime error(could not create specified OLE automation object). Is there a cd11 version out there? Or a fix?
Reply With Quote
  #5  
Old 05-03-2004, 21:52
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Object Creator

The script gives you the error because it was designed to be used with an earlier version of CorelDRAW. It can be easily updated by opening the CSC file in Notepad and looking for "CorelDRAW.Automation.7" (or whatever version of the script you have) and replace the 7 with 11.

Or better yet, use VBA for this. You can do it much easier with it. Here I created a really small simple version which should run in CorelDRAW 10-12. Just drop the attached GMS file in Program Files\\Corel\Corel Graphics 11\Draw\GMS, then go to Tools>Visual Basic>Play in CorelDRAW to run the macro (for more information about using GMS files, click here).

The actual code that creates the objects is quite simple:

Code:
Private Sub cmCreate_Click()
    Dim x As Double, y As Double
    Dim sx As Double, sy As Double
    
    sx = Val(txtWidth.Text)
    sy = Val(txtHeight.Text)
    If sx <= 0 Or sy <= 0 Then
        MsgBox "Invalid object size", vbCritical
        Exit Sub
    End If
    
    
    If rRectangle.Value Then
        x = ActivePage.CenterX - sx / 2
        y = ActivePage.CenterY - sy / 2
        ActiveLayer.CreateRectangle2 x, y, sx, sy
    Else
        x = ActivePage.CenterX
        y = ActivePage.CenterY
        ActiveLayer.CreateEllipse2 x, y, sx / 2, sy / 2
    End If
End Sub
I hope this helps.
Attached Images
 
Attached Files
File Type: gms ObjCreator.gms (20.0 KB, 416 views)
Reply With Quote
  #6  
Old 06-03-2004, 19:40
dimmech
Guest
 
Posts: n/a
Default

This appears to be exactly what I needed. I will try it out at work on Monday and post again if I have any problems.

Many Thanks,
Reply With Quote
  #7  
Old 12-09-2012, 03:34
cabir cabir is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Default round corner

Hi Alex
I just downloaded round corner macro but I am not able to make it work
I am using Corel X6 is it a version problem or what
My real need is to put a radius, measure or anything at an acute angle on the shape looking outside of the object

My problem is, with the acute angles looking outside the object.
As in the cdr shape you can see there -40 , 41, 117 and -118 degree angles. Why does it say -40 and not 320 degrees and -118 not 242 degrees. And which angle looks outside the object?
these angles are inside the object

These angles are outside the object .
How can I say they are outside the object with a macro? I couldn’t understand exactly but there is a solution in round corners because the radius is always in the right direction and place
Best regards
Cabir Bilirgen
Attached Files
File Type: cdr anglework.cdr (41.1 KB, 188 views)
Reply With Quote
  #8  
Old 12-09-2012, 09:46
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Angle

The following code will show the angles with positive values instead of negative as you wanted:
Code:
Sub WhatIsMyAngle()
    Dim n As Node
    Dim sShape As Shape
    Dim segBefore As Segment
    Dim segAfter As Segment
    Dim da As Double
    
    Set sShape = ActiveShape
    
    If sShape Is Nothing Then
        MsgBox "Nothing selected", vbCritical
        Exit Sub
    End If
    
    If sShape.Type <> cdrCurveShape Then
        MsgBox "A curve object must be selected", vbCritical
        Exit Sub
    End If
    
    For Each n In sShape.Curve.Nodes
        Set segBefore = n.PrevSegment
        Set segAfter = n.NextSegment
        
        If Not segBefore Is Nothing And Not segAfter Is Nothing Then
            da = segBefore.EndingControlPointAngle - segAfter.StartingControlPointAngle
            If da < 0 Then da = 360 + da
            ActiveLayer.CreateArtisticText n.PositionX, n.PositionY, Round(da, 0) & " degrees", , , "Ariel", 8, , , , cdrCenterAlignment
        End If
    Next n
End Sub
Best of luck,

-Shelby
Reply With Quote
  #9  
Old 17-09-2012, 08:59
cabir cabir is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Default angle work

Hi Shelby
This not what I asked. I am just trying to find the face of the angle.
May be I can find it on the way you showed me by adding or subtracting the angle with 180 or 360. I hoped that you should show me how to calculate with tangent or sinus just as in "round corners script". Anyway I am really happy to know you. You spent your very valuable time to me. Thank you very much and greetings to your family. You have a friend in Turkey.

Best for you
Cabir Bilirgen
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


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


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