node coordinates

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

 

Parents Reply Children
  • Hi.

    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://community.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 Explicit
    Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
    Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
    Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long

    Declare Function CloseClipboard Lib "user32" () As Long
    Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
    Declare Function EmptyClipboard Lib "user32" () As Long
    Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long

    Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long

    Private Const GHND = &H42
    Private Const CF_TEXT = 1

    Sub clipboard_1()
      Call string_to_clipboard("Just check it, if it worked....")
    End Sub


    Private 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 If

    End Sub

    Sub nodeCoord() ''run this the get nodes coords

    Dim s As Shape
    Dim n As Node
    Dim x As String, y As String
    Dim xy As String
    'Dim rVal As Long

    'ActiveDocument.Unit = cdrMillimeter

    If ActiveSelection.Shapes.count = 0 Then
        MsgBox "Please select a single curve shape"
        Exit Sub
    End If

    Set s = ActiveShape

    For 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 Sub

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

    Private Function getCBData() As String
        Dim MyData As DataObject
        Dim strClip$

        Set MyData = New DataObject
        MyData.GetFromClipboard
        getCBData = MyData.GetText
    End 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.

    ~John