I have the list of x,y coordinates for the CIE colour spectrum. How do I import the list so as to draw the spectrum curve?? The curve is the horseshoe shaped curve shown in the figure below [not the straight lines which are colours boundaries] that contains all the spectrum colours. Seems to me I should be able to import the list somehow and CorelDraw would then produce the line.
eduardatwork
Hello Eduard; You can import a file of the drawing you posted, but CorelDraw isn't a CAD program where you would type in the X, Y of the line ends you want drawn. You might try down loading "CorelCad" and give that a try that.
George
Eduard Alf:How do I import the list so as to draw the spectrum curve??
This macro might be the only solution... it comes with trial period, so you can try it.
Jeff Harrison MacroMonster.com • Daily Diversion Blog
Don't know if this will help you, but you can do it indirectly:
The big surprise -- it pastes into CorelDraw as a group of vector objects. So you can scale it up and down as needed.
But I've only tried it on simple curves. It might not copy with the complexity you have. And sadly, the "curve" is actually made of a lot of crude polygons, not from a proper bezier. So, the finished quality of the curve is nowhere near as good as it could be.
Probably better would be to choose points only so you get the positions without the lines. Then join the points with your own bezier curve.
Hello Jeff; That's the first I've seen of that type of macro, it would save hundreds of dollars over buying a CAD program.
TheSign Guy:Hello Jeff; That's the first I've seen of that type of macro, it would save hundreds of dollars over buying a CAD program.
Function plotting - I don't use that myself. BUT CADTool 4 is another CAD-related macro that has nice features I use.
CorelDraw X5 and X6 both have a built in Object Coordinates docker, where it is possible to build an object based on coordinates.
/Ronny
“The ability to think differently today from yesterday distinguishes the wise man from the stubborn” John Steinbeck
I had a look at that docker, which is no doubt good for other purposes. But as a method of creating a graph it is fairly clumsy to have to insert a lot of individual points one at a time by repeated button presses. It would be much easier to just type the values into an empty rows and columns grid. And at the end of it, it will draw only straight lines not curves (unless I've missed an option somewhere).
Oberon's macro looks more interesting. I had looked at that page several years ago, but discounted it because it described itself as a function plotter. The "new" ability to plot simple X, Y pairs seems to have been an afterthought and maybe it wasn't there when I looked at it.
Ronny Axelsson: CorelDraw X5 and X6 both have a built in Object Coordinates docker, where it is possible to build an object based on coordinates.
Hi.
Sure would be an absolutely awesome add to the docker huh Ronnie? Ability to take a csl and make a line!
~John
"The best thing about learning is that it never stops, and the rabbit hole will go as deep as you let it."~Johnwww.gdgmacros.com
harryLondon:But as a method of creating a graph it is fairly clumsy
This post just brought back a memory. I knew it sounded a little familiar. Here's an old post where I wrote a macro that would take an object and convert the nodes within it to coordinates. Pretty much the opposite of what you need.
http://coreldraw.com/forums/p/18899/81699.aspx#81699
Here's a slightly revised version of the macro with an added sub that will create your line segments:
Option ExplicitDeclare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As LongDeclare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As LongDeclare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As LongDeclare Function CloseClipboard Lib "user32" () As LongDeclare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As LongDeclare Function EmptyClipboard Lib "user32" () As LongDeclare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As LongDeclare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As LongPrivate Const GHND = &H42Private Const CF_TEXT = 1Sub clipboard_1() Call string_to_clipboard("Just check it, if it worked....")End SubPrivate Sub string_to_clipboard(str As String) Dim hGlobalMemory As Long hGlobalMemory = GlobalAlloc(GHND, Len(str) + 1) Dim lpGlobalMemory As Long lpGlobalMemory = GlobalLock(hGlobalMemory) lpGlobalMemory = lstrcpy(lpGlobalMemory, str) If GlobalUnlock(hGlobalMemory) <> 0 Then MsgBox "Couldn't GlobalUnlock" End If If OpenClipboard(0&) = 0 Then MsgBox "Couldn't open Clipboard" Exit Sub End If Dim dummy As Long dummy = EmptyClipboard() Dim hClipMemory As Long hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory) If CloseClipboard() = 0 Then MsgBox "Clipboard could not be closed" End IfEnd SubSub nodeCoord() ''run this the get nodes coordsDim s As ShapeDim n As NodeDim x As String, y As StringDim xy As String'Dim rVal As Long'ActiveDocument.Unit = cdrMillimeterIf ActiveSelection.Shapes.count = 0 Then MsgBox "Please select a single curve shape" Exit SubEnd IfSet s = ActiveShapeFor Each n In s.Curve.Nodes x = Round(n.PositionX, 3) & " " y = Round(n.PositionY, 3) & ", " xy = xy + x & y 'rVal = MsgBox(xy, vbOKCancel) 'If rVal = 2 Then Exit Sub Next n string_to_clipboard (xy) MsgBox "The string csv is now in your clipboard. You can paste into any document."End SubSub nodeCoordGMake() 'run this to make segments Dim strCoords$ 'ActiveDocument.Unit = cdrMillimeter Dim x1#, y1#, x2#, y2#, i&, sline As Shape Dim sr2 As New ShapeRange strCoords = getCBData Dim ar1$(), ar2$() ar1 = VBA.Split(strCoords, ", ") For i = 0 To UBound(ar1) - 1 If i > 0 Then ar2 = VBA.Split(ar1(i)) x2 = Val(CDbl(ar2(0))) y2 = Val(CDbl(ar2(1))) ar2 = VBA.Split(ar1(i - 1)) x1 = Val(CDbl(ar2(0))) y1 = Val(CDbl(ar2(1))) Set sline = ActiveLayer.CreateLineSegment(x1, y1, x2, y2) If Not sline Is Nothing Then sr2.Add sline End If Next i ar1 = VBA.Split(strCoords, ", ") End SubPrivate Function getCBData() As String Dim MyData As DataObject Dim strClip$ Set MyData = New DataObject MyData.GetFromClipboard getCBData = MyData.GetTextEnd Function
Basically in the original macro I changed the getCoords function so it gets a string that is formatted like this:
-3.036 5.751, -3.211 6.155, -3.44 6.734, -3.457 6.788, -3.473 6.842, -3.616 7.958, -3.126 7.906, -2.135 7.03, -1.259 6.171, -1.208 6.128, -1.158 6.085, 0.1 5.844, 0.457 7.279, 0.571 8.262, 0.239 8.978, 0.196 8.987, 0.153 8.997, 0.131 9.001, 0.117 9.013,
Each set of coords is separated by a space and each pair with a comma.
The first function can be used as a test. Select a curve and run. It copies the string of coordinates to the clipboard automatically. You can paste them somewhere to take a look if ya want.
While leaving a string of coordinates in the clipboard run the second function. You can also copy your coords from your own source if you wish. The 2nd macro will create the line segments. Use your Join Curves docker to join the segments. An alternative which can join segments live is my Node Manipulator macro.
Note! If the shape has little nodes you will want to add nodes to it in order for curve regeneration to be more accurate. One easy way to do it is with my Node Manipulator macro. but you can add node manually.
After the segments are joined select your new shape with the shape tool and select all nodes. On the property bar for the shape tool change to curved lines, and change node type to either Symetrical, or Smooth.
Walla! See movie below for a quick demo.