Drawline rotate output x degrees

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Drawline rotate output x degrees

Post by stitch22 » Sun Dec 02, 2012 8:19 pm

Is there a way to rotate the output of the Drawline subroutine?
the demos show rotating the offset which places the object at that angle
but does not change its orientation.
Here is what I came up with but it only flips it no rotation.
I tried using the gdi32 function setworldtransformation but I could not get it to accept my array?

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

Let>scaleD=1
Let>xmax=100
Let>ymax=50
Let>xmin=100
Let>ymin=50
//sample File Data - Lettering:  T  Font:  monotype Corsiva
'let>dxdyData=0,0,3%crlf%0,0,3%crlf%0,0,195%crlf%0.7,-5.4,193%crlf%1.4,-10.8,193%crlf%1.9,-16.1,193%crlf%1.9,-16.1,3%crlf%1.8,-16.2,3%crlf%2.9,-16.2,3%crlf%3.7,-15.4,3%crlf%4,-14.3,3%crlf%4,-13.2,3%crlf%3.9,-12.1,3%crlf%4.7,-11.1,3%crlf%4,-11.4,3%crlf%3.9,-12.5,3%crlf%3.9,-14,3%crlf%3.7,-15.4,3%crlf%2.8,-16.2,3%crlf%1.3,-16.5,3%crlf%1.7,-15.5,3%crlf%1.6,-16.7,3%crlf%2.1,-15.6,3%crlf%2,-16.8,3%crlf%2.3,-15.7,3%crlf%2.5,-16.8,3%crlf%2.5,-15.8,3%crlf%3,-16.7,3%crlf%2.7,-15.7,3%crlf%3.5,-16.4,3%crlf%2.9,-15.6,3%crlf%3.8,-16.1,3%crlf%3.1,-15.4,3%crlf%4.1,-15.7,3%crlf%3.3,-15.2,3%crlf%4.4,-15.2,3%crlf%3.4,-14.9,3%crlf%4.5,-14.8,3%crlf%3.4,-14.6,3%crlf%4.5,-14.3,3%crlf%3.4,-14.3,3%crlf%4.6,-13.9,3%crlf%3.4,-14,3%crlf%4,-13.6,3%crlf%3.9,-12.5,3%crlf%4,-11.4,3%crlf%4.8,-11.1,3%crlf%4.8,-10.7,3%crlf%4.9,-11.6,3%crlf%4.7,-10.6,3%crlf%4.8,-11.7,3%crlf%4.2,-10.6,3%crlf%4.5,-11.7,3%crlf%3.6,-11.1,3%crlf%4.4,-11.7,3%crlf%3.4,-11.7,3%clf%4.4,-11.9,3%crlf%3.4,-12.2,3%crlf%4.4,-12.1,3%crlf%3.4,-12.6,3%crlf%4.4,-12.4,3%crlf%3.4,-13,3%crlf%4.5,-12.7,3%crlf%3.4,-13.4,3%crlf%4.5,-13.1,3%crlf%3.4,-13.7,3%crlf%4.5,-13.5,3%crlf%3.4,-14,3%crlf%3,-13.5,3%crlf%1.4,-13.9,3%crlf%0.2,-14.2,3%crlf%-0.2,-14.1,3%crlf%1.4,-13.7,3%crlf%3.3,-13.6,3%crlf%2.4,-13.8,3%crlf%1.4,-14.1,3%crlf%-0.5,-13.7,3%crlf%-0.4,-15.2,3%crlf%-0.2,-13.6,3%crlf%0.2,-14.2,3%crlf%1.1,-14,3%crlf%2.1,-13.7,3%crlf%3.3,-13.4,3%crlf%3.7,-14,3%crlf%3.6,-12.7,3%crlf%3.3,-14.1,3%crlf%3.2,-12.8,3%crlf%3,-14.2,3%crlf%2.9,-12.8,3%crlf%2.7,-14.3,3%crlf%2.6,-12.9,3%crlf%2.4,-14.3,3%crlf%2.3,-13,3%crlf%2.1,-14.4,3%crlf%2,-13.1,3%crlf%1.8,-14.5,3%crlf%1.7,-13.2,3%crlf%1.5,-14.6,3%crlf%1.3,-13.2,3%crlf%1.2,-14.7,3%crlf%1,-13.3,3%crlf%0.8,-14.7,3%crlf%0.7,-13.4,3%crlf%0.5,-14.8,3%crlf%0.4,-13.5,3%crlf%0.2,-14.9,3%crlf%0.1,-13.6,3%crlf%-0.1,-15,3%crlf%-0.2,-13.6,3%crlf%-0.1,-15,3%crlf%-0.6,-14.9,3%crlf%-0.3,-15.3,3%crlf%-1.2,-15.4,3%crlf%-0.1,-14.9,3%crlf%-1.1,-15,3%crlf%-0.2,-14.5,3%crlf%-1.1,-14.6,3%crlf%-0.2,-14,3%crlf%-1.2,-14.3,3%crlf%-0.3,-13.7,3%crlf%-1.2,-13.8,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-1.2,-13.3,195%crlf%0.9,-10.7,193%crlf%
// arrow with right triangle and left square
let>dxdyData=0,0,3%crlf%0,5,3%crlf%0,25,3%crlf%10,5,3%crlf%10,3,3%crlf%9,3,3%crlf%10,5,3%crlf%-10,5,3%crlf%-10,3,3%crlf%-9,3,3%crlf%-9,5,3%crlf%-10,5,3%crlf%0,25,3



Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 94
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Redraw File'
  ClientHeight = 500
  ClientWidth = 500
  Color = clWhite
  Ctl3D = False
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesktopCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnClose,Quit
GDP>Dialog1,,ClientHeight,Wy
GDP>Dialog1,,ClientWidth,Wx
Let>winX=%Wx%/2
Let>winY=%Wy%/2

