Friday, April 29, 2011

File Name On Visible Layers

Create a sting from the PCB file name and place it on the board but leave off the ending (.pcbdoc). It will place a string on any routing and mechanical layer that is currently enabled and is visible.

Sub AddFileName

Dim Board
Dim ASMSting
Dim Layer
Dim TmpString
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub

For Layer = eTopLayer to eMultiLayer
  If Board.LayerIsDisplayed(Layer) AND Board.LayerIsUsed(Layer) Then
   ASMString = PCBServer.PCBObjectFactory(eTextObject,_
eNoDimension, eCreate_Default)
  ASMString.XLocation = Board.XOrigin + MilsToCoord(500) '500 mils from origin in X
  ASMString.YLocation = Board.YOrigin - MilsToCoord(500) '-500 mils from origin in Y
  TmpString = Board.FileName
  'Get rid of the drive and folder portion of the FileName
  While Instr(TmpString, "\") <> 0
    TmpString = Right(TmpString, Len(TmpString)-Instr(TmpString, "\") ) 'removes the path

  ASMString.Text = Left(TmpString, Instr(TmpString, ".") - 1 ) 'removes the extension
  ASMString.Size = MilsToCoord(100) 'Size of the string is 10
  ASMString.Layer = Layer

  Board.AddPCBObject(ASMString) ' Put this string on the Board
  Call PCBServer.SendMessageToRobots(ASMString.I_ObjectAddress, c_Broadcast,_

PCBM_BoardRegisteration, ASMString.I_ObjectAddress)

 End If

Call AddStringParameter("Action", "Redraw")

End Sub