1 Reply Latest reply on Aug 11, 2016 10:15 PM by Patrick.Cashman

    Component

    shainaor

      Hi All,

      I'm a newbie with automation.

      I wrote a script that looks up for a certain refdes and manipulate the nets of this refdes.

       

      The specific refdes I'm looking for consist of several symbols.

      I thought that the following code result with a component (scomp) that has all the symbols of the specific refdes.

      practically scomp is just the first symbol the query finds.

       

       

      For Each comp in vdapp.Query(VDM_COMP, VD_ALL)

           if comp.Refdes = UCase(refdesf) then

                Set scomp = comp

                exit for

           end if

      Next

       

      is it possible to retrieve all of the symbols as an object?

      am I doing it wrong and it needs to be done differently?

       

      Many thanks for your help,

       

      Shai

        • 1. Re: Component
          Patrick.Cashman

          The component, as you are using it (scomp & comp) consists only of a single symbol.  There is not an object like what you describe, an scomp which includes several symbols.

           

          But let us digress for a moment, to the fast way to do exactly what you want.  If you are working in an integrated design environment with DxDesigner and Xpedition, and you are constrained to use only DxDesigner for this task, just do it in Xpedition.  There you can select an entire component, and quickly get a collection of all the nets attached to the component. 

           

          As in:

          dim comp as mgcpcb.component

          dim nets as mgcpcb.nets

           

          comp = pcbdoc.findcomponent(refdes)

          nets = comp.nets

           

          But, if you must use DxDesigner for this task, it is a bit more complicated.

           

          What you have to do is make a collection variable of nets. Then loop through all the components and select them out by refdes as you have already done.  For each component, you'll do something like the following:

           

          Dim nets as List(of viewdraw.net)

          Dim net as viewdraw.net

          Dim comps as Object

          Dim comp as viewdraw.component

          Dim conns as Object

          Dim conn as viewdraw.connection

           

          (get comps with the query like you already did)

           

          nets.clear

          for each comp in comps

               if comp.refdes = myrefdes then

                    conns = comp.getconnections

                     for each conn in conns

                             nets.add(conn.net)

                     Next

               End If

          Next

           

          Now you have a list of nets.  You can use the ViewDraw nets collection, as you can get using the view.query(32,1), but working with those collections is a bit more clumsy than the generic vb collections, so it's just easier to use the List.  If using a .net environment, you could also use an arraylist, which is even easier because it will hold most any datatype without complaining.

           

          With the list of nets, you can loop through and do whatever you need to with each net.