Hello,
I'm new, so I have idea to make little application.
I need to draw point or better spline automatically by mouse move on screen.
After that the last point will be in the center of drawing.
On that way I can draw example shape 5mx6m without breaking and moving drawing.
Is that possible?
Thanks
Here is my sample:
Private Sub cAvax1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim x1 As Single
Dim y1 As Single
Dim z1 As Single
Dim vItemProperties As Variant
Dim iClr As Integer
Dim iWidth As Integer
Dim iPointStyle As Integer
Dim iLayer As Integer
Dim AvaxHandle As Long
z1 = 0
AvaxHandle = cAvax1.Add_Point(x, y, 0)
End Sub
Page 1 of 1
Adding spline or point by mouse move?
#3
Posted 30 March 2012 - 11:10 AM
Hi,
You can also try
For pan add
What do you mean by "draw example shape 5mx6m"?
You can also try
cAvax1.Command = FreehandPolyLine_c. For Add_Point to behave correctly replace it with
Dim x1 As Single, y1 As Single Call cAvax1.LongToSingle(CLng(X), CLng(Y), x1, y1) AvaxHandle = cAvax1.Add_Point(x1, y1, 0)
For pan add
cAvax1.Command = Zoom_Pan_c
What do you mean by "draw example shape 5mx6m"?
#4
Posted 31 March 2012 - 08:07 AM
My idea is to use mouse as "scanner".
The original irregular shape in real dimension is about 5x6 m.
PC screen has limitations defined by resolution.
My idea is after drawing every point center of screen will be on that point.
I'm trying to move PC mouse around the shape and that drawing should be on CAD software in
real dimension so I can use that drawing for cutting on CNC machine.
Is it possible?
Thanks
The original irregular shape in real dimension is about 5x6 m.
PC screen has limitations defined by resolution.
My idea is after drawing every point center of screen will be on that point.
I'm trying to move PC mouse around the shape and that drawing should be on CAD software in
real dimension so I can use that drawing for cutting on CNC machine.
Is it possible?
Thanks
#5
Posted 04 April 2012 - 10:09 AM
Try the following code:
Option Explicit
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT_TYPE) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type RECT_TYPE
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub MouseGet(X As Long, Y As Long)
Dim pt As POINTAPI
Dim typ_RECT As RECT_TYPE
GetWindowRect cAvax1.hwnd, typ_RECT
GetCursorPos pt
X = pt.X - typ_RECT.Left
Y = pt.Y - typ_RECT.Top
End Sub
Private Sub MousePut(X As Long, Y As Long)
Dim typ_RECT As RECT_TYPE
GetWindowRect cAvax1.hwnd, typ_RECT
SetCursorPos typ_RECT.Left + X, typ_RECT.Top + Y
End Sub
Private Sub cAvax1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim x1 As Single
Dim y1 As Single
Dim z1 As Single
Dim x2 As Single
Dim y2 As Single
Dim avaxdx As Single, avaxdy As Single
Dim zxMin As Single, zyMin As Single
Dim zxMax As Single, zyMax As Single
Dim xMin As Single, yMin As Single, zMin As Single
Dim xMax As Single, yMax As Single, zMax As Single
Dim AvaxHandle As Long
Dim dxMove As Long, dyMove As Long
Static fIn As Boolean
If Button = MouseButtonConstants.vbRightButton Then Unload Me: Exit Sub
If fIn = True Then Exit Sub
fIn = True
avaxdx = CLng(cAvax1.Width / Screen.TwipsPerPixelX)
avaxdy = CLng(cAvax1.Height / Screen.TwipsPerPixelY)
dxMove = avaxdx / 10
dyMove = avaxdy / 10
Call cAvax1.LongToSingle(CLng(X), CLng(Y), x1, y1)
cAvax1.AutoRedraw = False
AvaxHandle = cAvax1.Add_Point(x1, y1, z1)
If X > avaxdx - dxMove Then
Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call cAvax1.LongToSingle(CLng(X) - dxMove, CLng(Y), x2, y2)
zxMin = zxMin + (x1 - x2)
zxMax = zxMax + (x1 - x2)
If zxMin < xMin Then xMin = zxMin
If zxMax > xMax Then xMax = zxMax
If zyMin < yMin Then yMin = zyMin
If zyMax > yMax Then yMax = zyMax
Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call MousePut(CLng(X) - dxMove, CLng(Y))
ElseIf X < dxMove Then
Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call cAvax1.LongToSingle(CLng(X) + dxMove, CLng(Y), x2, y2)
zxMin = zxMin - (x2 - x1)
zxMax = zxMax - (x2 - x1)
If zxMin < xMin Then xMin = zxMin
If zxMax > xMax Then xMax = zxMax
If zyMin < yMin Then yMin = zyMin
If zyMax > yMax Then yMax = zyMax
Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call MousePut(CLng(X) + dxMove, CLng(Y))
End If
If Y > avaxdy - dyMove Then
Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call cAvax1.LongToSingle(CLng(X), CLng(Y) - dyMove, x2, y2)
zyMin = zyMin + (y1 - y2)
zyMax = zyMax + (y1 - y2)
If zxMin < xMin Then xMin = zxMin
If zxMax > xMax Then xMax = zxMax
If zyMin < yMin Then yMin = zyMin
If zyMax > yMax Then yMax = zyMax
Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call MousePut(CLng(X), CLng(Y) - dyMove)
ElseIf Y < dyMove Then
Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call cAvax1.LongToSingle(CLng(X), CLng(Y) + dyMove, x2, y2)
zyMin = zyMin - (y2 - y1)
zyMax = zyMax - (y2 - y1)
If zxMin < xMin Then xMin = zxMin
If zxMax > xMax Then xMax = zxMax
If zyMin < yMin Then yMin = zyMin
If zyMax > yMax Then yMax = zyMax
Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
Call MousePut(CLng(X), CLng(Y) + dyMove)
End If
cAvax1.AutoRedraw = True
fIn = False
End Sub
Private Sub Form_Load()
Dim avaxdx As Single, avaxdy As Single
Call cAvax1.SetAvaxProperty(BackBitmapDrawingOn_p, False)
Call cAvax1.StartAvax
avaxdx = CLng(cAvax1.Width / Screen.TwipsPerPixelX)
avaxdy = CLng(cAvax1.Height / Screen.TwipsPerPixelY)
Call MousePut(avaxdx / 2, avaxdy / 2)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call cAvax1.EndAvax
End Sub
Athanasios Gardos
Avax-Software.com
Avax-Software.com
Page 1 of 1
Sign In
Register
Help
Add Reply
MultiQuote