Let>delay=0.05

Show>Dialog1

Separate>%dxdyData%,%crlf%,dline
let>c=,
let>st=0
Let>b=1


If>scaleD=1
Let>scale={(%Wx%-10)/(%xmax%+%xmin%)}
Else
Let>scale={(%Wy%-10)/(%ymax%+%ymin%)}
Endif
Let>scale={(round(%scale%*10))/10}

'scale for testing
let>scale=4

'Draw bounding box = to extents
'rect
let>ulx={(%winX%)-(%xmax%)}
Let>uly={(%winY%)-(%ymax%)}
let>lrx={(%winX%)+(%xmin%)}
Let>lry={(%winY%)+(%ymin%)}
GoSub>DrawRectangle,Dialog1.handle,1,0,14547193,ulx,uly,lrx,lry

let>xOffset={(%winX%)-(%xmax%-%xmin%)}
let>yOffset={(%winY%)-(%ymax%-%ymin%)}
Separate>dline_%b%,%c%,dl
SRT>invXY
' inverting  y flips object no rotation
let>dl_2=%dl_2%*-1
let>dl_1=%dl_1%
END>invXY

SRT>orgXY
' original x y
let>dl_2=%dl_2%
let>dl_1=%dl_1%
END>orgXY

let>dl_1={round(%dl_1%*%scale%)}
let>dl_2={round(%dl_2%*%scale%)}
let>dxs=%xOffset%+%dl_1%
let>dys=%yOffset%+%dl_2%

Repeat>b
Let>b=b+1
Separate>dline_%b%,%c%,dl
'orgXY or invXY
GoSub>orgXY
let>dl_1={round(%dl_1%*%scale%)}
let>dl_2={round(%dl_2%*%scale%)}
Wait>%delay%
let>Flag=%dl_3%
if>Flag<3>16777215,color
let>dxs=%xOffset%+%dl_1%
let>dys=%yOffset%+%dl_2%
let>dxe=%dxs%
let>dye=%dys%
else
let>dxe=%xOffset%+%dl_1%
let>dye=%yOffset%+%dl_2%
GoSub>DrawLine,Dialog1.handle,1,%color%,dxs,dys,dxe,dye
let>dxs=%dxe%
let>dys=%dye%
endif
Until>b,dline_count

