Option Explicit
Dim oMath As cAvaxMath
Dim OffsetD As Single
Private Sub cAvax1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
cAvax1.Command = Cancel_c
End If
End Sub
Private Sub cAvax1_SelectedPoints(SelectId As String, lPointNumber As Long, x1() As Single, y1() As Single, z1() As Single)
Dim h() As Long
Dim lCnt As Long
Dim lMax As Long
Dim iType() As AvaxItemType
Dim vProp() As Variant
Dim vData() As Variant
Dim xyz() As Single, jCnt As Long
Dim x1d As Single, y1d As Single
Dim cx As Single, cy As Single
Dim aR As Single, bR As Single
Dim xV() As Single, yV() As Single, zV() As Single
Dim dAngle As Single, done%
Dim mat3x3() As Single, newH() As Long
ReDim newH(1) As Long
ReDim mat3x3(3, 3) As Single
If SelectId = "Offset_direction" And lPointNumber = 1 Then
lMax = cAvax1.GetSelectedHandlesArr(h())
If lMax > 0 Then
If cAvax1.GetProperties(h(), iType(), vProp(), vData()) = True Then
For lCnt = 1 To lMax
If iType(lCnt) = Line_i Then
xyz() = vData(lCnt)
Call oMath.OffsetLinePoint(xyz(1), xyz(2), xyz(4), xyz(5), OffsetD, x1(1), y1(1), x1d, y1d)
Call cAvax1.Add_Line(xyz(1) + x1d, xyz(2) + y1d, xyz(3), xyz(4) + x1d, xyz(5) + y1d, xyz(6))
ElseIf iType(lCnt) = Polyline_i Then
xyz() = vData(lCnt)
For jCnt = 1 To UBound(xyz()) Step 6
Call oMath.OffsetLinePoint(xyz(jCnt), xyz(jCnt + 1), xyz(jCnt + 3), xyz(jCnt + 4), OffsetD, x1(1), y1(1), x1d, y1d)
Call cAvax1.Add_Line(xyz(jCnt) + x1d, xyz(jCnt + 1) + y1d, xyz(jCnt + 2), xyz(jCnt + 3) + x1d, xyz(jCnt + 4) + y1d, xyz(jCnt + 5))
Next jCnt
ElseIf iType(lCnt) = Ellipse_i Then
xyz() = vData(lCnt)
If cAvax1.GetEllipseGeometry(h(lCnt), cx, cy, aR, bR, dAngle) = True Then
Call oMath.GetEllipseVertices(cx, cy, aR, bR, 60&, xV(), yV(), zV())
If aR <> bR And dAngle <> 0 Then
Call oMath.MATidn(mat3x3())
Call oMath.Rot2dMat(dAngle, cx, cy, done%, mat3x3())
Call oMath.TransformVertices(mat3x3(), xV(), yV())
End If
If oMath.PointInVertices(x1(1), y1(1), xV(), yV()) = True Then
If OffsetD < aR And OffsetD < bR Then
newH(1) = cAvax1.Add_Ellipse(cx, cy, xyz(3), aR - OffsetD, bR - OffsetD)
End If
Else
newH(1) = cAvax1.Add_Ellipse(cx, cy, xyz(3), aR + OffsetD, bR + OffsetD)
End If
If aR <> bR And dAngle <> 0 And newH(1) <> 0 Then
Call cAvax1.RotateItems(newH(), cx, cy, dAngle)
End If
End If
End If
Next lCnt
End If
End If
End If
End Sub
Private Sub Command1_Click()
Dim h() As Long
Dim lCnt As Long
Dim lMax As Long
Dim x() As Single, y() As Single, z() As Single
lMax = cAvax1.GetSelectedHandlesArr(h())
If lMax > 0 Then
OffsetD = Val(InputBox("Offset distance=", , Trim$(Str$(OffsetD))))
If OffsetD <> 0 Then
Call cAvax1.SelectPoints("Offset_direction", 1&, x(), y(), z())
End If
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "My Offset"
OffsetD = 1
Set oMath = New cAvaxMath
Call cAvax1.StartAvax
cAvax1.Add_Line 0, 0, 0, 10, 10, 0
cAvax1.Add_Rectangle 0, 0, 10, 10
cAvax1.Add_Circle 0, 0, 0, 4
cAvax1.Command = AutoLimits_c
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set oMath = Nothing
Call cAvax1.EndAvax
End Sub
Page 1 of 1
Make your own offset command
#1
Posted 23 June 2008 - 06:37 PM
VB6 source code on how to make your own offset command:
Athanasios Gardos
Avax-Software.com
Avax-Software.com
Page 1 of 1
Sign In
Register
Help
Add Reply
MultiQuote