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
<KenJ> wrote in message news:81663@coreldraw.com... Does anyone have know how to do this?
Jeff Harrison MacroMonster.com Daily Diversion Blog
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 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()Dim s As ShapeDim n As NodeDim x As String, y As StringDim xy As String'Dim rVal As LongIf ActiveSelection.Shapes.Count = 0 Then MsgBox "Please select a single curve shape" Exit SubEnd IfSet s = ActiveShapeFor 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."~Johnwww.gdgmacros.com
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
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) & ", "