let>MSG_HEIGHT=100
Let>MSG_WIDTH=200
Let>MSG_XPOS=600
Let>MSG_YPOS=500
MessageModal>Done

//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd

SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

//DrawRectangle Usage:
//GoSub>DrawRectangle,WindowHandle,PenSize,PenColor,SolidColor,ULXLocation,ULYLocation,LRXLocation,LRYLocation

SRT>DrawRectangle
LibFunc>user32,GetDC,HDC,%DrawRectangle_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawRectangle_var_2%,%DrawRectangle_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
LibFunc>gdi32,CreateSolidBrush,SBres,%DrawRectangle_var_4%
LibFunc>gdi32,SelectObject,SOres,hdc,sbres
LibFunc>gdi32,Rectangle,recres,hdc,%DrawRectangle_var_5%,%DrawRectangle_var_6%,%DrawRectangle_var_7%,%DrawRectangle_var_8%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>gdi32,DeleteObject,DOres,sbres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawRectangle


SRT>Quit
Exit>0
END>Quit

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sun Dec 02, 2012 9:30 pm

Hi stitch22,

I ran your code in MS 13.0.00 and it fails at line 105, the following line:

if>Flag16777215,color

- It complains that there is no label or Subroutine called "color"
- Did that line get damaged?
- If so, please re-post your code only make sure to put checkmarks beside all three of the following when you re-post:

Disable HTML in this post
Disable BBCode in this post
Disable Smilies in this post

Thanks
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Sun Dec 02, 2012 10:44 pm

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

