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 08-08-2014, 20:34
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Drawing smooth curves

Hi
Trying to draw hundreds of smooth curves from an Excel spreadsheet and struggling to find a way that doesnt require manual intervention.

I currently have a macro that reads in the node points (Excel only has the x,y coordinates) and draws overlapping curves - the first two/last three nodes overlap the previous/next curve. Each part of each curve is created with AppendLineSegment then the curve is created with CreateCurve. I can then manually select each curve/select All Nodes/To Curves/Smooth and use a macro to delete the first and last node, ending up with non-overlapping curves that look like a continuous smooth line.

I had tried to use AppendCurveSegment but whilst this created curved nodes with handles the lines were not smooth - I think because of the lack of control handle information and I would need to manually change the nodes back To Lines before converting them back To Curves.

The method wasnt good but I could get away with it with a few curves but now I want to draw hundreds of small curves of about 20 nodes each and Im wondering if someone could give advice about how to go about it.


Best wishes
nic

Last edited by nic; 08-08-2014 at 20:37.
Reply With Quote
  #2  
Old 09-08-2014, 16:04
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Excel test file and code that fails

This is code that the code as it was when I gave up trying and attached small excel sheet that will work with it.

If theres a good place to look for Node info could somebody point me in the right direction.


Code:
Dim sShape As Shape
Dim crv As Curve
Dim sp As SubPath
Dim ro1st As Double
Dim roFin As Double
Dim x As Double, y As Double, r As Double, n As Double
Dim nd As Node

Set XL = GetObject(, "Excel.Application")

x = XL.Cells(1, 1).Value
y = XL.Cells(1, 2).Value

Set crv = CreateCurve(ActiveDocument)
Set sp = crv.CreateSubPath(x, y)

For n = 2 To 22
    x = XL.Cells(n, 1).Value
    y = XL.Cells(n, 2).Value
    sp.AppendCurveSegment x, y
Next n

sp.Closed = False

Set sShape = ActiveLayer.CreateCurve(crv)

' above draw a shape but below fails
For Each nd In sShape
    nd.Type = cdrSmoothNode
Next nd

End Sub
Attached Files
File Type: zip excel file.zip (4.0 KB, 391 views)
Reply With Quote
  #3  
Old 11-08-2014, 13:18
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,791
Blog Entries: 15
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 Curve

Nic,

Change your below fails code to:
Code:
    ' above draw a shape but below fails
    For Each nd In sShape.Curve.Nodes
        nd.Type = cdrSmoothNode
    Next nd
See if that gives you the result you would like.

There are other ways of doing this also, you could draw an arc between three points, it would give you a smoother look with fewer nodes, if that is what you are looking for.

-Shelby
Reply With Quote
  #4  
Old 11-08-2014, 16:22
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Perfect

Thanks Shelby, that worked perfectly.

I shall look into the 3 point curves method and report back but Im thinking it wont do here and actually it has made me think I should overlap by another node .

Many thanks, really appreciate all the help you have given.
nic
Reply With Quote
  #5  
Old 24-09-2014, 00:03
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default 3 point curve

Hi Shelby
Had a look at drawing using the 3 point curve method and fell at the first hurdle because it seemed to require the bezier curve handle positions as part of its function and calculating those is beyond me. Im trying to draw mathematical curves a bit like spirographs from their x,y coordinates and the method that produced the smoothest if not the most accurate curves was to plot the whole curve (of up to 100000 nodes) in chunks of 2004 smooth nodes per shape and then deleting every other node and then the first and last nodes leaving a curve with 1000 nodes. By overlapping the next curve so its original 2004 node curve started at the penultimate node of the previous curve and deleting as before the 2nd curve started at the point the first curve finished and the curve between the two shapes flowed smoothly.
Best wishes
nic
Reply With Quote
Reply

Tags
appendline segment, smooth curves


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
Setting Drawing Origin in VBA nic CorelDRAW/Corel DESIGNER VBA 2 30-10-2013 08:04
connect curves: arc curves TobWen CurveWorks 4 30-05-2008 12:47
Drawing a 'T', a simple Q madhur General 3 18-09-2007 06:37
A Simple Question - drawing curves madhur General 4 01-08-2006 21:37
Drawing a cross hair ashwinw Corel Photo-Paint VBA 1 29-05-2004 17:44


All times are GMT -5. The time now is 07:46.


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