connecting users of the CorelDRAW family of products

Exporting Nodes Cordinates

rated by 0 users
This post has 4 Replies | 1 Follower

Share  
Page 1 of 1 (5 items) | RSS

Not Ranked
Australia
Male
Ken Posted: Tue, Mar 16 2010 2:05

Im currently using Corel as a small scale design tool and would like to export the x and y node co-ordinates from a curve or any object for that matter into a .csv or ascii text file.

Does anyone have know how to do this?

many thanks

Top 10 Contributor
Calgary, Alberta, Canada
Male
TAG - MacroMonster.com
This commercial macro from a Corel employee is the closest I know of.
 
<KenJ> wrote in message news:81663@coreldraw.com...

Does anyone have know how to do this?

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

Hi.

Ok. Try this. I made it so it copies the entire coords of the selected shape to your clipboard in a csv list style. I didn't have more time to put it to a good test. Let me know if it works for you.

 

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()

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

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 = n.PositionX & ", "
    y = n.PositionY & ", "
    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

 

-John

"The best thing about learning is that it never stops, and the rabbit hole will go as deep as you let it."
~John
www.gdgmacros.com

Not Ranked
Australia
Male
Ken replied on Tue, Mar 16 2010 18:21

thanks John

This works but there appears to be a scale factor involved?

A 2 noded horizontal line 100mm long (which should give 0,0,100,0) will give and output of ; 

0, 0, 3.93700393700787, 3.93700787401575 ?

How can I correct for that in the code?

rgds

 

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

Hi.

Oh. ok.

Your using mm.

You can add(the second line is the line added):

 

'Dim rVal As Long <<add right after this comment.

ActiveDocument.Unit = cdrMillimeter

 

You might also want to switch this line:

x = n.PositionX & ", "
y = n.PositionY & ", "

with this, so you round at 3 dec places:

x = Round(n.PositionX, 3) & ", "
y = Round(n.PositionY, 3) & ", "

 

-John

"The best thing about learning is that it never stops, and the rabbit hole will go as deep as you let it."
~John
www.gdgmacros.com

Page 1 of 1 (5 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.