Let>scaleD=1
Let>xmax=100
Let>ymax=50
Let>xmin=100
Let>ymin=50
//sample File Data - Lettering:  T  Font:  monotype Corsiva
'let>dxdyData=0,0,3%crlf%0,0,3%crlf%0,0,195%crlf%0.7,-5.4,193%crlf%1.4,-10.8,193%crlf%1.9,-16.1,193%crlf%1.9,-16.1,3%crlf%1.8,-16.2,3%crlf%2.9,-16.2,3%crlf%3.7,-15.4,3%crlf%4,-14.3,3%crlf%4,-13.2,3%crlf%3.9,-12.1,3%crlf%4.7,-11.1,3%crlf%4,-11.4,3%crlf%3.9,-12.5,3%crlf%3.9,-14,3%crlf%3.7,-15.4,3%crlf%2.8,-16.2,3%crlf%1.3,-16.5,3%crlf%1.7,-15.5,3%crlf%1.6,-16.7,3%crlf%2.1,-15.6,3%crlf%2,-16.8,3%crlf%2.3,-15.7,3%crlf%2.5,-16.8,3%crlf%2.5,-15.8,3%crlf%3,-16.7,3%crlf%2.7,-15.7,3%crlf%3.5,-16.4,3%crlf%2.9,-15.6,3%crlf%3.8,-16.1,3%crlf%3.1,-15.4,3%crlf%4.1,-15.7,3%crlf%3.3,-15.2,3%crlf%4.4,-15.2,3%crlf%3.4,-14.9,3%crlf%4.5,-14.8,3%crlf%3.4,-14.6,3%crlf%4.5,-14.3,3%crlf%3.4,-14.3,3%crlf%4.6,-13.9,3%crlf%3.4,-14,3%crlf%4,-13.6,3%crlf%3.9,-12.5,3%crlf%4,-11.4,3%crlf%4.8,-11.1,3%crlf%4.8,-10.7,3%crlf%4.9,-11.6,3%crlf%4.7,-10.6,3%crlf%4.8,-11.7,3%crlf%4.2,-10.6,3%crlf%4.5,-11.7,3%crlf%3.6,-11.1,3%crlf%4.4,-11.7,3%crlf%3.4,-11.7,3%clf%4.4,-11.9,3%crlf%3.4,-12.2,3%crlf%4.4,-12.1,3%crlf%3.4,-12.6,3%crlf%4.4,-12.4,3%crlf%3.4,-13,3%crlf%4.5,-12.7,3%crlf%3.4,-13.4,3%crlf%4.5,-13.1,3%crlf%3.4,-13.7,3%crlf%4.5,-13.5,3%crlf%3.4,-14,3%crlf%3,-13.5,3%crlf%1.4,-13.9,3%crlf%0.2,-14.2,3%crlf%-0.2,-14.1,3%crlf%1.4,-13.7,3%crlf%3.3,-13.6,3%crlf%2.4,-13.8,3%crlf%1.4,-14.1,3%crlf%-0.5,-13.7,3%crlf%-0.4,-15.2,3%crlf%-0.2,-13.6,3%crlf%0.2,-14.2,3%crlf%1.1,-14,3%crlf%2.1,-13.7,3%crlf%3.3,-13.4,3%crlf%3.7,-14,3%crlf%3.6,-12.7,3%crlf%3.3,-14.1,3%crlf%3.2,-12.8,3%crlf%3,-14.2,3%crlf%2.9,-12.8,3%crlf%2.7,-14.3,3%crlf%2.6,-12.9,3%crlf%2.4,-14.3,3%crlf%2.3,-13,3%crlf%2.1,-14.4,3%crlf%2,-13.1,3%crlf%1.8,-14.5,3%crlf%1.7,-13.2,3%crlf%1.5,-14.6,3%crlf%1.3,-13.2,3%crlf%1.2,-14.7,3%crlf%1,-13.3,3%crlf%0.8,-14.7,3%crlf%0.7,-13.4,3%crlf%0.5,-14.8,3%crlf%0.4,-13.5,3%crlf%0.2,-14.9,3%crlf%0.1,-13.6,3%crlf%-0.1,-15,3%crlf%-0.2,-13.6,3%crlf%-0.1,-15,3%crlf%-0.6,-14.9,3%crlf%-0.3,-15.3,3%crlf%-1.2,-15.4,3%crlf%-0.1,-14.9,3%crlf%-1.1,-15,3%crlf%-0.2,-14.5,3%crlf%-1.1,-14.6,3%crlf%-0.2,-14,3%crlf%-1.2,-14.3,3%crlf%-0.3,-13.7,3%crlf%-1.2,-13.8,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-1.2,-13.3,195%crlf%0.9,-10.7,193%crlf%
// arrow with right triangle and left square
let>dxdyData=0,0,3%crlf%0,5,3%crlf%0,25,3%crlf%10,5,3%crlf%10,3,3%crlf%9,3,3%crlf%10,5,3%crlf%-10,5,3%crlf%-10,3,3%crlf%-9,3,3%crlf%-9,5,3%crlf%-10,5,3%crlf%0,25,3



Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 94
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Redraw File'
  ClientHeight = 500
  ClientWidth = 500
  Color = clWhite
  Ctl3D = False
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesktopCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnClose,Quit
GDP>Dialog1,,ClientHeight,Wy
GDP>Dialog1,,ClientWidth,Wx
Let>winX=%Wx%/2
Let>winY=%Wy%/2

Let>delay=0.05

Show>Dialog1

Separate>%dxdyData%,%crlf%,dline
let>c=,
let>st=0
Let>b=1


If>scaleD=1
Let>scale={(%Wx%-10)/(%xmax%+%xmin%)}
Else
Let>scale={(%Wy%-10)/(%ymax%+%ymin%)}
Endif
Let>scale={(round(%scale%*10))/10}

'scale for testing
let>scale=4

'Draw bounding box = to extents
'rect
let>ulx={(%winX%)-(%xmax%)}
Let>uly={(%winY%)-(%ymax%)}
let>lrx={(%winX%)+(%xmin%)}
Let>lry={(%winY%)+(%ymin%)}
GoSub>DrawRectangle,Dialog1.handle,1,0,14547193,ulx,uly,lrx,lry

let>xOffset={(%winX%)-(%xmax%-%xmin%)}
let>yOffset={(%winY%)-(%ymax%-%ymin%)}
Separate>dline_%b%,%c%,dl
SRT>invXY
' inverting  y flips object no rotation
let>dl_2=%dl_2%*-1
let>dl_1=%dl_1%
END>invXY

SRT>orgXY
' original x y
let>dl_2=%dl_2%
let>dl_1=%dl_1%
END>orgXY

