Thursday, May 05, 2011

GetObject at cursor to pick a component.

Using the GetObject to choose what component to reset the designator to center/center.
Press escape to end action.

Sub ChooseDesReset

Dim Board
Dim Comp
Dim x,y

Set Board = PCBServer.GetCurrentPCBBoard
Call PCBServer.PreProcess

While Board.ChooseLocation(x,y, "Choose Component") = True
  Set Comp = Board.GetObjectAtXYAskUserIfAmbiguous(x,y,MkSet(_
  eComponentObject),AllLayers,eEditAction_Focus)

  If Not(Comp is Nothing) Then
     Call PCBServer.SendMessageToRobots(Comp.Name.I_ObjectAddress,_
     c_Broadcast, PCBM_BeginModify, c_NoEventData)
     Comp.ChangeNameAutoposition = eAutoPos_CenterCenter
     Call PCBServer.SendMessageToRobots(Comp.Name.I_ObjectAddress,_
     c_Broadcast, PCBM_EndModify , c_NoEventData)
  End If
Wend

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

End Sub



http://www.tdpcb.com/