Monday, June 06, 2011

Set the DRC error for a component

Simple test to look for the "R2" componet and set it's DRC flag.


Sub SetDRC

Dim Board
Dim CompDes
Set Board = PCBServer.GetCurrentPCBBoard
If Board is Nothing Then Exit Sub

Iterator = Board.BoardIterator_Create
Iterator.AddFilter_ObjectSet(MkSet(eComponentObject))
Iterator.AddFilter_LayerSet(AllLayers)
Iterator.AddFilter_Method(eProcessComponents)
Set CompDes = Iterator.FirstPCBObject
PCBServer.PreProcess

While Not(CompDes Is Nothing)
  If CompDes.Name.Text = "R2" then
     CompDes.SetState_DRCError = True
  End If
  Set CompDes = Iterator.NextPCBObject
Wend

Board.BoardIterator_Destroy(Iterator)
Pcbserver.PostProcess
ResetParameters
Call AddStringParameter("Action", "Redraw")
RunProcess("PCB:Zoom")

End Sub


www.tdpcb.com