9 Replies Latest reply on Dec 13, 2012 3:17 AM by lary.e

    Access to CES .Application.Tools.ObjectDefs via C# or DotNet

    joerg.schmidt

      Hello,

       

      i would liket to access the ObjectDefs - object via C#.

      The CES automation license is installed and i can get the Ces.Application.

      To get the electrical nets and net classes i need a ObjectDefs object which i got in VBScript code with following lines:

       

      Set CesApp = GetObject(, "Ces.Application")

      Set CES = CesApp.Tools("CES")

      Set CmsObjDefs = CES.ObjectDefs

      Set NetClasses = CmsObjDefs.Design.NetClasses

      Set ElectricNets = CmsObjDefs.Design.PhysNets

       

      In C# i can create the Ces.Application object. (I have installed an automation license which works)

      But i don't get a ObjectDefs object because its not a member of the Ces.Application.Tools.

      Here is the code so far.

       

      Ces.Application CesApp; //The CES Application Handler

      Ces.Tools CesTools;

      CesApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Ces.Application.Tools.ObjectDefs ") as Ces.Application;

      CesTools = CesApp.Tools;

      CmsObjDes = CesTools.??? ObjectDefs is not available

       

      So how do i get access to the ObjectDefs object of the CES.Application?

      Included Mentor related namespaces are:

      using ViewDraw;

      using Ces;

       

      Maybe i need some other namespaces?

       

      Thanks for your help and best regards,

       

      Joerg

        • 1. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
          Grzegorz_Poczatek

          Hello Joerg

          can I ask what problem you are trying to solve by writing automation script (program)? As you probably know Mentor is to withdraw CES Automation support long term and we would like to help customers add the features they need to CES (or flow) rather then have them coding it themselves.

           

          Best regards,

          Grzegorz

          • 2. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
            joerg.schmidt

            Hello Grzegorz,

             

            I have a script which is written in vbs. This script opens CES, reads all Netclasses and all associated nets and saves them inside the script in an array.

            Then I use this information to color the nets in DxDesigner depending on the netclass. So I can see very quickly which net is in the wrong netclass.

            This is a very usefull function for design reviews in our departmend.

             

            At the moment we use the Version 7.9.2 so the export function (command line tool) from CES (export netclasses, nets... to a excel file) is not available yet, because it will released not until version 7.9.3.

            (When 7.9.3. is available I will change the script to use this function)

             

            Furthermore I like to change my scripting language from vbs to C# because there isn't a really good vbs editor for free.

            I also need a easy way to access data bases via the script and so I choosed C#.

             

            So I would appreciate any help to get access to the ObjectDefs via C#.

            Maybe you have some example code snippets for dotnet? (C#, VisualBasic etc?)

             

            Thanks for your help in advance,

             

            Joerg

            • 3. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
              Grzegorz_Poczatek

              Thanks Joerg

               

              I realized now I have your use case already as you submitted it to cesauto_answers@mentor.com.

              In general CES COM Automation interface can be used with C# too. I will check what I can do for you and send you email back.

               

              Best regards,

              Grzegorz

              • 4. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
                joerg.schmidt

                Hi Grzegorz,

                 

                that sounds good. I'm looking forward to your mail.

                 

                Thanks and best regards,

                 

                joerg

                • 5. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
                  Robert_Szymanski

                  Hello Joerg,

                   

                  I attached below an example how CES automation can be used in C#.

                  The project references should additionally include ce70.dll and CmsObjectDefs70.dll libraries available in SDD_HOME/win32/lib directory.

                   

                  Best regards,

                  Robert

                   

                              Ces.Application oCesApp; //The CES Application Handler

                              CeICDB.Ce oCe;

                              CmsobjectsICDB.CeObjectDefs oCeObjDefs;

                   

                              oCesApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Ces.Application") as Ces.Application;

                              oCe = oCesApp.Tools.Item("CES") as CeICDB.Ce;

                              oCeObjDefs = oCe.ObjectDefs as CmsobjectsICDB.CeObjectDefs;

                              int nNCs = oCeObjDefs.Design.NetClasses.Count;

                  • 6. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
                    joerg.schmidt

                    Hello Robert,

                     

                    sorry for the circumstances but i still have some problems to get the NetClasses.

                    I like to extract the netnames and the coressponding net class.

                    I find a similiar example in the CES automation help.

                     

                    Private Sub writeDataToLogFile()

                         Dim fso As Scripting.FileSystemObject

                         Dim txtfile

                         Set fso = CreateObject("Scripting.FileSystemObject")

                         Set txtfile = fso.CreateTextFile(strExpFile, True)

                         If Not txtfile Is Nothing Then

                               cbLogFile.Enabled = False

                               If lbConstClass.ListIndex <= -1 Then

                                    Exit Sub

                               End If

                               nbSel = 0

                               Set objDefs = Ces.ObjectDefs

                               For i = 0 To lbConstClass.ListCount() - 1

                                    If lbConstClass.Selected(i) Then

                                         nbSel = nbSel + 1

                                         strClass = GetClassName(i)

                                         Set oClass = objDefs.Design.ConstraintClasses(strClass)

                                         txtfile.WriteLine "constraint_class " & strClass

                                         For Each enet In oClass.Nets

                                              txtfile.WriteLine "electrical_net " & enet.Name & " "

                                              If chIncConst.Value Then

                                              For Each cons In enet.Object.Constraints

                                                   txtfile.Write cons.Name & "=" & cons.Value & " "

                                                   Next

                                              End If

                                              Next

                                             If nbSel >= lbConstClass.SelCount Then

                                             Exit For

                                      End If

                                      DoEvents

                               End If

                               Next

                               txtfile.Close

                               cbLogFile.Enabled = True

                         End If

                    End Sub

                     

                    How must this code look in C#?

                    For example i tried to show the available NetClasses via a MessageBox.

                    But i can't use something like oCeObjDefs.Design.NetClasses(netindex) or oCeObjDefs.Design.NetClasses.Item(netindex) because there are no such so methods.

                    Here's my own code so far. How can i get the NetClasses - names?

                     

                    CesApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Ces.Application") as Ces.Application;

                    CesApp.Visible = true;

                    CeICDB.Ce oCe;

                    CmsobjectsICDB.CeObjectDefs oCeObjDefs;

                    oCe = CesApp.Tools.Item("CES") as CeICDB.Ce;

                    oCeObjDefs = oCe.ObjectDefs as CmsobjectsICDB.CeObjectDefs;

                    for (int netindex = 1; netindex <= oCeObjDefs.Design.NetClasses.Count; netindex++)

                    {

                         MessageBox.Show(oCeObjDefs.Design.NetClasses(netindex));

                    }

                     

                    Once again, sorry for the circumstances andd thanks for your help,

                     

                    Joerg

                     

                    BTW: The access to DxDesigner objects works fine for me. For example it was very easy to change component properties. But the Ces automation troubles me :-(

                    • 7. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
                      steve_shively

                      Jörg,


                      Mentor Graphics recommends that customers avoid use of CES Automation, because it is possible to corrupt your constraint data. There are inherent limitations with the CES Automation interface that prevents us from giving you a safe way to use this. In fact, manipulation of net classes is one area of particular concern to us. Furthermore, we will discontinue the CES Automation interface in the future so any code customers have or develop will not work at that point.

                       

                      We encourage customers to work with us to find alternate ways to accomplish their specific design processes, instead of using this interface. In fact, with the EE7.9.3 release, your use case can be completed without use of automation. Please review the CES Highlights video on SupportNet for more details on the new command line tools.


                      However, if you proceed to use CES Automation, we strongly urge you to include a strategy to backup up your design data prior to use of the automation interface, and then carefully verify the correctness of the resulting constraint data.

                       

                      • 8. Re: Access to CES .Application.Tools.ObjectDefs via C# or DotNet
                        MaBUa

                        Steve,

                        just only an idea.... I think Mentor shouldn't stop CES automation capability for READING.

                        (for writing I understand the risk)

                         

                        Martin