DxDesigner: Resetting RefDes of selected components

Version 2

    RefDes can be reset by selecting a component or components and then perform 'Delete Property' on Ref Designator row in properties window.

     

    But this does not work when the selection includes other objects such as global symbols(GND, VCC) or pins

     

    Below Automation code is to automate resetting RefDes of selected components even though the selection includes other objects so that you don't need to adjust selection filter.

     

     

    Set colPins = Application.ActiveView.Query(VDM_COMPPIN+VDM_PIN, VD_SELECTED)
    If colPins.Count > 0 Then
      For Each obj In colPins
        obj.Selected = False
      Next
    End If
    Set colComponents = Application.ActiveView.Query(VDM_COMP, VD_SELECTED)
    If Not colComponents.Count < 1 Then
      For Each oComponent In colComponents
        Set oRefAttr = oComponent.FindAttribute("Ref Designator")
        If Not oRefAttr Is Nothing Then
          oRefAttr.Delete
        End If
      Next
    End If