Sunday, April 17, 2011

Create a Via

Make a few Vias appear on a PCB with the reference being the Board Origin. (FYI learn to decipher TR0138 PCB API Reference.PDF that comes with Altium)


Sub ViaCreation
Dim Board
Dim Via
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub
PCBServer.PreProcess
For I = 1 to 10
  ' Create a Via object
  Via = PCBServer.PCBObjectFactory(eViaObject, eNoDimension, eCreate_Default)
  Via.X = MilsToCoord (I * 50) + Board.XOrigin
  Via.Y = MilsToCoord(I * 50) + Board.YOrigin
  Via.Size = MilsToCoord(35)
  Via.HoleSize = MilsToCoord(15)
  Via.LowLayer = eTopLayer
  Via.HighLayer = eBottomLayer

  ' Put this via in the Board object
  Board.AddPCBObject(Via)
  Call PCBServer.SendMessageToRobots(Board.I_ObjectAddress, c_Broadcast,_  PCBM_BoardRegisteration, Via.I_ObjectAddress)

Next

PCBServer.PostProcess
ResetParameters
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")

End Sub

These just makes the screen do a refresh
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")

"Undo Stuff"
PreProcess and PostProcess and the Call PCBServer.SendMessageToRobots(Board.I_ObjectAddress, c_Broadcast, PCBM_BoardRegisteration, Via.I_ObjectAddress)
allow the "Undo" to work with what was just placed on the board, otherwise is may not know that they were added.


http://www.tdpcb.com/