要不要这个圈不是重点,牛的是这个
'....................................................
Dim Board
DIM xm,ym 'mouse coordinate
'-----------------------------------------------------------------------
Sub PlaceSpiralTrackFormCreate(Sender)
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
If Not Board.ChooseLocation(xm,ym,"Choose Spiral Track start location") Then
End If
xm = xm/10000 'convert to mils
ym = ym/10000 '
PlaceSpiralTrackForm.StartX.Text = xm
PlaceSpiralTrackForm.StartY.Text = ym
PlaceSpiralTrackForm.LayerListBox.Text = Layer2String(Board.CurrentLayer) 'get current layer
If (Board.DisplayUnit) Then
PlaceSpiralTrackForm.Metric.Checked = false
Else
PlaceSpiralTrackForm.Metric.Checked = true ' read 0 = Metric, 1 = Inch
End If
StartX.Color = RGB(236, 233, 216)
StartY.Color = RGB(236, 233, 216)
Spacing.Color = RGB(236, 233, 216)
TrackWidth.Color = RGB(236, 233, 216)
Loops.Color = RGB(236, 233, 216)
ViaSize.Color = RGB(236, 233, 216)
ViaHoleSize.Color = RGB(236, 233, 216)
End Sub
'-----------------------------------------------------------------------
Sub XPBitBtn1Click(Sender)
DIM ArcX1, ArcX2, ArcX3, ArcX4, ArcY1, ArcY2, ArcY3, ArcY4
DIM Layer, Radius, Spacing, Width, Offset, Temp
Dim Via, Track, Arc
Dim MouseX, MouseY
If (Board.DisplayUnit) Then
Metric.Checked = false
Else
Metric.Checked = true ' read 0 = Metric, 1 = Inch
End If
Width = TrackWidth.Text
Spacing = (PlaceSpiralTrackForm.Spacing.Text)
Temp = ((Spacing/1) + (Width/1))
Offset = Temp/4
Layer = String2Layer(LayerListBox.Text)
MouseX = StartX.Text
MouseY = StartY.Text
ArcX1 = StartX.Text
ArcY1 = StartY.Text + Offset
ArcX2 = StartX.Text
ArcY2 = StartY.Text
ArcX3 = StartX.Text - Offset
ArcY3 = StartY.Text
ArcX4 = StartX.Text - Offset
ArcY4 = StartY.Text + Offset
Radius = (ViaSize.Text/2) + (Spacing/1) + (Width/2)
PlaceSpiralTrackForm.Hide
PCBServer.PreProcess
'Place Via
Via = PCBServer.PCBObjectFactory(eViaObject, eNoDimension, eCreate_Default)
Via.X = MilsToCoord(MouseX)
Via.Y = MilsToCoord(MouseY)
Via.Size = MilsToCoord(ViaSize.Text)
Via.HoleSize = MilsToCoord(ViaHoleSize.Text)
Via.LowLayer = eTopLayer
Via.HighLayer = eBottomLayer
Board.AddPCBObject(Via)
'Place 1st Arc to met start of sprial
Arc = PCBServer.PCBObjectFactory(eArcObject, eNoDimension, eCreate_Default)
Arc.XCenter = MilsToCoord(StartX.Text/1)
Arc.YCenter = MilsToCoord((StartY.Text/1) + Radius/2)
Arc.Layer = Layer 'eTopLayer
Arc.LineWidth = MilsToCoord(Width/1)
Arc.Radius = MilsToCoord(Radius/2)
Arc.StartAngle = 90
Arc.EndAngle = 270
Board.AddPCBObject(Arc)
' LOOP once for every turn
FOR p0 = 1 TO Loops.Text
'Place arc quadrant
Arc = PCBServer.PCBObjectFactory(eArcObject, eNoDimension, eCreate_Default)
Arc.LineWidth = MilsToCoord(Width/1)
Arc.XCenter = MilsToCoord(ArcX2/1)
Arc.YCenter = MilsToCoord(ArcY2/1)
Arc.Radius = MilsToCoord(Radius/1)
Arc.Layer = Layer 'eTopLayer
Arc.StartAngle = 0
Arc.EndAngle = 90
Board.AddPCBObject(Arc)
Radius = (Radius + Offset)
Arc = PCBServer.PCBObjectFactory(eArcObject, eNoDimension, eCreate_Default)
Arc.LineWidth = MilsToCoord(Width/1)
Arc.XCenter = MilsToCoord(ArcX3/1)
Arc.YCenter = MilsToCoord(ArcY3/1)
Arc.Radius = MilsToCoord(Radius/1)
Arc.Layer = Layer 'eTopLayer
Arc.StartAngle = 270
Arc.EndAngle = 0
Board.AddPCBObject(Arc)
Radius = (Radius + Offset)
Arc = PCBServer.PCBObjectFactory(eArcObject, eNoDimension, eCreate_Default)
Arc.LineWidth = MilsToCoord(Width/1)
Arc.XCenter = MilsToCoord(ArcX4/1)
Arc.YCenter = MilsToCoord(ArcY4/1)
Arc.Radius = MilsToCoord(Radius/1)
Arc.Layer = Layer 'eTopLayer
Arc.StartAngle = 180
Arc.EndAngle = 270
Board.AddPCBObject(Arc)
Radius = (Radius + Offset)
Arc = PCBServer.PCBObjectFactory(eArcObject, eNoDimension, eCreate_Default)
Arc.LineWidth = MilsToCoord(Width/1)
Arc.XCenter = MilsToCoord(ArcX1/1)
Arc.YCenter = MilsToCoord(ArcY1/1)
Arc.Radius = MilsToCoord(Radius/1)
Arc.Layer = Layer 'eTopLayer
Arc.StartAngle = 90
Arc.EndAngle = 180
Board.AddPCBObject(Arc)
Radius = (Radius + Offset)
NEXT
PCBServer.PostProcess
' Refresh PCB workspace.
ResetParameters
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")
Close
End Sub
'-----------------------------------------------------------------------
Sub MetricClick(Sender)
If Metric.Checked Then
StartX.Text = (StartX.Text / 39.37)
StartY.Text = (StartY.Text / 39.37)
ViaSize.Text = (ViaSize.Text / 39.37)
ViaHoleSize.Text = (ViaHoleSize.Text / 39.37)
Spacing.Text = (Spacing.Text / 39.37)
TrackWidth.Text = (TrackWidth.Text / 39.37)
Else
StartX.Text = (StartX.Text * 39.37)
StartY.Text = (StartY.Text * 39.37)
ViaSize.Text = (ViaSize.Text * 39.37)
ViaHoleSize.Text = (ViaHoleSize.Text * 39.37)
Spacing.Text = (Spacing.Text * 39.37)
TrackWidth.Text = (TrackWidth.Text * 39.37)
End If
End Sub
'-----------------------------------------------------------------------
Sub Main
PlaceSpiralTrackForm.showmodal
End Sub
'-----------------------------------------------------------------------
Sub XPBitBtn2Click(Sender)
close
End Sub
|