let>dl_1={round(%dl_1%*%scale%)}
let>dl_2={round(%dl_2%*%scale%)}
let>dxs=%xOffset%+%dl_1%
let>dys=%yOffset%+%dl_2%

Repeat>b
Let>b=b+1
Separate>dline_%b%,%c%,dl
'orgXY or invXY
GoSub>orgXY
let>dl_1={round(%dl_1%*%scale%)}
let>dl_2={round(%dl_2%*%scale%)}
Wait>%delay%
let>Flag=%dl_3%
if>Flag<>3
Random>16777215,color
let>dxs=%xOffset%+%dl_1%
let>dys=%yOffset%+%dl_2%
let>dxe=%dxs%
let>dye=%dys%
else
let>dxe=%xOffset%+%dl_1%
let>dye=%yOffset%+%dl_2%
GoSub>DrawLine,Dialog1.handle,1,%color%,dxs,dys,dxe,dye
let>dxs=%dxe%
let>dys=%dye%
endif
Until>b,dline_count

let>MSG_HEIGHT=100
Let>MSG_WIDTH=200
Let>MSG_XPOS=600
Let>MSG_YPOS=500
MessageModal>Done

//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd

SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

//DrawRectangle Usage:
//GoSub>DrawRectangle,WindowHandle,PenSize,PenColor,SolidColor,ULXLocation,ULYLocation,LRXLocation,LRYLocation

SRT>DrawRectangle
LibFunc>user32,GetDC,HDC,%DrawRectangle_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawRectangle_var_2%,%DrawRectangle_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
LibFunc>gdi32,CreateSolidBrush,SBres,%DrawRectangle_var_4%
LibFunc>gdi32,SelectObject,SOres,hdc,sbres
LibFunc>gdi32,Rectangle,recres,hdc,%DrawRectangle_var_5%,%DrawRectangle_var_6%,%DrawRectangle_var_7%,%DrawRectangle_var_8%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>gdi32,DeleteObject,DOres,sbres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawRectangle


SRT>Quit
Exit>0
END>Quit
[/code]

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Sun Dec 02, 2012 10:46 pm

I think I got it right that time
thanks

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 03, 2012 4:07 pm

What is it you're wanting to do?

I feel somewhat responsible since you're using my draw routines but you're using those correctly.
the demos show rotating the offset which places the object at that angle
I don't know what demos you're talking about And I don't see any API calls in the code trying to rotate anything.

The setworldtransformation API requires a pointer to a structure. I don't believe we have that ability unless it can be done in VBScript and passed back to a variable in a usable form. I have not investigated that possibility but as a generality, when I see any API that requires a "pointer to a structure" I stop and start looking for a different way.

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Mon Dec 03, 2012 6:55 pm

Hi JRL,

when I use the drawline sub the image is rotated 90 degrees. which is not accepptable. So I was looking for a way to rotate them back.

In the example file there are two data sets one for an arrow and one for the letter T. if your draw the T it will show you what I mean.

The examples not demos sorry, are where I got your sub from.


The API stuff I left out it just complicates the issue. And you just answered that question. And raised another.

Today I just wanted to know about the 90 degree issue. And if it is possible or is there another method of drawing that would be more suitable.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 03, 2012 7:44 pm

stich22,

The drawline sub makes a line between point A and point B. It doesn't cause any rotation of any kind.

I made a new data set that draws a rectangle 5 pixels wide and 10 pixels high. It displays in your dialog as a rectangle that is tall and narrow. This demonstrates that the subroutine is not rotating anything and that your code is translating the data set correctly. My conclusion would be that your data sets are rotated.

Hope this is helpful.




Code: Select all

