4 Replies Latest reply on May 1, 2017 7:06 AM by creynolds1

    Automation DxDesigner change "Symbol Name"


      Hi all

      How can I read the Symbol Name on a component in DxDesigner with automation?

      Then I wont to change the Partition Value. How can I do that?


      Thanks for helps,


        • 1. Re: Automation DxDesigner change "Symbol Name"

          Assuming you already have an active connection from your automation to an open DxDesigner session, you would do something like this:

          Sub fix_props()


                   Dim attr As ViewDraw.Attribute

                   Dim sym_name As String

                   Dim comp As ViewDraw.Component

                   Dim comp_col As Object

                   Dim view As ViewDraw.View


                   blok = Nothing

                   view = app.ActiveView


                   comp_col = view.query(128, 1)


                   For Each comp In comp_col

                       'get the symbol naame

                       attr = comp.FindAttribute("Symbol")

                       If Not attr Is Nothing Then

                           sym_name = attr.Value

                       End If


                       'change the partition naame

                       attr = comp.FindAttribute("Partition")

                       If Not attr Is Nothing Then

                           attr.Value = "New_Partition_Name"

                       End If



          End Sub


          However, changing the partition value like this is not a good idea.  If you are using DxDatabook, you should change it in the part's databook entry in your database.


          If you are replacing a part, it's a whole other can of worms which is much more complicated than can be treated in a thread like this.  It would take an entire application with a lot more going on.

          • 2. Re: Automation DxDesigner change "Symbol Name"

            Hi Patrick.


            I too am trying to read the "Symbol Name" from xDx. I tried your example without luck. The code below never finds a "Symbol Name". I can see, what I would call user properties (with boxes below), but I cannot see, what I would call the default properties, ie "Symbol Name". Any ideas?


            (I tried to use the syntax highlighting but it never displayed correctly...)


            ViewDraw.IVdObjs cmpntQuery = xdxView.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL);


            ViewDraw.IVdAttr attr;

            string sym_name;

            ViewDraw.IVdComp comp;

            int attrCnt = 0;


            for (int i = 1; i <= cmpntQuery.Count; i++)


                comp = cmpntQuery.Item(i);

                attrCnt = comp.Attributes.Count;

                // display any attributes found

                if (attrCnt != 0)


                    for (int j = 1; j < attrCnt; j++)


                        attr = comp.Attributes.Item(j);

                        Console.WriteLine("attr {0}, {1}: {2}", j, attr.Name, attr.Value);



                //get the symbol name

                attr = comp.FindAttribute("Symbol Name");

                if (attr != null)


                    sym_name = attr.Value;






            • 3. Re: Automation DxDesigner change "Symbol Name"

              The way I read the documentation, the user-defined symbol name can be obtained by comp.symbol rather than by comp.Findattribute.


              I haven't tried, but in an existing script, I used


              objComp.SymbolBlock.GetName(SHORT_NAME) instead - as in


              If (objComp.SymbolBlock.GetName(SHORT_NAME) = "cap_PF") and (objComp.SymbolBlock.SheetNum = "1" ) Then

                objComp.Selected = True


                OrigStr=objComp.SymbolBlock.GetName(SHORT_NAME)& "." & objComp.SymbolBlock.SheetNum

                NewStr = "cap.2"

              End If


              Could you give that a try ?


              • 4. Re: Automation DxDesigner change "Symbol Name"

                That indeed returned what I was after, from my example above, "res".



                            // get the symbol name from symbol
                            string symBlkName = comp.SymbolBlock.GetName(ViewDraw.VdNameType.SHORT_NAME);
                            Console.WriteLine("symbol attr: {0}", symBlkName);


                Thank you Peter!