![]() |
#1
|
|||
|
|||
![]()
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. |
#2
|
|||
|
|||
![]()
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 |
#3
|
||||
|
||||
![]()
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 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 |
#4
|
|||
|
|||
![]()
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 |
#5
|
|||
|
|||
![]()
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 |
![]() |
Tags |
appendline segment, smooth curves |
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 |
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 |