connecting users of the CorelDRAW family of products

node coordinates

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 10 Replies | 1 Follower

Share  
Page 1 of 1 (11 items) | RSS

Not Ranked
Ottawa, Canada
Male
Eduard Alf posted on Mon, Jul 2 2012 9:50

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

 

All Replies

Top 10 Contributor
Virginia USA
Male

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

TheSignGuy

Computer i5 Intel 2500K 4.0 mh, 16 gig Ram, SSD Main Drive, 1T WD Black, 1T Segate, 2 gig DDR 5 G Force Video card, Windows 7 Utl. 64 bit, ASRock 4 Extreme Mobo


Top 10 Contributor
Calgary, Alberta, Canada
Male
TAG - MacroMonster.com

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.

Top 10 Contributor
London UK

Don't know if this will help you, but you can do it indirectly:

  • Create an open office spreadsheet and enter the x and y value pairs in columns A and B.
  • Highlight all values of both columns and do Insert > chart (still in the spreadsheet).
  • Ignore the bar chart that first appears. Select the chart type as XY Scatter with Points and Lines
  • Select Smooth Lines
  • Finish the chart wizard, select the chart and copy it to clipboard

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.

 

Top 10 Contributor
Virginia USA
Male

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.Idea

George

TheSignGuy

Computer i5 Intel 2500K 4.0 mh, 16 gig Ram, SSD Main Drive, 1T WD Black, 1T Segate, 2 gig DDR 5 G Force Video card, Windows 7 Utl. 64 bit, ASRock 4 Extreme Mobo


Top 10 Contributor
Calgary, Alberta, Canada
Male
TAG - MacroMonster.com

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.Idea

Function plotting - I don't use that myself. BUT CADTool 4 is another CAD-related macro that has nice features I use.

Top 10 Contributor
Sweden
Male

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

Top 10 Contributor
London UK

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.

Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

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

 

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Top 10 Contributor
Sweden
Male

harryLondon:
But as a method of creating a graph it is fairly clumsy
You're right, the docker is a bit crude when it comes to creating objects from scratch.
So before you go for the upgrade, Eduard, download the trial and see if it works for you.

/Ronny

“The ability to think differently today from yesterday distinguishes the wise man from the stubborn”
John Steinbeck

Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

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

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Page 1 of 1 (11 items) | RSS
© Corel Corporation. The content herein is in the form of a personal web log ("Blog") or forum posting. As such, the views expressed in this site are those of the participants and do not necessarily reflect the views of Corel Corporation, or its affiliates and their respective officers, directors, employees and agents. Terms and Conditions / User Guidelines.