Dim App As Object
Set App = CreateObject("PCDLRN.Application")
Dim Part As Object
Set Part = App.ActivePartProgram
Dim Cmds As Object
Set Cmds = Part.Commands
Dim Cmd As Object
Dim PLN_ID$
Dim X#(99), Y#(99), Z#(99)
Dim i%, j%
Dim HDirection%, Hpattern%, NHits%, NHitsRing%, NRings%, hit%, buttonval%
Dim HitAngle#, HitAngleInc#, SRadius#, ERadius#, RadiusInc#
Dim X_theo#, Y_theo#, Z_theo#, Xtheo#, Ytheo#
If NRings > 1 Then
RadiusInc = (ERadius - SRadius) / (NRings - 1)
Else
RadiusInc = 0
End If
If dlg1.EditBox_9 <> 0 Then
If dlg1.EditBox_9 < 0 Then
dlg1.EditBox_9 = 360 + dlg1.EditBox_9
End If
HitAngle = dlg1.EditBox_9*(PI/180)
End If
If dlg1.OptionGroup2 = 1 Then
HDirection = 1
End If
If dlg1.OptionGroup1 = 1 Then
Hpattern = 1
End If
hit = 1
If Hpattern = 1 Then ' Orbital
For i = 1 To NRings
For j = 1 To NHitsRing
If HDirection = 0 Then
Xtheo = SRadius * cos(HitAngle) + X_theo
Ytheo = SRadius * sin(HitAngle) + Y_theo
Else
Xtheo = X_theo + SRadius * cos(HitAngle)
Ytheo = (Y_theo + SRadius * sin(HitAngle) ) * -1
End If
X(hit) = Xtheo
Y(hit) = Ytheo
hit = hit + 1
HitAngle = HitAngle + HitAngleInc
Next j
HitAngle = HitAngle - HitAngleInc
SRadius = SRadius + RadiusInc
Next i
Else ' If it is Not orbital it must be Radial
For i = 1 To NHitsRing
For j = 1 To NRings
If HDirection = 0 Then
Xtheo = SRadius * cos(HitAngle) + X_theo
Ytheo = SRadius * sin(HitAngle) + Y_theo
Else
Xtheo = X_theo + SRadius * cos(HitAngle)
Ytheo = (Y_theo + SRadius * sin(HitAngle)) * -1
End If
X(hit) = Xtheo
Y(hit) = Ytheo
hit = hit + 1
SRadius = SRadius + RadiusInc
Dim PCDapp As Object
Dim PCDpart As Object
Dim Cmds As Object
Dim Cmd As Object
Dim FCmd As Object
Dim Lenght#, Width#
Dim Rows%, RowHits%, NumHits%, hit%
Dim tX#, tY#, tZ#, theo_X#, theo_Y#
Dim theoX#(99), theoY#(99)
Dim PlnID$, Direction$(3)
Dim ButtonVal%, PattLenght#, PattWidth#
Dim pdirection%, wdirection%, start_X#, start_Y#
Set PCDapp = CreateObject("PCDLRN.Application")
Set PCDpart = PCDapp.ActivePartProgram
Set Cmds = PCDpart.Commands
If dlg1.dirListbox = 0 Or dlg1.dirListbox = 2 Then
pdirection = 1
ElseIf dlg1.dirListbox = 1 Or dlg1.dirListbox = 3 Then
wdirection = 1
End If
If pdirection = 1 Then
If dlg1.dirListbox = 0 Then
start_X = tX + (Lenght/2)
start_Y = tY + (Width/2)
PattLenght = PattLenght * -1
PattWidth = PattWidth * -1
ElseIf dlg1.dirListbox = 2 Then
start_X = (tX + (Lenght/2)) * -1
start_Y = (tY + (Width/2)) * -1
End If
Else
If dlg1.dirListbox = 1 Then
start_X = tX - (Width/2)
start_Y = tY + (Lenght/2)
PattLenght = PattLenght * -1
ElseIf dlg1.dirListbox = 3 Then
start_X = (tX - (Width/2)) * -1
start_Y = (tY + (Lenght/2)) * -1
PattWidth = PattWidth * -1
End If
End If
theo_X = start_X
theo_Y = start_Y
If pdirection = 1 Then
For i = 1 To Rows
For h = 1 To RowHits
theoX(hit) = theo_X
theoY(hit) = theo_Y
hit = hit + 1
If h < RowHits Then
theo_X = theo_X + PattLenght
End If
Next h
theo_Y = theo_Y + PattWidth
PattLenght = PattLenght * -1
Next i
ElseIf wdirection = 1 Then
For i = 1 To Rows
For h = 1 To RowHits
theoX(hit) = theo_X
theoY(hit) = theo_Y
hit = hit + 1
If h < RowHits Then
theo_Y = theo_Y + PattLenght
End If
Next h
theo_X = theo_X + PattWidth
PattLenght = PattLenght * -1
Next i
End If
Set Cmd = Cmds.CurrentCommand
Cmds.InsertionPointAfter Cmd
Fixed Bugs with direction when x and y are not zero, and feature theo x y values are not updated
Sub Main
Dim PCDapp As Object
Dim PCDpart As Object
Dim Cmds As Object
Dim Cmd As Object
Dim FCmd As Object
Dim Lenght#, Width#
Dim Rows%, RowHits%, NumHits%, hit%
Dim tX#, tY#, tZ#, theo_X#, theo_Y#
Dim theoX#(99), theoY#(99)
Dim PlnID$, Direction$(3)
Dim ButtonVal%, PattLenght#, PattWidth#
Dim pdirection%, wdirection%, start_X#, start_Y#
Set PCDapp = CreateObject("PCDLRN.Application")
Set PCDpart = PCDapp.ActivePartProgram
Set Cmds = PCDpart.Commands
If dlg1.dirListbox = 0 Or dlg1.dirListbox = 2 Then
pdirection = 1
ElseIf dlg1.dirListbox = 1 Or dlg1.dirListbox = 3 Then
wdirection = 1
End If
If pdirection = 1 Then
If dlg1.dirListbox = 0 Then
start_X = tX + (Lenght/2)
start_Y = tY + (Width/2)
PattLenght = PattLenght * -1
PattWidth = PattWidth * -1
ElseIf dlg1.dirListbox = 2 Then
start_X = (tX - (Lenght/2))
start_Y = (tY - (Width/2))
End If
Else
If dlg1.dirListbox = 1 Then
start_X = tX - (Width/2)
start_Y = tY + (Lenght/2)
PattLenght = PattLenght * -1
ElseIf dlg1.dirListbox = 3 Then
start_X = (tX + (Width/2))
start_Y = (tY - (Lenght/2))
PattWidth = PattWidth * -1
End If
End If
theo_X = start_X
theo_Y = start_Y
If pdirection = 1 Then
For i = 1 To Rows
For h = 1 To RowHits
theoX(hit) = theo_X
theoY(hit) = theo_Y
hit = hit + 1
If h < RowHits Then
theo_X = theo_X + PattLenght
End If
Next h
theo_Y = theo_Y + PattWidth
PattLenght = PattLenght * -1
Next i
ElseIf wdirection = 1 Then
For i = 1 To Rows
For h = 1 To RowHits
theoX(hit) = theo_X
theoY(hit) = theo_Y
hit = hit + 1
If h < RowHits Then
theo_Y = theo_Y + PattLenght
End If
Next h
theo_X = theo_X + PattWidth
PattLenght = PattLenght * -1
Next i
End If
If ButtonVal = -1 Then
Set Cmd = Cmds.CurrentCommand
Cmds.InsertionPointAfter Cmd