//sample File Data - Lettering:  T  Font:  monotype Corsiva
'let>dxdyData=0,0,3%crlf%0,0,3%crlf%0,0,195%crlf%0.7,-5.4,193%crlf%1.4,-10.8,193%crlf%1.9,-16.1,193%crlf%1.9,-16.1,3%crlf%1.8,-16.2,3%crlf%2.9,-16.2,3%crlf%3.7,-15.4,3%crlf%4,-14.3,3%crlf%4,-13.2,3%crlf%3.9,-12.1,3%crlf%4.7,-11.1,3%crlf%4,-11.4,3%crlf%3.9,-12.5,3%crlf%3.9,-14,3%crlf%3.7,-15.4,3%crlf%2.8,-16.2,3%crlf%1.3,-16.5,3%crlf%1.7,-15.5,3%crlf%1.6,-16.7,3%crlf%2.1,-15.6,3%crlf%2,-16.8,3%crlf%2.3,-15.7,3%crlf%2.5,-16.8,3%crlf%2.5,-15.8,3%crlf%3,-16.7,3%crlf%2.7,-15.7,3%crlf%3.5,-16.4,3%crlf%2.9,-15.6,3%crlf%3.8,-16.1,3%crlf%3.1,-15.4,3%crlf%4.1,-15.7,3%crlf%3.3,-15.2,3%crlf%4.4,-15.2,3%crlf%3.4,-14.9,3%crlf%4.5,-14.8,3%crlf%3.4,-14.6,3%crlf%4.5,-14.3,3%crlf%3.4,-14.3,3%crlf%4.6,-13.9,3%crlf%3.4,-14,3%crlf%4,-13.6,3%crlf%3.9,-12.5,3%crlf%4,-11.4,3%crlf%4.8,-11.1,3%crlf%4.8,-10.7,3%crlf%4.9,-11.6,3%crlf%4.7,-10.6,3%crlf%4.8,-11.7,3%crlf%4.2,-10.6,3%crlf%4.5,-11.7,3%crlf%3.6,-11.1,3%crlf%4.4,-11.7,3%crlf%3.4,-11.7,3%clf%4.4,-11.9,3%crlf%3.4,-12.2,3%crlf%4.4,-12.1,3%crlf%3.4,-12.6,3%crlf%4.4,-12.4,3%crlf%3.4,-13,3%crlf%4.5,-12.7,3%crlf%3.4,-13.4,3%crlf%4.5,-13.1,3%crlf%3.4,-13.7,3%crlf%4.5,-13.5,3%crlf%3.4,-14,3%crlf%3,-13.5,3%crlf%1.4,-13.9,3%crlf%0.2,-14.2,3%crlf%-0.2,-14.1,3%crlf%1.4,-13.7,3%crlf%3.3,-13.6,3%crlf%2.4,-13.8,3%crlf%1.4,-14.1,3%crlf%-0.5,-13.7,3%crlf%-0.4,-15.2,3%crlf%-0.2,-13.6,3%crlf%0.2,-14.2,3%crlf%1.1,-14,3%crlf%2.1,-13.7,3%crlf%3.3,-13.4,3%crlf%3.7,-14,3%crlf%3.6,-12.7,3%crlf%3.3,-14.1,3%crlf%3.2,-12.8,3%crlf%3,-14.2,3%crlf%2.9,-12.8,3%crlf%2.7,-14.3,3%crlf%2.6,-12.9,3%crlf%2.4,-14.3,3%crlf%2.3,-13,3%crlf%2.1,-14.4,3%crlf%2,-13.1,3%crlf%1.8,-14.5,3%crlf%1.7,-13.2,3%crlf%1.5,-14.6,3%crlf%1.3,-13.2,3%crlf%1.2,-14.7,3%crlf%1,-13.3,3%crlf%0.8,-14.7,3%crlf%0.7,-13.4,3%crlf%0.5,-14.8,3%crlf%0.4,-13.5,3%crlf%0.2,-14.9,3%crlf%0.1,-13.6,3%crlf%-0.1,-15,3%crlf%-0.2,-13.6,3%crlf%-0.1,-15,3%crlf%-0.6,-14.9,3%crlf%-0.3,-15.3,3%crlf%-1.2,-15.4,3%crlf%-0.1,-14.9,3%crlf%-1.1,-15,3%crlf%-0.2,-14.5,3%crlf%-1.1,-14.6,3%crlf%-0.2,-14,3%crlf%-1.2,-14.3,3%crlf%-0.3,-13.7,3%crlf%-1.2,-13.8,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.2,3%crlf%-1.2,-13.3,3%crlf%-0.2,-13.1,3%crlf%-1.2,-13.3,3%crlf%-1.2,-13.3,195%crlf%0.9,-10.7,193%crlf%
// arrow with right triangle and left square
'let>dxdyData=0,0,3%crlf%0,5,3%crlf%0,25,3%crlf%10,5,3%crlf%10,3,3%crlf%9,3,3%crlf%10,5,3%crlf%-10,5,3%crlf%-10,3,3%crlf%-9,3,3%crlf%-9,5,3%crlf%-10,5,3%crlf%0,25,3
let>dxdyData=0,0,3%crlf%0,10,3%crlf%5,10,3%crlf%5,0,3%crlf%0,0,3

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Mon Dec 03, 2012 8:46 pm

For some Direction try drawing an arrow pointing up, U will find that +Y is pointing down not up.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 03, 2012 9:01 pm

This will create an arrow pointing up.

Code: Select all

let>dxdyData=0,0,3%crlf%-5,10,3%crlf%5,10,3%crlf%0,0,3%crlf%0,20,3
As I was typing this it occurred to me what might be wrong. You have placed 0,0 at a specific location on the dialog. I suspect you're expecting a Cartesian coordinate system based on your zero point where positive numbers go to the right and up from zero zero and negative numbers go to the left and down. Unfortunately, that's not how your computer monitor works. On the monitor, as X gets bigger, you move to the right, As Y gets bigger, you move down. So Y is backward from what you are expecting.

Does that explain the situation?

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Mon Dec 03, 2012 9:51 pm

Yes

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Mon Dec 03, 2012 10:25 pm

the files I read in are stitch files for embroidery. so yes this makes sense is there a conversion?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 03, 2012 10:37 pm

I lived AutoCAD for ten years. I don't know why it didn't occur to me earlier.

I think its just a matter of writing your code to account for that issue. basically invent the Cartesian axes in Macro Scheduler. I'll see what I can come up with tonight. If you figure it out be sure to post the solution.

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Mon Dec 03, 2012 11:12 pm

Ok ,Thanks I will. I saw VB examples that use SetWorldTransformation I will take a closer look. That could change the the dialog window coordinate system

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Tue Dec 04, 2012 3:33 pm

After several hours digging and testing. Here is a
Cartesian Coordinates Window using your drawline sub.
We can now change Mapmodes

Code: Select all

SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
//  GraphicsMode
//  MM_Compatible = 1  MM_ADVANCED = 2
LibFunc>gdi32,SetGraphicsMode,gMode,hDC,1
//  Map Mode Values
//  MM_TEXT = 1;      MM_LOMETRIC = 2;
//  MM_HIMETRIC = 3;  MM_LOENGLISH = 4;
//  MM_HIENGLISH = 5; MM_TWIPS = 6;
//  MM_ISOTROPIC = 7; MM_ANISOTROPIC = 8;
LibFunc>gdi32,SetMapMode,mMode,hDC,4
//must set ViewportOrgEx X Y
'LibFunc>gdi32,SetWindowOrgEx,setWor,hDC,0,0,0
LibFunc>gdi32,SetWindowExtEx,setWex,hDC,%Wx%,%Wy%,0
LibFunc>gdi32,SetViewportOrgEx,setVPor,hDC,%xOffset%,%yOffset%,0
LibFunc>gdi32,SetViewportExtEx,setVPex,hDC,%Wx%,%Wy%,0
//
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine
here is a 20 x 20 square and cross

Code: Select all

let>dxdyData=0,25,3%crlf%0,-25,3%crlf%25,0,6%crlf%25,0,3%crlf%-25,0,3%crlf%-20,20,6%crlf%-20,20,3%crlf%-20,-20,3%crlf%20,-20,3%crlf%20,20,3%crlf%-20,20,3
Still no rotation. using the LOENGLISH map mode my data is at -90

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Tue Dec 04, 2012 3:38 pm

Because offsets are set through API calls you no longer need them in the other coding. xOffset and yOffset can and should be removed

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts